文章作者:里海
来源网站:https://blog.csdn.net/WangPaiFeiXingYuan
UF_UI_specify_screen_position
Defined in: uf_ui.h
int UF_UI_specify_screen_position(char * message, UF_UI_motion_fn_t motion_cb, void * motion_cb_data, double screen_pos [ 3 ] , tag_t * view_tag, int * response )
overview 概述
This function allows you to indicate a screen position by pressing MB1
in the graphics window. The screen position and the tag of the view it
is in are returned.
An empty dialog is displayed with only the Back and Cancel buttons enabled.
The function UF_UI_set_cursor_view affects the screen_pos
and view_tag that is returned and passed to the motion callback. This
is particularly true with respect to the display of a drawing view. The
two values for the new_cursor_view parameter of UF_UI_set_cursor_view affect
the view_tag and screen_pos parameters of UF_UI_specify_screen_position as
follows:
. If new_cursor_view is set to “Any View” and the cursor is in a
drawing member view, then the return values for the view_tag and
screen_pos are the tag of the member view and the position in
Absolute Coordinates in that member view.
. If the new_cursor_view is set to “Work View”, then regardless of
whether the cursor is in a member view or not, the return values
for the view_tag and screen_pos are the tag of the drawing and the
position in drawing coordinates.
If Grid Snap is presently enabled, the screen position is automatically
snapped. This also applies to the position passed to the motion
callback.
This function accepts a motion callback which will be called in
response to each detected movement (i.e. “motion”) of the cursor
within the graphics window. The callback will be passed the current
position and view of the cursor, and the client data pointer.
The typedef for motion callbacks is defined in uf_disp.h as follows:
typedef void (UF_UI_motion_fn_t)(
double screen_pos[3],
UF_UI_motion_cb_data_p_t motion_cb_data,
void data );
All of the above parameters are input parameters to the callback
function:
screen_pos is the current position of the crosshair, given in Work
Part Absolute Coordinates (as described above).
motion_cb_data is a pointer to a data structure; presently, only
the following field of this structure should be referenced:
motion_cb_data->view_tag is the tag of the view of the
current crosshair position.
Finally, the third parameter to the motion callback, data, is the client
data pointer initially passed to UF_UI_specify_screen_position along
with the callback.
In general, a motion callback will generate some graphical feedback
based on the current cursor position, using Overlay Graphics
primitives. Overlay Graphics primitives are defined using the
UF_DISP_display_ogp_ functions. Overlay Graphics primitives
generated from a motion callback will be displayed immediately
following the invocation of the callback, and will be automatically
erased just before the next invocation, and upon the completion of
the call to UF_UI_specify_screen_position.
Please see the Overview of the section on Overlay Graphics primitive
functions in the Display chapter for further information regarding
their behavior and usage.
Keep in mind that your motion callback will be invoked in response to
every detected movement of the cursor (in the graphics window). If
you find that the display of the cursor appears to be “choppy”, or that
it doesn’t seem to be “keeping up” with your movement of the mouse,
it may be that you are attempting to do too many calculations and/or
define too many primitives from your motion callback.
There must be a part loaded when this function is called.
这个功能允许您通过在图形窗口中按 MB1来指示屏幕位置。返回屏幕位置及其所在视图的标记。将显示一个空对话框,其中仅启用“返回”和“取消”按钮。函数 UF _ UI _ set _ cursor _ view 影响返回并传递给运动回调的 screen _ pos 和 view _ tag。在绘图视图的显示方面尤其如此。UF _ UI _ set _ cursor _ view 的 new _ cursor _ view 参数的两个值如下所示影响 UF _ UI 的 view _ tag 和 screen _ pos 参数:。如果 new _ cursor _ View 被设置为“ AnyView”,并且光标位于绘图成员视图中,那么 View _ tag 和 screen _ pos 的返回值是成员视图的标记以及该成员视图中绝对坐标的位置。?.如果 new _ cursor _ View 被设置为“ Work View”,那么无论游标是否在成员视图中,View _ tag 和 screen _ pos 的返回值都是绘图的标记和绘图坐标中的位置。如果目前启用了 GridSnap,则屏幕位置将自动快照。这也适用于传递给运动回调的位置。此函数接受一个运动回调,该回调将响应在图形窗口中检测到的光标的每个运动(即“运动”)而被调用。回调将传递游标的当前位置和视图以及客户端数据指针。用于运动回调的 typedef 在 UF _ disp.h 中定义如下: typedef void (UF _ UI _ motion _ fn _ t)(double screen _ pos [3] ,UF _ UI _ motion _ cb _ data _ p _ t motion _ cb _ data,void data) ; 所有上述参数都是回调函数的输入参数: screen _ pos 是工作部件绝对坐标中给出的十字线的当前位置(如上所述)。Motion _ cb _ data 是一个指向数据结构的指针; 目前,只需要引用该结构的以下字段: motion _ cb _ data-> view _ tag 是当前十字线位置视图的标记。最后,运动回调的第三个参数 data 是客户端数据指针,它最初连同回调一起传递给 UF _ UI _ specite_ screen _ position。通常,运动回调将使用 Overlay Graphics 原语基于当前光标位置生成一些图形反馈。Overlay Graphics 基元是使用 UF _ DISP _ display _ ogp _ 函数定义的。从运动回调生成的 Overlay Graphics 原语将在回调调用之后立即显示,并且将在下一次调用之前以及在对 UF _ UI _ special _ screen _ position 的调用完成之后自动擦除。请参阅“显示”章节中关于叠加图形原语函数的概述,以获得有关其行为和用法的进一步信息。请记住,您的动作回调将被调用来响应每一个检测到的光标移动(在图形窗口中)。如果你发现光标的显示出现了“断断续续”,或者它似乎没有“跟上”你的鼠标移动,这可能是你试图做太多的计算和/或定义太多的原语从你的运动回调。当调用这个函数时,必须有一个加载的部分。
UFUN例子
欢迎订阅《里海NX二次开发3000例专栏》https://blog.csdn.net/wangpaifeixingyuan/category_8840986.html,点击链接扫码即可订阅(持续更新中)。已经有几百人订阅,订阅是永久的,无限期阅读,如需帮助请私信。
parameters 参数
char * | message | Input | Cue line message (132 Character maximum), or NULL 提示行消息(最大132个字符) ,或者 NULL |
UF_UI_motion_fn_t | motion_cb | Input | Motion callback function, or NULL 运动回调函数,或 NULL |
void * | motion_cb_data | Input | Client data pointer, or NULL; will be passed to motion_cb 客户端数据指针或 NULL; 将被传递给 motion _ cb |
double | screen_pos [ 3 ] | Output | The screen position in Work Part Absolute Coords, projected “through the screen” onto the WCS XY plane. This is given in Work Part Absolute Coordinates. This is only returned if the response returned is UF_UI_PICK_RESPONSE. 工作部件绝对坐标中的屏幕位置,通过屏幕投影到 WCS XY 平面上。这是在工作部分的绝对坐标给出。仅当返回的响应为 UF _ UI _ PICK _ RESPONSE 时才返回。 |
tag_t * | view_tag | Output | Tag of the view in which the screen position was indicated. This is only returned if the response returned is UF_UI_PICK_RESPONSE. 指示屏幕位置的视图的标记。仅当返回的响应为 UF _ UI _ PICK _ RESPONSE 时才返回。 |
int * | response | Output | One of the following: UF_UI_PICK_RESPONSE UF_UI_BACK UF_UI_CANCEL 以下内容之一: UF _ UI _ PICK _ RESPONSE UF _ UI _ Back UF _ UI _ CANCEL |
>>> 返回目录
文章来源:https://www.toymoban.com/news/detail-857110.html
C++语言在UG二次开发中的应用及综合分析
- C++ 是C语言的扩展,它既可以执行C语言的过程化程序设计,也可以进行以抽象数据类型为特点的基于对象的设计,以及面向对象的程序设计。C++ 在处理问题规模上具有很大的适应性。
- C++不仅具有计算机高效运行的实用性特征,并且致力于提升大规模程序的编程质量以及程序设计语言的问题描述能力。
在UG二次开发中,C++语言具有以下特点
- C++语言支持多种程序设计风格
- C++的许多特性以库的形式存在,保证了语言的简洁和开发运行的效率
- 与C语言相比,C++引入了面向对象的概念,使得UG二次开发的人机交互界面更加简洁
- 通过借助UG自带的2000多种API函数,结合高级语言C++以及编程软件Visual Studio,可以对UG进行二次开发
- 需要注意的是,市场上的Visual Studio和UG版本众多,并非所有版本都能兼容
程序设计过程通常包括以下步骤:
- 问题分析:对要解决的问题进行深入的分析,理解问题的具体需求和限制。
- 需求定义:明确程序的目标和功能,包括用户需求、系统需求等。
- 设计:根据需求进行设计,包括算法设计、数据结构设计、界面设计等。
- 编码:根据设计的结果,使用一种编程语言将程序代码实现出来。
- 测试:通过各种测试方法来确保程序的正确性,包括单元测试、集成测试、系统测试等。
- 维护:对程序进行修改和完善,以解决可能出现的问题或满足新的需求。
- 文档编写:编写程序文档,描述程序的功能、操作方法、注意事项等。
以下是一个创建体素特征(块、柱、锥、球)的二次开发例子
#include <stdio.h>
#include <stdarg.h>
#include <uf_modl_primitives.h>
#include <uf_ui_ugopen.h>
#include <uf.h>
#include <uf_defs.h>
//封装打印函数,用于将信息打印到信息窗口
//QQ3123197280
int ECHO(const char* szFormat, ...)
{
char szMsg[5000] = "";
va_list arg_ptr;
va_start(arg_ptr, szFormat);
vsprintf_s(szMsg, szFormat, arg_ptr);
va_end(arg_ptr);
UF_UI_open_listing_window();
UF_UI_write_listing_window(szMsg);
return 0;
}
extern DllExport void ufusr(char* param, int* returnCode, int rlen)
{
UF_initialize();
//创建块
UF_FEATURE_SIGN sign = UF_NULLSIGN;
//块起点相对于ABS
double block_orig[3] = { 0.0,0.0,0.0 };
//方向相对于WCS
char* block_len[3] = { "10", "30", "10" };
tag_t blk_obj;//体特征
UF_MODL_create_block1(sign, block_orig, block_len, &blk_obj);
int iEdit = 0;
char* size[3];
UF_MODL_ask_block_parms(blk_obj, iEdit, size);
ECHO("%s,%s,%s\n", size[0], size[1], size[2]);//输出: p6=10,p7=30,p8=10
//创建圆柱
UF_FEATURE_SIGN sign1 = UF_NULLSIGN;
double origin[3] = { 10.0,0.0,10.0 };
char height[] = "20";
char diam[] = "10";
double direction[3] = { 0,0,1 };//方向
tag_t cyl_obj_id;
UF_MODL_create_cyl1(sign1, origin, height, diam, direction, &cyl_obj_id);
int iEdit2 = 0;
char* cDiameter;
char* cHeight;
UF_MODL_ask_cylinder_parms(cyl_obj_id, iEdit2, &cDiameter, &cHeight);
ECHO("%s,%s\n", cDiameter, cHeight);//输出:p9=10,p10=20
UF_free(cDiameter);
UF_free(cHeight);
//创建圆锥
UF_FEATURE_SIGN sign2 = UF_NULLSIGN;
double origin2[3] = { 0.0,0.0,10.0 };
char height2[] = "20";
char* diam2[2] = { "10" ,"5" };
double direction2[3] = { 0,0,1 };//方向
tag_t cone_obj_id;
UF_MODL_create_cone1(sign2, origin2, height2, diam2, direction2, &cone_obj_id);
int iEdit3 = 0;
char* cD1;
char* cD2;
char* cH;
char* cAngle;
UF_MODL_ask_cone_parms(cone_obj_id, iEdit3, &cD1, &cD2, &cH, &cAngle);
ECHO("%s,%s,%s,%s\n", cD1, cD2, cH, cAngle);//输出:p11=10,p12=5,p13=20,p14=7.1250163489018
UF_free(cD1);
UF_free(cD2);
UF_free(cH);
UF_free(cAngle);
//创建球
UF_FEATURE_SIGN sign3 = UF_NULLSIGN;
double douCenter2[3] = { 0.0,0.0,30.0 };
char cDiam[] = "8";
tag_t sphere_obj_id;
UF_MODL_create_sphere1(sign3, douCenter2, cDiam, &sphere_obj_id);
int iEdit4 = 0;
char* cDiam_parm;
UF_MODL_ask_sphere_parms(sphere_obj_id, iEdit4, &cDiam_parm);
ECHO("%s\n", cDiam_parm);//输出:p15=8
UF_free(cDiam_parm);
UF_terminate();
}
extern int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
效果:
文章来源地址https://www.toymoban.com/news/detail-857110.html
到了这里,关于NX二次开发UF_UI_specify_screen_position 函数介绍的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!