iCAx开思工具箱

标题: CAA怎样实现这个命令怎样改Annotation的批注线的长度和角度? [打印本页]

作者: cupcake    时间: 2005-9-1 17:29
标题: CAA怎样实现这个命令怎样改Annotation的批注线的长度和角度?
各位高手:  
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批注,但是批注线的方向和批注线的长度不满足我的要求,请问怎样把批注线的长度减小,角度与所要标注的直线垂直?
作者: liuruixiao205    时间: 2005-9-2 10:38
顶!还有就是批注线的形状能自己定义吗?
作者: saeba    时间: 2005-9-2 12:53
Encyclopedia的例子里有这个说明:
Modifying Leader Extremity Symbol
        CATIDrwEltWithLeader * piEltWithLeader = NULL;
        rc = piText -> QueryInterface(IID_CATIDrwEltWithLeader,
                                      (void **) [$piEltWithLeader)]
        if ( SUCCEEDED(rc) )
        {
          int LeaderCount = piEltWithLeader -> GetNbLeader ();
          if ( LeaderCount >= 1 )
          {
            CATIDrwLeader_var spDrwLeader = piEltWithLeader -> GetLeader (1);
            if ( NULL_var !=spDrwLeader )
            {
            }
          }
          piEltWithLeader -> Release();
          piEltWithLeader = NULL;
        }
...
   
The interface CATIDrwEltWithLeader from DraftingInterface framework is available on 3D Text Annotation. It can be used to retrieve annotation's leaders and to modify them.
  
再看看CATIDrwLeader,有AddPoint(), ModifyPoint()等很多方法,
应该可以改变Leader(引线)的形状,长度
作者: cupcake    时间: 2005-9-3 09:50
谢谢seaba兄了,我看到过这些但是就是不知道所谓的Leader和anchor point of the leader 指的是什么,这些单词都认识,但是就是不知道该怎么翻译。
:)
作者: cupcake    时间: 2005-9-3 15:25
还是没有成功
:(
作者: cupcake    时间: 2005-9-6 23:25
现在我的程序能实现批注,但是位置有点偏,见图1,acoka兄说要计算anchor point 的坐标,确实需要,不知道怎样计算,因为CATIDrwLeader或者CATIDrwEltWithLeader对anchor point 其实是2D点,我现在是在3D状态下标注,因此要用CATIDrwLeader的SetAnchorPoint()来设置anchor point就应该设法把3D点(假设标注的是直线的端点,其实是为了给直线标注)转为2D点,但是投影平面又不是xy,yz,zx或者与他们平行的面,我还没有想出应该怎样把CATMathPoint转为CATMathPoint2D的方法,请指教。
作者: cupcake    时间: 2005-9-6 23:27
图1
作者: cupcake    时间: 2005-9-6 23:29
图2,我想做成图2的样子,就是让文字就在直线的端点旁边,我的做法是先做出端点,然后在端点处标注。
作者: acoka    时间: 2005-9-7 14:38
基本的矢量计算,任何的线性代数的教材都会有说明的呀
  
cupcake wrote:
现在我的程序能实现批注,但是位置有点偏,见图1,acoka兄说要计算anchor point 的坐标,确实需要,不知道怎样计算,因为CATIDrwLeader或者CATIDrwEltWithLeader对anchor point 其实是2D点,我现在是在3D状态下标注,因此要用CATIDrwLeader的SetAnchorPoint()来设置anchor point就应该设法把3D点(假设标注的是直线的端点  
  
......
  

作者: cupcake    时间: 2005-9-22 23:05
最近又看了看函数,发现了CATMathPlane有个Project 函数,原型如下:
Project
public void Project( const CATMathPoint&  iPointToProject,
double&  ioFirstParamOnPlane,
double&  ioSecondParamOnPLane) const

Retrieves the projection of a CATMathPoint on a CATMathPlane.
Parameters:
ioFirstParamOnPlane
The parameter of the projection on the first direction of the plane.
ioSecondParamOnPlane
The parameter of the projection on second direction of the plane.
请问这个函数是不是能完成把一个空间点投影到该平面上,并得到点在该平面上的H和V局部坐标?我是这样做的:
CATMathPoint mathPT;
spThePoint->GetMathPoint(mathPT);
theMathPlane.Project(mathPT,FirstParam,SecondParam);
请问FirstParam和SecondParam是不是H和V局部坐标?我用FirstParam和SecondParam作为参数传到1楼的程序中去,把如下:piAnnot-Move(DeltaX, DeltaY); 改成了piAnnot-Move(FirstParam, SecondParam);结果还是不对,批注没有标到直线的端点上去(我传进来的spThePoint就是直线端点),请指教,谢谢了
:)
作者: beacher0234    时间: 2011-2-24 17:34
谁能告诉我为什么用不成CATMathPoint ,提示缺少动态链接库




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3