几何尺寸与公差论坛

 找回密码
 注册
查看: 3944|回复: 1

CLinearDimension::SetOffsetPosition

[复制链接]
发表于 2008-4-9 17:01:10 | 显示全部楼层 |阅读模式
void CLinearDimension::SetOffsetPosition(CCadDimensionData &dimensionData)
{
  if (!m_dAnnotation)
    return;
  IANNOTATION swAnnotation(m_dAnnotation);
  // //Upper-left corner of the text box of the dimension
  //SafeDoubleArray dbPositionArray (swAnnotation.GetPosition());

  //double *dbPosition = NULL;
  //SafeArrayAccessData(dbPositionArray.m_pSafeArray, (void**)&dbPosition);

  LPDISPATCH dDisplayData = NULL;
  dDisplayData = swAnnotation.GetDisplayData();
  swAnnotation.DetachDispatch();
  //CCadPoint3 centerPt;
  //if (dbPositionArray.getSize() > 2)
  //  centerPt.Set(dbPosition[0], dbPosition[1], dbPosition[2]);
  if (!dDisplayData)
    return;
  IDISPLAYDATA swDisplayData(dDisplayData);
  long lgLineCount = 0;
  lgLineCount = swDisplayData.GetLineCount();
  CCadPoint3 startPt1, endPt1, startPt2, endPt2, startPt3, endPt3;
  for(int nIndex = 0; nIndex < lgLineCount; nIndex ++)
  {
    SafeDoubleArray dbLineArray(swDisplayData.GetLineAtIndex2(nIndex));
    double *dbLine = NULL;
    SafeArrayAccessData(dbLineArray.m_pSafeArray, (void**)&dbLine);  
    int nLength = dbLineArray.getSize();
    CCadPoint3FArray pointArray;
    CCadPoint3 startPt, endPt;
    if (nLength >= 10)
    {
      startPt.Set(dbLine[4], dbLine[5], dbLine[6]);
      endPt.Set(dbLine[7], dbLine[8], dbLine[9]);
      pointArray.Add(startPt);
      pointArray.Add(endPt);
    }
    if (nLength >= 10 && 2 == nIndex)
    {
      startPt3 = startPt;
      endPt3 = endPt;
    }  
    if (nLength >= 10 && 1 == nIndex)
    {
      startPt2 = startPt;
      endPt2 = endPt;
    }
    else if (nLength >= 10 && 0 == nIndex)
    {
      startPt1 = startPt;
      endPt1 = endPt;
    }  
    if (pointArray.GetSize() > 0)
    {
      dimensionData.m_drawPoints.Add(pointArray);
    }
  }
  GetRotateMatrix(XAXIS, endPt3, startPt3, startPt1, dimensionData.m_position);  
  dimensionData.m_position.SetOffset (endPt3);
  swDisplayData.DetachDispatch();
}
 楼主| 发表于 2008-4-9 17:02:59 | 显示全部楼层

回复: CLinearDimension::SetOffsetPosition

void CDiameterDimension::SetOffsetPosition(CCadDimensionData &dimensionData)
{
if (!m_dAnnotation)
return;
IANNOTATION swAnnotation(m_dAnnotation);
// Upper-left corner of the text box of the dimension
//SafeDoubleArray dbPositionArray (swAnnotation.GetPosition());

//double *dbPosition = NULL;
//SafeArrayAccessData(dbPositionArray.m_pSafeArray, (void**)&dbPosition);

LPDISPATCH dDisplayData = NULL;
dDisplayData = swAnnotation.GetDisplayData();
swAnnotation.DetachDispatch();
//CCadPoint3 centerPt;
//if (dbPositionArray.getSize() > 2)
// centerPt.Set(dbPosition[0], dbPosition[1], dbPosition[2]);
if (!dDisplayData)
return;
IDISPLAYDATA swDisplayData(dDisplayData);
long lgLineCount = 0;
lgLineCount = swDisplayData.GetLineCount();
CCadPoint3 startPt1, endPt1, startPt2, endPt2;
for(int nIndex = 0; nIndex < lgLineCount; nIndex ++)
{
SafeDoubleArray dbLineArray(swDisplayData.GetLineAtIndex2(nIndex));
double *dbLine = NULL;
SafeArrayAccessData(dbLineArray.m_pSafeArray, (void**)&dbLine);
int nLength = dbLineArray.getSize();
CCadPoint3FArray pointArray;
CCadPoint3 startPt, endPt;
if (nLength >= 10)
{
startPt.Set(dbLine[4], dbLine[5], dbLine[6]);
endPt.Set(dbLine[7], dbLine[8], dbLine[9]);
pointArray.Add(startPt);
pointArray.Add(endPt);
}
if (nLength >= 10 && 1 == nIndex)
{
startPt2 = startPt;
endPt2 = endPt;
}
else if (nLength >= 10 && 0 == nIndex)
{
startPt1 = startPt;
endPt1 = endPt;
}
if (pointArray.GetSize() > 0)
{
dimensionData.m_drawPoints.Add(pointArray);
}
}
GetRotateMatrix(XAXIS, endPt2, endPt1, startPt1, dimensionData.m_position);
dimensionData.m_position.SetOffset (endPt2);
swDisplayData.DetachDispatch();
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 19:31 , Processed in 0.037176 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表