|
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();
} |
|