Pro/E之為裝配模型樹中元件添加右擊快捷菜單,實現對元件聚焦顯示

/*==========================================*\
FUNCTION: UserZoomAtSelPoint
PURPOSE:  Zooms window in by factor of 2 at selected point on a solid
model.
\*===========================================*/
ProError UserZoomAtSelPoint()
{
	ProError status;
	ProSelection *p_sel;
	int n_sel;
	ProAsmcomppath comp_path;
	ProPoint3d p3d;
	ProMatrix matrix, zoom_matrix;
	ProPoint3d t_point;
	ProFileName msgfile;
	ProModelitem item;
	ProMdl top_model;

	ProPoint3d scrpnt;
	int i, j, k;
	int window;
	double scale;

/*-------------------------------------*\
The Pro/ENGINEER "virtual window".  Used to calculate the amount
of pan needed to center the zoomed window on the chosen point.
\*--------------------------------------*/
double window_outline [2][3] = {{0.0, 0.0, 0.0}, {1000.0, 843.75, 0.0}};

	ProStringToWstring (msgfile, "HelpMessage.txt");

	/*----------------------------------------*\
	Prompt the user to select the center of the zoom
	\*------------------------------------------*/
	ProMessageDisplay (msgfile, "USER Select a location on a solid model for zoom ");

	status = ProSelect ("prt_or_asm", 1, NULL, NULL, NULL, NULL, &p_sel, &n_sel); 
	if (status != PRO_TK_NO_ERROR)
		return (status);

	
	/*-------------------------------------------*\
	Get the selected point
	\*-------------------------------------------*/
	ProSelectionPoint3dGet (p_sel[0], p3d);

	/*-------------------------------------------*\
	Get the assembly component path for the selected component 
	\*-------------------------------------------*/
	status = ProSelectionAsmcomppathGet (p_sel[0], &comp_path);
	if (status == PRO_TK_NO_ERROR && comp_path.owner != NULL)
	{

		top_model = comp_path.owner;
/*--------------------------------------------*\
	Get the coordinate transformation matrix for the component to
	the assembly
\*-----------------------------------------------*/
		ProAsmcomppathTrfGet (&comp_path, PRO_B_TRUE, matrix);

/*---------------------------------------------*\
	Transform the selected point into the coordinate system of the 
	top level assembly
\*-------------------------------------------------*/
		status = ProPntTrfEval(p3d, matrix, t_point);

	}
	else
	{

/*---------------------------------------------------*\
	If the selection is the top level component prepare the needed
	parameters for zooming
\*--------------------------------------------------*/
		ProSelectionModelitemGet (p_sel[0], &item);
		top_model =  item.owner;
		memcpy (t_point, p3d, sizeof (ProPoint3d));
	}

	/*------------------------------------------------*\
	Get the view transformation matrix (from the current window)
	\*-------------------------------------------------*/
	ProViewMatrixGet (top_model, NULL, matrix);

	/*---------------------------------------------------*\
	Transform the solid model point to screen coordinates
	\*-------------------------------------*/
	ProPntTrfEval (t_point, matrix, scrpnt);

	/*---------------------------------------------------*\
	Get the window pan-zoom transformation matrix
	\*-----------------------------------------------*/
	ProWindowCurrentMatrixGet (matrix);

	/*-----------------------------------------------*\
	Zoom in on the created point
	\*-------------------------------------------------*/
	for (j=0; j<4; j++)
	{
		for (k=0; k<4; k++)
			zoom_matrix [j][k] = 0.0;
	}

	/*----------------------------------------------*\
	Double the existing window scale
	\*------------------------------------------------*/
	scale = 2.0 * matrix [0][0];

	for (j=0; j<3; j++)
	{
	zoom_matrix [j][j] = scale;
	zoom_matrix [3][j] = 
	(window_outline [1][j] - window_outline [0][j])/2.0 -
			scrpnt[j]*scale;
	}

	zoom_matrix [3][3] = 1.0;

	ProMdlWindowGet (top_model, &window);

	status = ProWindowPanZoomMatrixSet (window, zoom_matrix);

	/*-----------------------------------------------*\
	Repaint the window
	\*-------------------------------------------------*/
	ProWindowRepaint (window);

	//加亮此元件
	ProSelectionHighlight(p_sel[0],PRO_COLOR_SELECTED);

	return (status);
}

转载于:https://www.cnblogs.com/samyangvs05/archive/2010/04/19/1715718.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值