MSCE C++ 元素预览的问题

老师好:

     为了便于沟通和交流,我重新创建了一个贴子。

通过老师点点滴滴的 指导 和 浏览论坛 其他的相关帖子 ,找到了 部分资料,并将代码编译通过了。但是仍旧有些问题。具体如下

 我的业务场景是 当用户定义 一个 3D元素的时候,通过预览按钮 ,可以在  Generic  上显示出来该元素,但是目前 测试发现  Generic 上没有反应(没有显示该元素)。

具体业务逻辑是 :

当用户点击 预览按钮后 ,将根据定义好的数据 创建出来一个元素(CELL),最终通过调用 void  drawCellDetail(MSDialogP  dbP , DialogItem  *diP , int   is3d , MSElementDescrP cellDP)函数,将这个元素(CELL)显示到 Generic上,从而达到预览的效果(并且 要求 该元素(CELL) 不添加到当前的设计文件中,只是 预览的功能)。

其中 diP 是 Generic 句柄,

dbP是  diP ->GetDialog () ,

is3d 是 1,

cellDP是我代码创建的cell 通过   eehTmp.GetElementDescrP(); 获取的。

代码如下:

ppp=mdlDialog_itemGetByTypeAndId(dimP->db,RTYPE_Generic  ,GENERICID_Cells , 0 );

drawCellDetail(ppp->GetDialog ()  , ppp , 1 , pz.ElementD);

编译通过的代码如下:

void  drawCellDetail(MSDialogP  dbP , DialogItem  *diP , int   is3d , MSElementDescrP cellDP)
{
	ViewFlags       viewflags;
    RotMatrix       rMatrix;
    BSIRect         localRect;
    Dpoint3d        origin, newextent;
    int         nDices;  
    DRange3d         dRangeVec=Bentley::DRange3d::From(0,0,0,0,0,0);
   // int             status;
	//dRangeVec->From(0,0,0,0,0,0);
    localRect = diP->rect;

    mdlElmdscr_validate (cellDP, MASTERFILE);

    nDices = mdlModelRef_is3D (MASTERFILE);

    if (!is3d)
      {

    mdlRMatrix_getIdentity (&rMatrix);
    mdlCnv_scanRangeToDRange (&dRangeVec, &cellDP->el.hdr.dhdr.range);
    origin = dRangeVec.low;
    origin.z = 0.0;

    mdlVec_subtractPoint (&newextent,&dRangeVec.high,&origin);

    newextent.z = fc_1000;
    if (newextent.x < fc_1) newextent.x = fc_1000;
    if (newextent.y < fc_1) newextent.y = fc_1000;

    memset (&viewflags, 0, sizeof(viewflags));
    viewflags.patterns   = 1;
    viewflags.ed_fields  = 1;
    viewflags.on_off     = 1;
    viewflags.grid     = 1;
    viewflags.constructs = 1;
    viewflags.dimens     = 1;

   // mdlDialog_rectInset(&localRect, 3, 3);

    mdlWindow_clipRectSet ((MSWindow *)dbP, &localRect);

    mdlElmdscr_displayToWindow ((MSWindow *)dbP, &localRect,&viewflags ,cellDP, &rMatrix,
                &origin, &newextent, nDices, -1);

    mdlWindow_clipRectSet ((MSWindow *)dbP, NULL);
	
        }
    else
        {
        BSIRect localRectArray[4];
        int     deltaX;
        int     deltaY;
        int     winNumber;
        RotMatrix  rMatrixArray[4];
        //set up the views
        mdlView_getStandard (&rMatrixArray[0],StandardView::Top);
        mdlView_getStandard (&rMatrixArray[1],StandardView::Iso);
        mdlView_getStandard (&rMatrixArray[2],StandardView::Front);
        mdlView_getStandard (&rMatrixArray[3],StandardView::Right);

        deltaX = localRect.corner.x - localRect.origin.x;
        deltaY = localRect.corner.y - localRect.origin.y;

        localRectArray[0] = localRect;
        localRectArray[0].corner.y = localRect.origin.y+(deltaY/2);
        localRectArray[0].corner.x = localRect.origin.x+(deltaX/2);

        localRectArray[1] = localRect;
        localRectArray[1].origin.x = localRect.origin.x+(deltaX/2);
        localRectArray[1].corner.y = localRect.origin.y+(deltaY/2);

        localRectArray[2] = localRect;
        localRectArray[2].origin.y = localRect.origin.y+(deltaY/2);
        localRectArray[2].corner.x = localRect.corner.x-(deltaX/2);


        localRectArray[3]  = localRect;
        localRectArray[3].origin.x = localRect.origin.x+(deltaX/2);
        localRectArray[3].origin.y = localRect.origin.y+(deltaY/2);

        for (winNumber  = 0;winNumber <4  ;winNumber++ )
            {
            mdlCnv_scanRangeToDRange (&dRangeVec, &cellDP->el.hdr.dhdr.range);

            mdlRMatrix_multiplyRange (&dRangeVec.low,&dRangeVec.high,&rMatrixArray[winNumber]);
            mdlVec_subtractPoint (&newextent,&dRangeVec.high,&dRangeVec.low);

			mdlRMatrix_multiplyTransposePoint(&dRangeVec.low, &rMatrixArray[winNumber]);

            if (newextent.z< fc_1) newextent.z = fc_1000;
            if (newextent.x < fc_1) newextent.x = fc_1000;
            if (newextent.y < fc_1) newextent.y = fc_1000;

            memset (&viewflags, 0, sizeof(viewflags));
            viewflags.patterns   = 1;
            viewflags.ed_fields  = 1;
            viewflags.on_off     = 1;
            viewflags.grid     = 1;
            viewflags.constructs = 1;
            viewflags.dimens     = 1;

           // mdlDialog_rectInset(&localRectArray[winNumber], 2, 2);

            mdlWindow_clipRectSet ((MSWindow *)dbP, &localRect);

            mdlElmdscr_displayToWindow ((MSWindow *)dbP, &localRectArray[winNumber],&viewflags ,cellDP, &rMatrixArray[winNumber],
                                              &dRangeVec.low, &newextent, nDices, -1);
            mdlDialog_rectDrawEdge (dbP,&localRectArray[winNumber],TRUE);
            mdlWindow_clipRectSet ((MSWindow *)dbP, NULL);

            }
        }
		
    mdlElmdscr_freeAll (&cellDP);
}

希望老师在百忙之中 ,帮忙分析一下 ,是什么原因,辛苦老师了!!感激!!!

Parents Reply Children
No Data