马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
各位高手:
boolean MyCmd1CmdreateTextOnGeometry(CATISpecObject_var spPointAsSpec,CATMathPlane Plane,double M)
{
// Retrieve the selected geometry
HRESULT rc = S_OK;
CATPathElement* pPathElement = NULL;
do {
if( !spPointAsSpec )
{
break;
}
CATIBuildPath* pBuildPath = NULL;
{
rc = spPointAsSpec->QueryInterface(IID_CATIBuildPath,(void**)[$pBuildPath)]
if(FAILED(rc))
{
break;
}
}
CATPathElement activePath = CATFrmEditor::GetCurrentEditor()->GetUIActiveObject();
rc = pBuildPath->ExtractPathElement([$activePath,&pPathElement)]
{
if(!!pBuildPath)
{
pBuildPath->Release();
pBuildPath = NULL;
}
if(FAILED(rc) || !pPathElement)
{
break;
}
}
} while(0);
if ( !pPathElement )
{
return FALSE;
}
CATSO * pSelection = new CATSO(0);
pSelection->AddElement(pPathElement,0);
if ( pSelection )
{
// Retrieve CATITPSFactoryAdvanced interfaces
CATITPSFactoryAdvanced * piFactAdv = NULL;
HRESULT rc =CATTPSInstantiateComponent (DfTPS_ItfTPSFactoryAdvanced,
(void**) [$ piFactAdv)]
if ( SUCCEEDED(rc) && !!piFactAdv)
{
CATITPSText * piText = NULL;
CATUnicodeString TextString;
TextString.BuildFromNum(M,"%g");
rc = piFactAdv ->CreateTextOnGeometry (pSelection, &lane,
[$TextString , &piText)]
if ( SUCCEEDED(rc) )
{
// Modifying Text Position
CATIDrwAnnotation * piAnnot = NULL;
rc = piText -> QueryInterface (IID_CATIDrwAnnotation,
(void**) [$ piAnnot)]
if ( SUCCEEDED(rc) )
{
double DeltaX = -1;
double DeltaY = +1;
piAnnot->Move(DeltaX, DeltaY);
piAnnot->SetOrientation(90/CATRadianToDegree);
piAnnot ->Release();
piAnnot = NULL;
}
// Modifying Text Size And Font
CATIDrwTextProperties * piTxtProp = NULL;
rc = piText -> QueryInterface (IID_CATIDrwTextProperties,
(void**) [$ piTxtProp)]
if ( SUCCEEDED(rc) )
{
// Change Font Size to 1.5 millimeters
piTxtProp -> SetFontSize (3);
piTxtProp ->SetMirroring(CATDrwFlipVertical);
piTxtProp -> Release();
piTxtProp = NULL;
}
// Use CATIDrwTextProperties::Refresh for updating visualization
// after leader and text modification
rc = piText -> QueryInterface (IID_CATIDrwTextProperties,
(void**) [$ piTxtProp)]
if ( SUCCEEDED(rc) )
{
piTxtProp -> Refresh();
piTxtProp -> Release();
piTxtProp = NULL;
}
piText -> Release();
piText = NULL;
}
piFactAdv -> Release();
piFactAdv = NULL;
}
}
return (TRUE);
}
以上代码完成3D批注,但是批注线的方向和批注线的长度不满足我的要求,请问怎样把批注线的长度减小,角度与所要标注的直线垂直? |