1897 lines
44 KiB
C++
1897 lines
44 KiB
C++
#include "stdafx.h"
|
||
#include "SymbolAnnotateJig.h"
|
||
|
||
|
||
//以下类是从EditSymbolAnnotate.cpp中分离出来 by lgy 20120109
|
||
TComposingEdJig::TComposingEdJig(TDbSymbComposing *pElev)
|
||
{
|
||
m_pDrawEnt=pElev;
|
||
}
|
||
|
||
AcEdJig::DragStatus
|
||
TComposingEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
XPoint ptBase=m_nOperCode==kTextLine? m_pDrawEnt->GetTurnPoint() : m_pDrawEnt->GetStartPoint();
|
||
return acquirePoint(pt, ptBase);
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TComposingEdJig::DoIt(int *keyIndex)
|
||
{
|
||
// delete by xly on 100917 做法标注绘制过程中不影响对象捕捉
|
||
//XPushVar<int> osmode(_T("OSMODE"), 0);//add by whl
|
||
if(m_nOperCode==kTurnPoint) {
|
||
m_ptResult=m_pDrawEnt->GetStartPoint();
|
||
} else if(m_nOperCode==kTextLine) {
|
||
XPoint ptTemp;
|
||
ads_polar(m_pDrawEnt->GetTurnPoint(), 0.0, m_pDrawEnt->GetTextBaseLen(FALSE), ptTemp);
|
||
m_ptResult=ptTemp;
|
||
}
|
||
int nRet = TSymbEdJig::DoIt(keyIndex);
|
||
return nRet;
|
||
}
|
||
|
||
// 更新实体数据,sg modify 081105
|
||
Adesk::Boolean TComposingEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet = Adesk::kTrue;
|
||
double nVal(0); // sg add 081105,当前线长,统一代码用
|
||
if (m_nOperCode == kTurnPoint) {
|
||
m_pDrawEnt->SetTurnPoint(m_ptResult);
|
||
nVal = m_pDrawEnt->GetTextBaseLen(FALSE); // sg add 081105
|
||
}
|
||
else if (m_nOperCode == kTextLine)
|
||
{
|
||
// refreshed by whl on 060208
|
||
// double nVal=m_ptResult.x - m_pDrawEnt->GetTurnPoint().x;
|
||
// double nVal = Wcs2Ucs(m_ptResult).x - Wcs2Ucs(m_pDrawEnt->GetTurnPoint()).x;
|
||
// sg modify 081105
|
||
nVal = Wcs2Ucs(m_ptResult).x - Wcs2Ucs(m_pDrawEnt->GetTurnPoint()).x;
|
||
m_pDrawEnt->SetTextBaseLen(nVal, FALSE);
|
||
}
|
||
|
||
// sg modify 090225,解决M单位图的问题
|
||
// double dDist2Line = m_pDrawEnt->GetDistSymbol()*57, // 距线距离系数
|
||
// sg modify 090429,解决改变比例后,绘制距离远的BUG,此解决方案,可兼顾M单位图的问题
|
||
double dFixDist = 0.57 * DocGetPScale();
|
||
double dDist2Line = m_pDrawEnt->GetDistSymbol()*dFixDist, // 距线距离系数
|
||
dPageWidth = 0; // 页宽,sg add 081104
|
||
m_pDrawEnt->SetDist2Line(dDist2Line, FALSE);
|
||
m_pDrawEnt->SetAlignBySymbol(); // 设置对齐方式,sg add 081104
|
||
if (!m_pDrawEnt->IsSideText()) // 文字在线上,sg modify 081105
|
||
{
|
||
dPageWidth = nVal - 2*m_pDrawEnt->GetDist2Line(FALSE);
|
||
}
|
||
m_pDrawEnt->SetPageWidth(dPageWidth, FALSE);
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* TComposingEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TComposingAddOtherPtJig::TComposingAddOtherPtJig(XPoint ptStart, XPoint ptBase)
|
||
{
|
||
m_ptLeader = ptBase.AsAcGePoint3d();
|
||
m_ptFirstVertexes = ptStart.AsAcGePoint3d();
|
||
m_line.setStartPoint(m_ptLeader);
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TComposingAddOtherPtJig::DoIt(int *keyIndex)
|
||
{
|
||
return TSymbEdJig::DoIt(keyIndex);
|
||
}
|
||
|
||
AcEdJig::DragStatus TComposingAddOtherPtJig::GetPoint(AcGePoint3d &pt)
|
||
{
|
||
// 自由拖拽,不受正交控制
|
||
return acquirePoint(pt);
|
||
}
|
||
|
||
Adesk::Boolean TComposingAddOtherPtJig::update()
|
||
{
|
||
// 将JIG时的鼠标位置点,投影到第一条引线上
|
||
AcGePoint3d ptRet = m_ptResult,
|
||
ptOnLine;
|
||
// 引线
|
||
AcDbLine line(m_ptFirstVertexes, m_ptLeader);
|
||
|
||
// 获得拖拽点到引线的投影点
|
||
line.getClosestPointTo(ptRet, ptOnLine, Adesk::kTrue);
|
||
m_ptResult = ptOnLine;
|
||
|
||
m_line.setEndPoint(m_ptResult);
|
||
return Adesk::kTrue;
|
||
}
|
||
AcDbEntity* TComposingAddOtherPtJig::entity() const
|
||
{
|
||
return (AcDbEntity *)&m_line;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TIndexPointerEdJig::TIndexPointerEdJig(TDbSymbIndexPointer *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
m_pDlg = NULL;
|
||
}
|
||
|
||
void TIndexPointerEdJig::InitCutLine()
|
||
{
|
||
ASSERT(m_pDrawEnt != NULL);
|
||
ASSERT(!m_pDrawEnt->IsIndexPointer());
|
||
|
||
m_pDrawEnt->GetCutLineAll(m_arCutAdded);
|
||
m_arCutAdded.RemoveAt(0); // 删除第一个。
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TIndexPointerEdJig::DoIt(int *keyIndex)
|
||
{
|
||
XPushVar<int> osmode(_T("OSMODE"), 0); // add by whl,关闭对象捕捉
|
||
if (m_nOperCode == kSourceExtent) // 指向范围
|
||
{
|
||
m_drawEnt.setPropertiesFrom(m_pDrawEnt);
|
||
m_drawEnt.setRadius(m_pDrawEnt->GetSourceExtent()/2.0);
|
||
m_drawEnt.setCenter((const AcGePoint3d &)m_pDrawEnt->GetStartPoint());
|
||
m_ptResult = m_pDrawEnt->GetStartPoint();
|
||
}
|
||
else if (m_nOperCode==kTurnPoint || m_nOperCode==kViewDirection) // 转折点、剖视方向
|
||
{
|
||
m_ptResult = m_pDrawEnt->GetStartPoint();
|
||
}
|
||
else if (m_nOperCode == kTextBasePoint)
|
||
{
|
||
m_ptResult = m_pDrawEnt->GetTextBasePoint();
|
||
}
|
||
|
||
int nRet = TSymbEdJig::DoIt(keyIndex);
|
||
if (m_nOperCode==kSourceExtent && nRet==RTNORM)
|
||
m_pDrawEnt->SetSourceExtent(m_drawEnt.radius()*2.0);
|
||
if (m_nOperCode == kMoreCuts)
|
||
{
|
||
if (nRet == RTNORM)
|
||
{
|
||
m_arCutAdded.Add(m_cutCurrDrag);
|
||
}
|
||
else if (nRet == RTNONE)
|
||
{
|
||
m_pDrawEnt->SetCutLine(m_arCutAdded);
|
||
m_arCutAdded.RemoveAll();
|
||
}
|
||
}
|
||
return nRet;
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus TIndexPointerEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
DragStatus stat;
|
||
if (m_nOperCode==kSourceExtent || m_nOperCode==kViewDirection ||
|
||
m_nOperCode==kTurnPoint || m_nOperCode == kAddedTurn)
|
||
{ // modify by lgh,添加对“新添得转折点的支持。”
|
||
XPoint ptBase = m_pDrawEnt->GetStartPoint();
|
||
if (m_nOperCode == kTurnPoint && m_pDrawEnt->HasAddedPoint())
|
||
{
|
||
m_pDrawEnt->GetAddedPoint(ptBase);
|
||
}
|
||
stat = acquirePoint(pt, ptBase);
|
||
}
|
||
else
|
||
stat = acquirePoint(pt);
|
||
return stat;
|
||
}
|
||
|
||
extern XPoint pptfirst_; // [11/12/2007 nsh]
|
||
extern double sAngle_;
|
||
Adesk::Boolean TIndexPointerEdJig::update() // 更新实体数据
|
||
{
|
||
if ((m_pDlg != NULL) && (m_pDrawEnt != NULL))
|
||
{
|
||
if (m_pDlg->m_bDimOnExtent)
|
||
{
|
||
m_pDlg->UpdateData();
|
||
const double dMinLen = TDbSymbIndexPointer::GetDefaultExtendLineLen();
|
||
double dTextLen1 = m_pDlg->GetUpDimLen();
|
||
double dTextLen2 = m_pDlg->GetDownDimLen();
|
||
double dLen = max(dTextLen1, dTextLen2)/m_pDrawEnt->GetPScale();
|
||
if (dLen < dMinLen)
|
||
dLen = dMinLen;
|
||
|
||
m_pDrawEnt->SetExtendLineLen(dLen);
|
||
m_pDrawEnt->SetDimPos(1);
|
||
}
|
||
else
|
||
{
|
||
m_pDrawEnt->SetExtendLineLen(0.0);
|
||
m_pDrawEnt->SetDimPos(0);
|
||
}
|
||
}
|
||
|
||
Adesk::Boolean bRet = Adesk::kTrue;
|
||
if (m_nOperCode == kSourceExtent) // 指向范围
|
||
{
|
||
m_drawEnt.setRadius(m_ptResult.Distance2d(m_pDrawEnt->GetStartPoint()));
|
||
}
|
||
else if (m_nOperCode == kTurnPoint) // 引线首个转折点
|
||
{
|
||
// m_pDrawEnt->SetTurnPoint(m_ptResult); // add by cwk on 060704
|
||
if (!m_bFixAngle) // add by cwk on 060704
|
||
{
|
||
m_pDrawEnt->SetTurnPoint(m_ptResult);
|
||
}
|
||
else
|
||
{
|
||
// [11/12/2007 nsh]
|
||
static double ss = sAngle_;
|
||
if (CIndexDimDlg::m_iIndexType == 0) // 非剖切的情况
|
||
{
|
||
if (ss >= 0) // 处理输入的角度值为大于零的数值
|
||
{
|
||
AcGePoint3d ap3;
|
||
ads_real x0, y0;
|
||
ads_real xi, yi;
|
||
XPoint xxxx = pptfirst_;
|
||
x0 = pptfirst_.x;
|
||
y0 = pptfirst_.y;
|
||
xi = Wcs2Ucs(m_ptResult).x;
|
||
yi = Wcs2Ucs(m_ptResult).y;
|
||
if (xi>=x0 && yi>=y0)
|
||
{
|
||
m_dFixAngle = sAngle_;
|
||
}
|
||
else if (xi<x0 && yi>=y0)
|
||
{
|
||
m_dFixAngle = 180 - sAngle_;
|
||
}
|
||
else if (xi<=x0 && yi<y0)
|
||
{
|
||
m_dFixAngle = 180 + sAngle_;
|
||
}
|
||
else if (xi>x0 && yi<y0)
|
||
{
|
||
m_dFixAngle = 360 - sAngle_;
|
||
}
|
||
}
|
||
else if (ss < 0) // 处理角度值为小于零的情况
|
||
{
|
||
AcGePoint3d ap3;
|
||
static double fabsAngle;
|
||
fabsAngle = fabs(sAngle_);
|
||
double x0, y0;
|
||
double xi, yi;
|
||
x0 = pptfirst_.x;
|
||
y0 = pptfirst_.y;
|
||
xi = m_ptResult.x;
|
||
yi = m_ptResult.y;
|
||
if (xi>=x0 && yi>=y0) // 第一象限
|
||
{
|
||
m_dFixAngle = fabsAngle;
|
||
}
|
||
else if (xi<x0 && yi>=y0)
|
||
{
|
||
m_dFixAngle = 180 - fabsAngle;
|
||
}
|
||
else if (xi<=x0 && yi<y0)
|
||
{
|
||
m_dFixAngle = 180 + fabsAngle;
|
||
}
|
||
else if (xi>x0 && yi<y0)
|
||
{
|
||
m_dFixAngle = 360 - fabsAngle;
|
||
}
|
||
}
|
||
|
||
XPoint ptTemp = m_pDrawEnt->GetStartPoint();
|
||
double d1 = sqrt((Wcs2Ucs(m_ptResult).x - Wcs2Ucs(ptTemp).x)
|
||
* (Wcs2Ucs(m_ptResult).x - Wcs2Ucs(ptTemp).x)
|
||
+ (Wcs2Ucs(m_ptResult).y - Wcs2Ucs(ptTemp).y)
|
||
* (Wcs2Ucs(m_ptResult).y - Wcs2Ucs(ptTemp).y));
|
||
double d3 = atan2(Wcs2Ucs(m_ptResult).y - Wcs2Ucs(ptTemp).y,
|
||
Wcs2Ucs(m_ptResult).x - Wcs2Ucs(ptTemp).x);
|
||
double d2 = cos((m_dFixAngle / 180)* PI - d3);
|
||
double d = d1 * d2;
|
||
|
||
XPoint ptTurn;
|
||
ptTurn.y = Wcs2Ucs(ptTemp).y + d * sin((m_dFixAngle / 180)* PI);
|
||
ptTurn.x = Wcs2Ucs(ptTemp).x + d * cos((m_dFixAngle / 180)* PI);
|
||
m_pDrawEnt->SetTurnPoint(Ucs2Wcs(ptTurn));
|
||
}
|
||
else
|
||
{
|
||
m_pDrawEnt->SetTurnPoint(m_ptResult);
|
||
}
|
||
}
|
||
}
|
||
else if (m_nOperCode == kTextBasePoint) // Modify on 2002/10/14,文字基线长度
|
||
{
|
||
XPoint ptTurn = m_pDrawEnt->GetTurnPoint();
|
||
// modified by whl on 060208
|
||
double nDist = Wcs2Ucs(m_ptResult).x - Wcs2Ucs(ptTurn).x;
|
||
// double nDist = m_ptResult.Distance2d(ptTurn);
|
||
// if (m_ptResult.x < ptTurn.x)
|
||
// nDist = -nDist;
|
||
|
||
/*
|
||
XLine ln(m_pDrawEnt->GetStartPoint(), m_pDrawEnt->GetTurnPoint());
|
||
// Modify on 2002/2/25 by ZJQ, 解决水平方向的问题
|
||
if (fabs(sin(ln.Direction())) < 1.0E-6)
|
||
{
|
||
if (fabs(ln.Direction()-PI) < 1.0E-6)
|
||
nDist = -nDist;
|
||
}
|
||
else
|
||
{
|
||
int nSide = ln.OnWhichSide(m_ptResult);
|
||
if (nSide == OFFSET_LEFT)
|
||
nDist = -nDist;
|
||
}
|
||
*/
|
||
m_pDrawEnt->SetTextBaseLen(nDist, FALSE);
|
||
}
|
||
else if (m_nOperCode == kViewDirection) // 剖视方向
|
||
{
|
||
XLine ln(m_pDrawEnt->GetStartPoint(), m_pDrawEnt->GetTurnPoint());
|
||
int nSide = ln.OnWhichSide(m_ptResult);
|
||
double nVal = (nSide==OFFSET_LEFT) ?
|
||
fabs(m_pDrawEnt->GetSourceExtent()) : -fabs(m_pDrawEnt->GetSourceExtent());
|
||
m_pDrawEnt->SetSourceExtent(nVal);
|
||
}
|
||
// add by lgh.添加多“新增转折点”和"多个剖切线"的支持
|
||
else if (m_nOperCode == kAddedTurn)
|
||
{
|
||
m_pDrawEnt->SetAddedPoint(m_ptResult);
|
||
m_pDrawEnt->SetTurnPoint(m_ptResult);
|
||
}
|
||
else if (m_nOperCode == kMoreCuts)
|
||
{
|
||
XLine firstLine = m_pDrawEnt->GetFirstLine();
|
||
AcGeLineSeg3d geFirstLine(firstLine.StartPoint().AsAcGePoint3d(), firstLine.EndPoint().AsAcGePoint3d());
|
||
|
||
XPoint nearPoint = geFirstLine.closestPointTo(m_ptResult.AsAcGePoint3d());
|
||
|
||
if (nearPoint != firstLine.StartPoint() && nearPoint != firstLine.EndPoint())
|
||
{
|
||
XVector3D vecLine = firstLine.Direction3d();
|
||
|
||
double dLen = fabs(TDbSymbIndexPointer::GetDefaultCutLineLen()*m_pDrawEnt->GetPScale());
|
||
vecLine.Scale(dLen);
|
||
XLine cutLine(nearPoint, nearPoint + vecLine);
|
||
XPoint endNearPoint = geFirstLine.closestPointTo(cutLine.EndPoint().AsAcGePoint3d());
|
||
if (endNearPoint != firstLine.StartPoint() && endNearPoint != firstLine.EndPoint())
|
||
{
|
||
if (m_cutCurrDrag == cutLine)
|
||
bRet = Adesk::kFalse;
|
||
else
|
||
{
|
||
m_cutCurrDrag = cutLine;
|
||
CArray<XLine, XLine&> arCuts;
|
||
arCuts.Append(m_arCutAdded);
|
||
arCuts.Add(m_cutCurrDrag);
|
||
m_pDrawEnt->SetCutLine(arCuts);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* TIndexPointerEdJig::entity() const
|
||
{
|
||
return ((m_nOperCode==kSourceExtent) ? (AcDbEntity *)&m_drawEnt : (AcDbEntity *)m_pDrawEnt);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TArrowEdJig::TArrowEdJig(TDbSymbArrow *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
m_bFirst = TRUE;
|
||
}
|
||
|
||
AcEdJig::DragStatus TArrowEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
XPoly2D poly;
|
||
m_pDrawEnt->GetPoly2D(poly);
|
||
if (poly.Length() > 1)
|
||
{
|
||
if (m_bFirst)
|
||
{
|
||
XPoint ptBase = *poly.Head();
|
||
return acquirePoint(pt, ptBase); // [3/7/2008 nsh]
|
||
}
|
||
else
|
||
{
|
||
XPoint ptBase = *poly[1];
|
||
return acquirePoint(pt, ptBase);
|
||
}
|
||
}
|
||
else
|
||
return acquirePoint(pt);
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TArrowEdJig::DoIt(int *keyIndex)
|
||
{
|
||
m_bFirst = TRUE;
|
||
XPoly2D poly2d;
|
||
m_pDrawEnt->GetPoly2D(poly2d);
|
||
if (m_nOperCode==kLinePoint || m_nOperCode==kArcPoint)
|
||
{
|
||
m_ptResult = *poly2d.Head();
|
||
}
|
||
else if (m_nOperCode == kArcMidPoint) // MidPoint
|
||
{
|
||
XCurveSegment cv;
|
||
poly2d.Nth(0, cv);
|
||
m_ptResult = cv.MidPoint();
|
||
}
|
||
|
||
int nRet = TSymbEdJig::DoIt(keyIndex);
|
||
return nRet;
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TArrowEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet = Adesk::kTrue;
|
||
XPoly2D poly2d;
|
||
m_pDrawEnt->GetPoly2D(poly2d);
|
||
if (m_nOperCode==kLinePoint || m_nOperCode==kArcPoint)
|
||
{
|
||
if (m_bFirst)
|
||
{
|
||
m_bFirst = FALSE;
|
||
poly2d.InsertNodeAt(0, m_ptResult);
|
||
}
|
||
else
|
||
*poly2d.Head() = m_ptResult;
|
||
}
|
||
else if (m_nOperCode == kArcMidPoint)
|
||
{
|
||
XDirectionCurve cv;
|
||
poly2d.Nth(0, cv);
|
||
XCurveSegment seg;
|
||
seg = XArc(cv.GetStartPoint(), m_ptResult, cv.GetEndPoint());
|
||
if (!!seg)
|
||
{
|
||
if (seg.GetStartPoint().Distance(cv.GetStartPoint())>_DIST_SNAP)
|
||
seg.SetBulge(-seg.GetBulge());
|
||
poly2d.SetBulge(0, seg.GetBulge());
|
||
}
|
||
}
|
||
else if (m_nOperCode == kArcRadius)
|
||
{
|
||
XPoint ptBase, ptPrev;
|
||
int nLen = poly2d.Length();
|
||
ptBase = *poly2d[0];
|
||
ptPrev = *poly2d[1];
|
||
double nChordLen = ptBase.Distance2d(ptPrev);
|
||
double nRadius = ptBase.Distance2d(m_ptResult);
|
||
if (nChordLen < 2.0*nRadius+1.0E-6)
|
||
{
|
||
double bulge = 2.0*asin(nChordLen/2.0/nRadius);
|
||
if (XLine(ptBase, ptPrev).OnWhichSide(m_ptResult) == OFFSET_LEFT)
|
||
bulge = -bulge;
|
||
poly2d.SetBulge(0, bulge);
|
||
}
|
||
}
|
||
m_pDrawEnt->SetPoly2D(poly2d);
|
||
m_pDrawEnt->SetTextLocation(m_pDrawEnt->GetDefaultTextLocation());
|
||
m_pDrawEnt->SetText2Location(m_pDrawEnt->GetDefaultText2Location()); // sg add 090107
|
||
// sg add 090119,JIG过程中支持预览箭头样式
|
||
m_pDrawEnt->SetArrowType((TDbSymbArrow::TArrowType)g_nSymbArrowStyle);
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* TArrowEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TCoordEdJig::TCoordEdJig(TDbSymbCoord *pElev)
|
||
{
|
||
m_pDrawEnt=pElev;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TCoordEdJig::DoIt()
|
||
{
|
||
// sg modify 120618,解决设置固定度角后,坐标文字位置不正确的问题
|
||
savePoint = m_saveFirstPt;
|
||
|
||
XPushVar<int> osmode(_T("OSMODE"), 0);//add by whl
|
||
return TSymbEdJig::DoIt();
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TCoordEdJig::update()
|
||
{
|
||
//if(m_ptResult.Distance2d(m_pDrawEnt->GetTurnPoint())<_DIST_SNAP*10)
|
||
// return Adesk::kFalse;
|
||
if(CCoordDlg::m_bFixAngle)
|
||
{
|
||
{
|
||
//add by lgy 20120606 固定的角度值应该应该在固定绘制之前设置
|
||
dAngle = CCoordDlg::m_strAngle;
|
||
|
||
XPoint temp = Ucs2Wcs(savePoint);
|
||
if (CCoordDlg::m_bFixAngle)
|
||
{
|
||
//这个点的坐标有问题
|
||
double x0,y0;
|
||
double xi,yi;
|
||
x0=savePoint.x;
|
||
y0=savePoint.y;
|
||
xi=Wcs2Ucs(m_ptResult).x;
|
||
yi=Wcs2Ucs(m_ptResult).y;
|
||
if(xi>=x0 && yi>=y0)
|
||
{
|
||
m_dFixAngle=::_tstof(dAngle);
|
||
}
|
||
else if(xi<x0 && yi>=y0)
|
||
{
|
||
m_dFixAngle=180-::_tstof(dAngle);
|
||
}
|
||
else if(xi<=x0 && yi<y0)
|
||
{
|
||
m_dFixAngle =180+::_tstof(dAngle);
|
||
}
|
||
else if(xi>x0 && yi<y0)
|
||
{
|
||
m_dFixAngle=360-::_tstof(dAngle);
|
||
}
|
||
}
|
||
|
||
BOOL bShift=IsKeyPressed(VK_SHIFT);
|
||
XVector3D vt=m_ptResult-m_pDrawEnt->GetLocation();
|
||
double nAngle=ads_angle(XPoint(), vt);
|
||
nAngle=CT_std_angle(nAngle-Ucs2Wcs(0.0));//add by whl
|
||
Adesk::UInt8 nQuadrant;
|
||
if(nAngle>=0.0 && nAngle<PI/2)
|
||
{
|
||
nQuadrant=0;
|
||
if(bShift)
|
||
nAngle=PI/4;
|
||
}
|
||
else if(nAngle>=PI/2 && nAngle<PI)
|
||
{
|
||
nQuadrant=1;
|
||
if(bShift)
|
||
nAngle=PI/2+PI/4;
|
||
}
|
||
else if(nAngle>=PI && nAngle<PI*1.5)
|
||
{
|
||
nQuadrant=2;
|
||
if(bShift)
|
||
nAngle=PI+PI/4;
|
||
}
|
||
else {
|
||
nQuadrant=3;
|
||
if(bShift)
|
||
nAngle=2*PI-PI/4;
|
||
}
|
||
|
||
XLine ln(m_pDrawEnt->GetLocation(), nAngle);
|
||
if(bShift)
|
||
{
|
||
XPoint(m_ptResult).Project(&ln, m_ptResult);
|
||
}
|
||
|
||
XPoint mm=Wcs2Ucs(m_ptResult);
|
||
double x5=Wcs2Ucs(m_ptResult.x);
|
||
double d1 = sqrt((Wcs2Ucs(m_ptResult).x - Wcs2Ucs(temp).x)
|
||
* (Wcs2Ucs(m_ptResult).x - Wcs2Ucs(temp).x)
|
||
+ (Wcs2Ucs(m_ptResult).y - Wcs2Ucs(temp).y)
|
||
* (Wcs2Ucs(m_ptResult).y - Wcs2Ucs(temp).y));
|
||
double d3 = atan2(Wcs2Ucs(m_ptResult).y - Wcs2Ucs(temp).y,
|
||
Wcs2Ucs(m_ptResult).x - Wcs2Ucs(temp).x);
|
||
double d2 = cos((m_dFixAngle / 180)* PI - d3);
|
||
double d = d1 * d2;
|
||
XPoint ptTemp;
|
||
ptTemp.y = Wcs2Ucs(temp).y + d * sin((m_dFixAngle / 180)* PI);
|
||
ptTemp.x = Wcs2Ucs(temp).x + d * cos((m_dFixAngle / 180)* PI);
|
||
m_pDrawEnt->SetQuadrant(nQuadrant);//设置象限
|
||
m_pDrawEnt->SetTurnPoint(Ucs2Wcs(ptTemp));
|
||
}
|
||
}
|
||
else if(!CCoordDlg::m_bFixAngle)
|
||
{
|
||
BOOL bShift=IsKeyPressed(VK_SHIFT);
|
||
XVector3D vt=m_ptResult-m_pDrawEnt->GetLocation();
|
||
double nAngle=ads_angle(XPoint(), vt);
|
||
|
||
nAngle=CT_std_angle(nAngle-Ucs2Wcs(0.0));//add by whl
|
||
|
||
Adesk::UInt8 nQuadrant;
|
||
if(nAngle>=0.0 && nAngle<PI/2)
|
||
{
|
||
nQuadrant=0;
|
||
if(bShift)
|
||
nAngle=PI/4;
|
||
}
|
||
else if(nAngle>=PI/2 && nAngle<PI)
|
||
{
|
||
nQuadrant=1;
|
||
if(bShift)
|
||
nAngle=PI/2+PI/4;
|
||
}
|
||
else if(nAngle>=PI && nAngle<PI*1.5)
|
||
{
|
||
nQuadrant=2;
|
||
if(bShift)
|
||
nAngle=PI+PI/4;
|
||
}
|
||
else {
|
||
nQuadrant=3;
|
||
if(bShift)
|
||
nAngle=2*PI-PI/4;
|
||
}
|
||
XLine ln(m_pDrawEnt->GetLocation(), nAngle);
|
||
if(bShift) {
|
||
XPoint(m_ptResult).Project(&ln, m_ptResult);
|
||
}
|
||
m_pDrawEnt->SetQuadrant(nQuadrant);//设置象限
|
||
//m_pDrawEnt->SetTurnPoint(Ucs2Wcs(m_ptResult));
|
||
m_pDrawEnt->SetTurnPoint(m_ptResult);
|
||
}
|
||
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* TCoordEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TDrawingNameJig::TDrawingNameJig(TDbDrawingName *pEnt)
|
||
: m_pDrawEnt(pEnt)
|
||
, m_pszPrompt(NULL)
|
||
, m_pszKeyword(NULL)
|
||
{
|
||
}
|
||
|
||
void TDrawingNameJig::SetPrompt(const TCHAR *pszPrompt)
|
||
{
|
||
m_pszPrompt = pszPrompt;
|
||
}
|
||
|
||
void TDrawingNameJig::SetKeyword(const TCHAR *pszKeyword)
|
||
{
|
||
m_pszKeyword = pszKeyword;
|
||
}
|
||
|
||
int TDrawingNameJig::start(int *keyIndex)
|
||
{
|
||
setDispPrompt( m_pszPrompt );
|
||
AcEdJig::DragStatus stat = drag();
|
||
|
||
if ( kNormal == stat )
|
||
append();
|
||
else
|
||
delete m_pDrawEnt;
|
||
|
||
int nRet;
|
||
if (stat == AcEdJig::kCancel)
|
||
nRet = RTCAN;
|
||
else if(stat == AcEdJig::kNull)
|
||
nRet = RTNONE;
|
||
else if (stat <= 0)
|
||
nRet = RTNORM;
|
||
else
|
||
{
|
||
if(keyIndex) *keyIndex = stat;
|
||
nRet = RTKWORD;
|
||
}
|
||
return nRet;
|
||
}
|
||
|
||
AcEdJig::DragStatus TDrawingNameJig::sampler()
|
||
{
|
||
setUserInputControls( ( UserInputControls )
|
||
( kNullResponseAccepted | kAccept3dCoordinates ));
|
||
|
||
if (m_pszKeyword)
|
||
setKeywordList(m_pszKeyword);
|
||
|
||
AcGePoint3d point;
|
||
DragStatus stat = acquirePoint(point);
|
||
if (stat == kNormal)
|
||
{
|
||
if (point == m_ptIns)
|
||
return AcEdJig::kNoChange;
|
||
else
|
||
m_ptIns = point;
|
||
}
|
||
return stat;
|
||
}
|
||
|
||
Adesk::Boolean TDrawingNameJig::update()
|
||
{
|
||
// m_pDrawEnt->SetLocation(m_ptIns); // sg modify 090112
|
||
m_pDrawEnt->SetMidLocation(m_ptIns);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity *TDrawingNameJig::entity() const
|
||
{
|
||
return m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TLeaderEdJig::TLeaderEdJig(TDbSymbMultiLeader *pElev)
|
||
{
|
||
m_nOperCode = TLeaderEdJig::kNone;
|
||
m_pDrawEnt = pElev;
|
||
}
|
||
|
||
XPoint TLeaderEdJig::GetDragPoint() const
|
||
{
|
||
XPoint ptDrag = m_ptResult;
|
||
if (m_nOperCode == TLeaderEdJig::kLeader)
|
||
ptDrag = m_pDrawEnt->GetLeaderPoint();
|
||
else if (m_nOperCode == TLeaderEdJig::kTextLine)
|
||
ptDrag = m_pDrawEnt->GetTextBasePoint();
|
||
return ptDrag;
|
||
}
|
||
|
||
XPoint TLeaderEdJig::GetBasePoint() const
|
||
{
|
||
XPoint ptDrag = m_ptResult;
|
||
if (m_nOperCode == TLeaderEdJig::kLeader)
|
||
{
|
||
XPointList pts;
|
||
m_pDrawEnt->GetLeaderVertexes(pts);
|
||
if (pts.Length())
|
||
ptDrag = *pts[0];
|
||
}
|
||
else
|
||
{
|
||
ptDrag = m_pDrawEnt->GetLeaderPoint();
|
||
}
|
||
return ptDrag;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TLeaderEdJig::DoIt(int *keyIndex)
|
||
{
|
||
//ces
|
||
sAngle;
|
||
m_ptResult = GetDragPoint();
|
||
XPushVar<int> osmode(_T("OSMODE"), 0); // add by whl
|
||
|
||
if (m_bFixAngle) // sg add 090330,如果固定角度,则自动关闭正交
|
||
{
|
||
XPushVar<int> orthomode(_T("ORTHOMODE"), 0);
|
||
return TSymbEdJig::DoIt(keyIndex);
|
||
}
|
||
return TSymbEdJig::DoIt(keyIndex);
|
||
}
|
||
void TLeaderEdJig::SetDlg(CLeaderDlg *pLeadDlg)
|
||
{
|
||
m_pDlg = pLeadDlg;
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus
|
||
TLeaderEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
DragStatus stat;
|
||
if (m_nOperCode == kTextLine)
|
||
stat = acquirePoint(pt);
|
||
else
|
||
// sg modify 090325,恢复了被NSH删除的代码,可能会带来闪烁问题,修改的目的是解决不支持正交的问题
|
||
stat = acquirePoint(pt, GetBasePoint().AsAcGePoint3d());
|
||
// [10/18/2007 nsh]
|
||
// stat = acquirePoint(pt);
|
||
return stat;
|
||
}
|
||
|
||
Adesk::Boolean TLeaderEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet = Adesk::kTrue;
|
||
if (m_nOperCode == TLeaderEdJig::kLeader)
|
||
{
|
||
// add by cwk on 060606
|
||
if (!m_bFixAngle)
|
||
{
|
||
XVector3D vtOffset = m_ptResult - GetBasePoint();
|
||
m_pDrawEnt->SetLeaderPoint(m_ptResult);
|
||
if (vtOffset.x < 0.0)
|
||
m_pDrawEnt->SetTextBaseLen(-fabs(m_pDrawEnt->GetTextBaseLen()));
|
||
else
|
||
m_pDrawEnt->SetTextBaseLen(fabs(m_pDrawEnt->GetTextBaseLen()));
|
||
}
|
||
else
|
||
{
|
||
//modify by lgy 20120206 固定角度角度出现问题
|
||
static double ss = sAngle;
|
||
sAngle = _tstof(m_pDlg->m_sFixAngle);
|
||
if (ss >= 0)
|
||
{
|
||
// 处理输入的角度值为大于零的数值
|
||
AcGePoint3d ap3;
|
||
ads_real x0,y0;
|
||
ads_real xi,yi;
|
||
XPoint xxxx=pptfirst;
|
||
x0=pptfirst.x;
|
||
y0=pptfirst.y;
|
||
xi=Wcs2Ucs(m_ptResult).x;
|
||
yi=Wcs2Ucs(m_ptResult).y;
|
||
if(xi>=x0 && yi>=y0)
|
||
{
|
||
m_dFixAngle=sAngle;
|
||
}
|
||
else if(xi<x0 && yi>=y0)
|
||
{
|
||
m_dFixAngle=180-sAngle;
|
||
}
|
||
else if(xi<=x0 && yi<y0)
|
||
{
|
||
m_dFixAngle =180+sAngle;
|
||
}
|
||
else if(xi>x0 && yi<y0)
|
||
{
|
||
m_dFixAngle=360-sAngle;
|
||
}
|
||
}
|
||
else if (ss<0)
|
||
{
|
||
//处理角度值为小于零的情况
|
||
AcGePoint3d ap3;
|
||
static double fabsAngle;
|
||
fabsAngle=fabs(sAngle);
|
||
double x0,y0;
|
||
double xi,yi;
|
||
x0=pptfirst.x;
|
||
y0=pptfirst.y;
|
||
xi=m_ptResult.x;
|
||
yi=m_ptResult.y;
|
||
|
||
if (xi>=x0 && yi>=y0) // 第一象限
|
||
{
|
||
m_dFixAngle=fabsAngle;
|
||
}
|
||
else if(xi<x0 && yi>=y0)
|
||
{
|
||
m_dFixAngle=180-fabsAngle;
|
||
}
|
||
else if(xi<=x0 && yi<y0)
|
||
{
|
||
m_dFixAngle =180+fabsAngle;
|
||
}
|
||
else if(xi>x0 && yi<y0)
|
||
{
|
||
m_dFixAngle=360-fabsAngle;
|
||
}
|
||
}
|
||
|
||
XPoint temp = GetBasePoint();
|
||
XPoint xxx=Wcs2Ucs(temp);
|
||
double d1 = sqrt((Wcs2Ucs(m_ptResult).x - Wcs2Ucs(temp).x)
|
||
* (Wcs2Ucs(m_ptResult).x - Wcs2Ucs(temp).x)
|
||
+ (Wcs2Ucs(m_ptResult).y - Wcs2Ucs(temp).y)
|
||
* (Wcs2Ucs(m_ptResult).y - Wcs2Ucs(temp).y));
|
||
double d3 = atan2(Wcs2Ucs(m_ptResult).y - Wcs2Ucs(temp).y,
|
||
Wcs2Ucs(m_ptResult).x - Wcs2Ucs(temp).x);
|
||
double d2 = cos((m_dFixAngle / 180)* PI - d3);
|
||
double d = d1 * d2;
|
||
|
||
XPoint ptTemp;
|
||
ptTemp.y = Wcs2Ucs(temp).y + d * sin((m_dFixAngle / 180)* PI);
|
||
ptTemp.x = Wcs2Ucs(temp).x + d * cos((m_dFixAngle / 180)* PI);
|
||
XVector3D vtOffset = ptTemp - Wcs2Ucs(temp);
|
||
m_pDrawEnt->SetLeaderPoint(Ucs2Wcs(ptTemp));
|
||
if (vtOffset.x<0.0)
|
||
m_pDrawEnt->SetTextBaseLen(-fabs(m_pDrawEnt->GetTextBaseLen()),FALSE);
|
||
else
|
||
m_pDrawEnt->SetTextBaseLen(fabs(m_pDrawEnt->GetTextBaseLen()),FALSE);
|
||
}
|
||
}
|
||
else if (m_nOperCode==TLeaderEdJig::kVertex)
|
||
{
|
||
}
|
||
else if (m_nOperCode==TLeaderEdJig::kTextLine)
|
||
{
|
||
XPoint ptLeader = m_pDrawEnt->GetLeaderPoint();
|
||
// mofidied by whl on 060208
|
||
// m_pDrawEnt->SetTextBaseLen(m_ptResult.x - ptLeader.x, FALSE);
|
||
m_pDrawEnt->SetTextBaseLen(Wcs2Ucs(m_ptResult).x - Wcs2Ucs(ptLeader).x, FALSE);
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* TLeaderEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TLeaderAddOtherPtJig::TLeaderAddOtherPtJig(CLeaderDlg *pDlg, XPoint ptStart, XPoint ptBase,double dLayoutRotation)
|
||
:m_pDlg(pDlg)
|
||
{
|
||
m_bLeaderParall = FALSE;
|
||
m_bUpdateDlg = TRUE;
|
||
m_ptLeader = ptBase.AsAcGePoint3d();
|
||
m_ptFirstVertexes = ptStart.AsAcGePoint3d();
|
||
m_line.setStartPoint(m_ptLeader);
|
||
m_nLayoutRotation = dLayoutRotation;
|
||
}
|
||
|
||
TLeaderAddOtherPtJig::TLeaderAddOtherPtJig(BOOL bAllPtsOnLine, XPoint ptStart, XPoint ptBase,double dLayoutRotation,BOOL b)
|
||
:m_bAllOnLine(bAllPtsOnLine)
|
||
{
|
||
m_bUpdateDlg = FALSE;
|
||
m_ptLeader = ptBase.AsAcGePoint3d();
|
||
m_ptFirstVertexes = ptStart.AsAcGePoint3d();
|
||
m_line.setStartPoint(m_ptLeader);
|
||
m_nLayoutRotation = dLayoutRotation;
|
||
m_bLeaderParall = b;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TLeaderAddOtherPtJig::DoIt(int *keyIndex)
|
||
{
|
||
// modify by xly on 100903 对象捕捉有效,不影响用户设置
|
||
// XPushVar<int> osmode(_T("OSMODE"), 0); // 临时将对象捕捉关掉
|
||
return TSymbEdJig::DoIt(keyIndex);
|
||
}
|
||
|
||
AcEdJig::DragStatus TLeaderAddOtherPtJig::GetPoint(XPoint &pt)
|
||
{
|
||
return acquirePoint(pt); // 自由拖拽,不受正交控制
|
||
}
|
||
|
||
Adesk::Boolean TLeaderAddOtherPtJig::update()
|
||
{
|
||
/* BOOL bOnLine;
|
||
if (m_bUpdateDlg) // 时时更新对话框
|
||
{
|
||
m_pDlg->UpdateData(TRUE);
|
||
bOnLine = m_pDlg->m_bAllPtsOnLine;
|
||
}
|
||
else // 一次性判断
|
||
{
|
||
bOnLine = m_bAllOnLine;
|
||
}
|
||
|
||
if (bOnLine) // 多点共线,将JIG时的鼠标位置点,投影到第一条引线上
|
||
{
|
||
AcGePoint3d ptRet = m_ptResult,
|
||
ptOnLine;
|
||
AcDbLine line(m_ptFirstVertexes, m_ptLeader); // 第一条引线
|
||
line.getClosestPointTo(ptRet, ptOnLine, Adesk::kTrue);
|
||
m_ptResult = ptOnLine;
|
||
}
|
||
m_line.setEndPoint(m_ptResult);
|
||
return Adesk::kTrue;
|
||
*/
|
||
int iStyle = 0;
|
||
if (m_bUpdateDlg)
|
||
{
|
||
m_pDlg->UpdateData();
|
||
iStyle = m_pDlg->GetLeaderStyle();
|
||
}
|
||
else
|
||
{
|
||
iStyle = m_bLeaderParall;
|
||
}
|
||
|
||
if (iStyle == 0) //多点共线
|
||
{
|
||
BOOL bOnLine;
|
||
if (m_bUpdateDlg) // 时时更新对话框
|
||
{
|
||
m_pDlg->UpdateData(TRUE);
|
||
bOnLine = m_pDlg->m_bAllPtsOnLine;
|
||
}
|
||
else // 一次性判断
|
||
{
|
||
bOnLine = m_bAllOnLine;
|
||
}
|
||
|
||
if (bOnLine) // 多点共线,将JIG时的鼠标位置点,投影到第一条引线上
|
||
{
|
||
AcGePoint3d ptRet = m_ptResult,
|
||
ptOnLine;
|
||
AcDbLine line(m_ptFirstVertexes, m_ptLeader); // 第一条引线
|
||
line.getClosestPointTo(ptRet, ptOnLine, Adesk::kTrue);
|
||
m_ptResult = ptOnLine;
|
||
}
|
||
}
|
||
else if (iStyle == 1) //引线平行
|
||
{
|
||
XPoint ptTemp;
|
||
ads_polar(TADSGePoint3d(m_ptLeader),m_nLayoutRotation, 100.0, ptTemp);
|
||
XLine textbaseline(TADSGePoint3d(m_ptLeader), ptTemp);
|
||
XLine line(m_ptResult,m_ptResult+(m_ptFirstVertexes - m_ptLeader));
|
||
ads_point ptads;
|
||
textbaseline.Intersection(&line,ptads);
|
||
m_line.setStartPoint(m_ptResult.AsAcGePoint3d());
|
||
m_line.setEndPoint(TADSGePoint3d(ptads).AsAcGePoint3d());
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
m_line.setEndPoint(m_ptResult);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* TLeaderAddOtherPtJig::entity() const
|
||
{
|
||
return (AcDbEntity *)&m_line;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TDrawingIndexEdJig::TDrawingIndexEdJig(TDbSymbDrawingIndex *pEnt,TCHAR *pszPormat,TCHAR *pszKeyWord):
|
||
m_pEnt(pEnt),
|
||
m_ptCur(0,0,0),
|
||
m_ptLast(0,0,0),
|
||
m_pszPormat(pszPormat),
|
||
m_pszKeyWord(pszKeyWord)
|
||
{
|
||
}
|
||
|
||
TDrawingIndexEdJig::~TDrawingIndexEdJig()
|
||
{
|
||
|
||
}
|
||
|
||
AcEdJig::DragStatus TDrawingIndexEdJig::doIt()
|
||
{
|
||
AcEdJig::DragStatus status =AcEdJig::kNull;
|
||
|
||
setDispPrompt(m_pszPormat);
|
||
|
||
try
|
||
{
|
||
status = drag();
|
||
}
|
||
catch(...)
|
||
{
|
||
status = AcEdJig::kCancel;
|
||
}
|
||
return status;
|
||
}
|
||
|
||
AcEdJig::DragStatus TDrawingIndexEdJig::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)(AcEdJig::kAccept3dCoordinates|
|
||
AcEdJig::kNullResponseAccepted));
|
||
|
||
AcEdJig::DragStatus status =AcEdJig::kCancel;
|
||
|
||
if (m_pszKeyWord)
|
||
{
|
||
setKeywordList(m_pszKeyWord);
|
||
}
|
||
|
||
status = acquirePoint(m_ptCur);
|
||
|
||
if (status == AcEdJig::kNormal)
|
||
{
|
||
if (m_ptCur.isEqualTo(m_ptLast))
|
||
{
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
}
|
||
m_ptLast = m_ptCur;
|
||
|
||
return status;
|
||
}
|
||
|
||
Adesk::Boolean TDrawingIndexEdJig::update()
|
||
{
|
||
m_pEnt->SetCenter(m_ptCur); //位置
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity *TDrawingIndexEdJig::entity() const
|
||
{
|
||
return (m_pEnt);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TElevEdJig::TElevEdJig(TDbSymbElevation *pElev)
|
||
{
|
||
m_nOperCode = TElevEdJig::kNone;
|
||
m_pDrawEnt = pElev;
|
||
}
|
||
|
||
XPoint TElevEdJig::GetDragPoint() const
|
||
{
|
||
XPoint ptDrag = m_ptResult;
|
||
XPoint ptArray[7];
|
||
m_pDrawEnt->GetVertexes(ptArray);
|
||
if (m_nOperCode == TElevEdJig::kDirection)
|
||
ptDrag = ptArray[2];
|
||
else if (m_nOperCode == TElevEdJig::kBaseLine)
|
||
ptDrag = ptArray[4];
|
||
else if (m_nOperCode==TElevEdJig::kLeader)
|
||
ptDrag = ptArray[6];
|
||
else if (m_nOperCode == TElevEdJig::kMove) // add by zkm
|
||
ptDrag = ptArray[0];
|
||
return ptDrag;
|
||
}
|
||
|
||
XPoint TElevEdJig::GetBasePoint() const
|
||
{
|
||
XPoint ptDrag = m_ptResult;
|
||
XPoint ptArray[7];
|
||
m_pDrawEnt->GetVertexes(ptArray);
|
||
if (m_nOperCode == TElevEdJig::kDirection)
|
||
// ptDrag = ptArray[2];
|
||
ptDrag = ptArray[0]; // sg modify 090209,根据林工提出的意见,仿照理正修改,方向JIG更明显
|
||
else if (m_nOperCode == TElevEdJig::kBaseLine)
|
||
ptDrag = ptArray[0];
|
||
else if (m_nOperCode == TElevEdJig::kMove) // add by zkm
|
||
{
|
||
ptDrag = m_ptBase;
|
||
if (g_bHightWrite)
|
||
ptDrag = ptArray[0];
|
||
}
|
||
return ptDrag;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TElevEdJig::DoIt(int *keyIndex)
|
||
{
|
||
m_ptResult = GetDragPoint();
|
||
return TSymbEdJig::DoIt(keyIndex);
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus TElevEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
return acquirePoint(pt, GetBasePoint().AsAcGePoint3d());
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TElevEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet = Adesk::kTrue;
|
||
AcGePoint3dArray gripPoints;
|
||
TDbSymbElevation *pElev = m_pDrawEnt;
|
||
VERIFY(pElev->getStretchPoints(gripPoints) == Acad::eOk);
|
||
if (m_nOperCode == TElevEdJig::kDirection)
|
||
{
|
||
// sg modify 090327,解决正交打开时,无法绘制文字在符号左下方的情况;
|
||
// AcGeVector3d vtOffset = m_ptResult.AsAcGePoint3d() - gripPoints[1];
|
||
AcGeVector3d vtOffset = m_ptResult.AsAcGePoint3d() - gripPoints[0];
|
||
AcDbIntArray indices;
|
||
indices.append(1);
|
||
if (vtOffset.length() > _DIST_SNAP*10)
|
||
{
|
||
// sg modify 090330,解决灵敏度丢失问题,首先将矢量单位化,再扩大
|
||
vtOffset.normalize();
|
||
double dScale = (2*DocGetEleTriangleSize() + 0.5) * DocGetPScale();
|
||
vtOffset *= dScale;
|
||
pElev->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
|
||
if (pElev->IsFilled() || pElev->IsHollowTriangle()) // sg add 090209,增加文字位置点设置
|
||
pElev->SetTextBaseLen(DocGetEleTriangleSize());
|
||
else if (pElev->IsDote())
|
||
pElev->SetTextBaseLen(DocGetEleDoteSize());
|
||
else
|
||
pElev->SetTextBaseLen(pElev->GetDefaultTextBaseLen());
|
||
pElev->SetTextPoint(pElev->GetDefaultTextLocation());
|
||
pElev->SetLowTextPt(pElev->GetDefaultTextLocation2()); // sg add 090223
|
||
}
|
||
else if (m_nOperCode == TElevEdJig::kBaseLine)
|
||
{
|
||
AcGeVector3d vtOffset = m_ptResult.AsAcGePoint3d() - gripPoints[3];
|
||
AcDbIntArray indices;
|
||
indices.append(3);
|
||
if (vtOffset.length() > _DIST_SNAP)
|
||
pElev->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
else if (m_nOperCode == TElevEdJig::kLeader)
|
||
{
|
||
int idx=pElev->HasBaseLine()? 4 : 3;
|
||
AcGeVector3d vtOffset = m_ptResult.AsAcGePoint3d() - gripPoints[idx];
|
||
AcDbIntArray indices;
|
||
indices.append(idx);
|
||
if (vtOffset.length() > _DIST_SNAP*10)
|
||
pElev->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
// add by zkm
|
||
else if (m_nOperCode == TElevEdJig::kMove)
|
||
{
|
||
XPoint pt = Wcs2Ucs(m_ptResult);
|
||
XPoint pt1 = Wcs2Ucs(gripPoints[0]);
|
||
XPoint vtOffset = pt - pt1;
|
||
// sg modify 120611,不能直接使用全局变量
|
||
//if (g_bOrder && !CElevDlg::g_pElevDlg->m_bOrderTou)
|
||
if (CElevDlg::g_pElevDlg->IsOrder() && !CElevDlg::g_pElevDlg->m_bOrderTou)
|
||
{
|
||
pt1.y = pt.y;
|
||
pt1.x = m_dPointX;
|
||
gripPoints[0] = Ucs2Wcs(pt1).AsAcGePoint3d();
|
||
}
|
||
else
|
||
gripPoints[0] = m_ptResult.AsAcGePoint3d();
|
||
|
||
pElev->SetLocation(gripPoints[0]);
|
||
acedGetAcadDwgView()->SetFocus();
|
||
CElevDlg::g_pElevDlg->UpdateGrid(m_fBaseElev+_AS_METER(pt.y-Wcs2Ucs(m_ptBase).y)); // [12/4/2007 nsh],解决M单位问题
|
||
CElevDlg::g_pElevDlg->UpdataEnt();
|
||
CElevDlg::g_pElevDlg->UpdateEntText();
|
||
pElev->SetTextPoint(pElev->GetDefaultTextLocation()); // sg add 090209,增加文字位置点设置
|
||
pElev->SetLowTextPt(pElev->GetDefaultTextLocation2()); // sg add 090223
|
||
}
|
||
else
|
||
{
|
||
bRet = Adesk::kFalse;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* TElevEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TNorthThumbEdJig::TNorthThumbEdJig(TDbSymbNorthThumb *pElev)
|
||
{
|
||
m_pDrawEnt=pElev;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TNorthThumbEdJig::DoIt(int *keyIndex)
|
||
{
|
||
m_ptResult=m_nOperCode==kCenter?
|
||
m_pDrawEnt->GetCenter() : m_pDrawEnt->GetNorthPoint();
|
||
|
||
int nRet=TSymbEdJig::DoIt(keyIndex);
|
||
return nRet;
|
||
}
|
||
|
||
BOOL TNorthThumbEdJig::IsPosChanged(XPoint ptNew) const
|
||
{
|
||
BOOL bRet;
|
||
if(m_nOperCode==kCenter)
|
||
bRet=TSymbEdJig::IsPosChanged(ptNew);
|
||
else {
|
||
double nAngOld=ads_angle(m_pDrawEnt->GetCenter(), m_ptResult);
|
||
double nAngNew=ads_angle(m_pDrawEnt->GetCenter(), ptNew);
|
||
double nAng1=CT_std_angle(nAngOld-nAngNew);
|
||
double nAng2=CT_std_angle(nAngNew-nAngOld);
|
||
if(nAng1<_angSnap || nAng2<_angSnap)
|
||
bRet=FALSE;
|
||
else bRet=TRUE;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus TNorthThumbEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
AcEdJig::DragStatus stat;
|
||
if(m_nOperCode==kCenter)
|
||
stat=acquirePoint(pt);
|
||
else {
|
||
double nAng=PI/2.0;
|
||
stat=acquireAngle(nAng, m_pDrawEnt->GetCenter().AsAcGePoint3d());
|
||
if(stat==AcEdJig::kNull) {
|
||
nAng=PI/2.0;
|
||
stat=AcEdJig::kNormal;
|
||
}
|
||
if(stat==AcEdJig::kNormal)
|
||
ads_polar(m_pDrawEnt->GetCenter(), nAng, m_pDrawEnt->GetRadius(), pt);
|
||
}
|
||
|
||
return stat;
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TNorthThumbEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet=Adesk::kTrue;
|
||
if(m_nOperCode==kCenter)
|
||
m_pDrawEnt->SetCenter(m_ptResult);
|
||
else
|
||
m_pDrawEnt->SetRotation(ads_angle(m_pDrawEnt->GetCenter(), m_ptResult));
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* TNorthThumbEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TSymmetryEdJig::TSymmetryEdJig(TDbSymbSymmetry *pElev)
|
||
{
|
||
m_pDrawEnt=pElev;
|
||
m_ptResult=m_pDrawEnt->GetEndPoint();
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus TSymmetryEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
return acquirePoint(pt, m_pDrawEnt->GetStartPoint().AsAcGePoint3d());
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TSymmetryEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet=Adesk::kTrue;
|
||
m_pDrawEnt->SetEndPoint(m_ptResult);
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* TSymmetryEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TSectionEdJig::TSectionEdJig(TDbSymbSection *pElev)
|
||
{
|
||
m_pDrawEnt=pElev;
|
||
m_iFlag2=0;
|
||
//add by lgy 20120320 控制莫种jig剖面符号方式显示
|
||
m_nMode = 1;
|
||
m_pDlg = NULL;
|
||
}
|
||
|
||
//add by lgy 20120322 为jig添加对话框,为了jig时能实时与对话框交互
|
||
void TSectionEdJig::SetJigDlg(CSectionDlg *pDlg)
|
||
{
|
||
m_pDlg = pDlg;
|
||
}
|
||
int TSectionEdJig::GetiFlag2()
|
||
{
|
||
return m_iFlag2;
|
||
}
|
||
|
||
void TSectionEdJig::SetJigMode(int nMode)
|
||
{
|
||
m_nMode = nMode;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TSectionEdJig::DoIt(int *keyIndex)
|
||
{
|
||
XPushVar<int> osmode(_T("OSMODE"), 0);//add by whl
|
||
|
||
if(m_nOperCode==kSectPointOther)
|
||
{
|
||
m_iFlag2=1-m_iFlag2;
|
||
CopyObject(*m_pDrawEnt, m_drawEnt);
|
||
XPoly2D poly;
|
||
m_drawEnt.GetPoly2D(poly);
|
||
ASSERT(poly.Length()>=2);
|
||
m_ptResult=*poly.Tail();
|
||
//modify by lgy 20120320 如果为非正交转折剖切
|
||
//if(m_iFlag2==1)
|
||
m_nMode = m_pDlg->GetSectionMode();
|
||
if(m_iFlag2==1&&m_nMode!=3)
|
||
{
|
||
poly.AppendNode(m_ptResult);
|
||
poly.AppendNode(m_ptResult);
|
||
}
|
||
else if (m_nMode == 3) //非正交转折剖切
|
||
{
|
||
poly.AppendNode(m_ptResult);
|
||
}
|
||
m_drawEnt.SetPoly2D(poly);
|
||
}
|
||
else if(m_nOperCode==kSectPoint || m_nOperCode==kViewDirection)
|
||
{
|
||
XPoly2D poly;
|
||
m_pDrawEnt->GetPoly2D(poly);
|
||
ASSERT(poly.Length()>=2);
|
||
m_ptResult=*poly.Tail();
|
||
}
|
||
|
||
//modify by lgy 20120530 非正交剖切支持对象捕捉
|
||
//int nRet = TSymbEdJig::DoIt(keyIndex);
|
||
int nRet = 0;
|
||
if (m_nMode != 3)
|
||
{
|
||
nRet = TSymbEdJig::DoIt(keyIndex);
|
||
}
|
||
else //绘制模式为非正交转正剖切,需要恢复对象捕捉
|
||
{
|
||
XPushVar<int> osmode(_T("OSMODE"), 16383);
|
||
nRet = TSymbEdJig::DoIt(keyIndex);
|
||
}
|
||
if(m_nOperCode==kSectPointOther)
|
||
{
|
||
if(nRet==RTNORM||(nRet==RTNONE&&m_iFlag2==0))
|
||
CopyObject(m_drawEnt, *m_pDrawEnt);
|
||
}
|
||
return nRet;
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus TSectionEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
DragStatus stat;
|
||
XPoint ptBase;
|
||
XPoly2D poly;
|
||
m_pDrawEnt->GetPoly2D(poly);
|
||
if(m_nOperCode==kSectPoint)
|
||
{
|
||
ASSERT(poly.Length()==2);
|
||
ptBase=*poly.Head();
|
||
}
|
||
else if(m_nOperCode==kSectPointOther ||
|
||
m_nOperCode==kViewDirection)
|
||
{
|
||
ASSERT(poly.Length()>=2);
|
||
if(m_iFlag2==1)
|
||
ptBase=*poly.Tail();
|
||
else
|
||
ptBase=*poly[poly.Length()-2];
|
||
}
|
||
else
|
||
{
|
||
ASSERT(0);
|
||
}
|
||
|
||
//add by lgy 20120525 如果是非正交剖切,jig时橡皮线需要修改
|
||
if (m_nMode == 3)
|
||
{
|
||
if(m_nOperCode==kSectPoint)
|
||
{
|
||
ASSERT(poly.Length()==2);
|
||
ptBase=*poly.Head();
|
||
}
|
||
else
|
||
{
|
||
ptBase = *poly.Tail();
|
||
}
|
||
}
|
||
stat=acquirePoint(pt, ptBase);
|
||
return stat;
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TSectionEdJig::update()
|
||
{
|
||
//add by lgy 20120426 确保对话框中内容能与实体实时交互
|
||
double dHeight = m_pDlg->GetNumHeight();
|
||
m_pDrawEnt->SetTextHeight(dHeight);
|
||
m_pDrawEnt->SetText(m_pDlg->GetSectionNum());
|
||
AcDbObjectId idScaleStyle = InitTextStyle(m_pDlg->GetNumStyle());
|
||
m_pDrawEnt->SetTextStyleId(idScaleStyle);
|
||
|
||
if (m_pDlg->GetIsShowDrawText())
|
||
{
|
||
if (m_pDlg->GetLocal() == 0) //两端显示
|
||
{
|
||
m_pDrawEnt->SetIsHasIndexS(TRUE);
|
||
m_pDrawEnt->SetIsHasIndexE(TRUE);
|
||
}
|
||
else if (m_pDlg->GetLocal() == 1)//始端显示
|
||
{
|
||
m_pDrawEnt->SetIsHasIndexS(TRUE);
|
||
m_pDrawEnt->SetIsHasIndexE(FALSE);
|
||
}
|
||
else if (m_pDlg->GetLocal() == 2)//末端显示
|
||
{
|
||
m_pDrawEnt->SetIsHasIndexS(FALSE);
|
||
m_pDrawEnt->SetIsHasIndexE(TRUE);
|
||
}
|
||
|
||
if (!m_pDlg->GetDirect())
|
||
{
|
||
m_pDrawEnt->SetDimDirection(0); //剖切方向
|
||
}
|
||
else
|
||
{
|
||
m_pDrawEnt->SetDimDirection(1); //剖视方向
|
||
}
|
||
|
||
m_pDrawEnt->SetDrawingIndex(m_pDlg->GetDrawNum());
|
||
m_pDrawEnt->SetIndexHeight(m_pDlg->GetDrawHeight());
|
||
m_pDrawEnt->SetIndexStyleId(InitTextStyle(m_pDlg->GetDrawingStyle()));
|
||
}
|
||
else //不显示文字时,默认仍要有文字样式
|
||
{
|
||
m_pDrawEnt->SetDrawingIndex(_T("1")); //如果不显示文字,为标注设置默认位置为1
|
||
m_pDrawEnt->SetIndexStyleId(InitTextStyle(TS_INDEXSCALE));
|
||
m_pDrawEnt->SetIndexHeight(3.5);
|
||
}
|
||
|
||
Adesk::Boolean bRet=Adesk::kTrue;
|
||
if(m_nOperCode==kSectPoint)
|
||
{
|
||
XPoly2D poly;
|
||
m_pDrawEnt->GetPoly2D(poly);
|
||
ASSERT(poly.Length()==2);
|
||
XPoint pt1=*poly[0];
|
||
*poly[1]=m_ptResult;
|
||
double nViewDir=ads_angle(pt1, m_ptResult)-PI/2.0;
|
||
m_pDrawEnt->SetPoly2D(poly);
|
||
m_pDrawEnt->SetViewDirection(nViewDir);
|
||
//add by lgy 20120525 如果是非正交转正剖切,需要设置末尾点的剖视线的角度
|
||
if(m_nMode == 3)
|
||
{
|
||
m_pDrawEnt->SetNonPerpendicularitySection(TRUE);
|
||
m_pDrawEnt->SetViewDirection2(nViewDir);
|
||
}
|
||
|
||
m_pDrawEnt->SetTextLocation(0, m_pDrawEnt->GetDefaultTextLocation(0));
|
||
m_pDrawEnt->SetTextLocation(1, m_pDrawEnt->GetDefaultTextLocation(1));
|
||
//add by lgy 20120319 9.0中添加剖面符号文字,需要设置其显示的位置点
|
||
m_pDrawEnt->SetIndexLocation(0, m_pDrawEnt->GetDefaultIndexLocation(0));
|
||
m_pDrawEnt->SetIndexLocation(1, m_pDrawEnt->GetDefaultIndexLocation(1));
|
||
}
|
||
else if(m_nOperCode==kSectPointOther)
|
||
{
|
||
XPoly2D poly;
|
||
m_drawEnt.GetPoly2D(poly);
|
||
int nLen=poly.Length();
|
||
ASSERT(nLen>=3);
|
||
if(m_iFlag2==0)
|
||
{
|
||
//add by lgy 20120320 添加以下if判断,是为了解决非正交转折剖面的问题
|
||
if (m_nMode != 3) //不是非正交转折
|
||
{
|
||
XPoint pt1=*poly[nLen-3];
|
||
XPoint pt2=*poly[nLen-2];
|
||
XLine ln(m_ptResult, ads_angle(pt1, pt2));
|
||
XPoint pt3;
|
||
pt2.Project(&ln, pt3);
|
||
*poly[nLen-1]=pt3;
|
||
}
|
||
else
|
||
{
|
||
*poly[nLen-1]=m_ptResult;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//add by lgy 20120320 添加以下if判断,是为了解决非正交转折剖面的问题
|
||
if (m_nMode != 3) //不是非正交转折
|
||
{
|
||
XPoint pt1=*poly[nLen-4];
|
||
XPoint pt2=*poly[nLen-3];
|
||
XLine ln(m_ptResult, ads_angle(pt1, pt2));
|
||
XPoint pt3;
|
||
pt2.Project(&ln, pt3);
|
||
*poly[nLen-2]=pt3;
|
||
*poly[nLen-1]=m_ptResult;
|
||
}
|
||
else
|
||
{
|
||
*poly[nLen-1]=m_ptResult;
|
||
}
|
||
}
|
||
|
||
SetPrompt(_T("\n点取下一个剖切点<结束>:"));
|
||
m_drawEnt.SetPoly2D(poly);
|
||
nLen=poly.Length();
|
||
ASSERT(nLen>=2);
|
||
if(m_iFlag2==1)
|
||
{
|
||
//modify by lgy 20120525 考虑非正交转正剖切时剖视线的方向
|
||
//XLine ln1(*poly[nLen-4], *poly[nLen-3]);
|
||
//int nSide=ln1.OnWhichSide(m_ptResult);
|
||
//if(nSide==OFFSET_LEFT)
|
||
// m_drawEnt.SetViewDirection(CT_std_angle(ln1.Direction()+PI/2));
|
||
//else
|
||
// m_drawEnt.SetViewDirection(CT_std_angle(ln1.Direction()-PI/2));
|
||
if (m_nMode != 3)
|
||
{
|
||
XLine ln1(*poly[nLen-4], *poly[nLen-3]);
|
||
int nSide=ln1.OnWhichSide(m_ptResult);
|
||
if(nSide==OFFSET_LEFT)
|
||
{
|
||
m_drawEnt.SetViewDirection(CT_std_angle(ln1.Direction()+PI/2));
|
||
}
|
||
else
|
||
{
|
||
m_drawEnt.SetViewDirection(CT_std_angle(ln1.Direction()-PI/2));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_drawEnt.SetNonPerpendicularitySection(TRUE);
|
||
|
||
XLine ln2(*poly[nLen-2], *poly[nLen-1]);
|
||
XLine ln3(*poly[0], *poly[1]);
|
||
int nSide=ln3.OnWhichSide(m_ptResult);
|
||
|
||
if (nSide == OFFSET_LEFT)
|
||
{
|
||
m_drawEnt.SetViewDirection(CT_std_angle(ln3.Direction()+PI/2));
|
||
m_drawEnt.SetViewDirection2(CT_std_angle(ln2.Direction()+PI/2));
|
||
}
|
||
else
|
||
{
|
||
m_drawEnt.SetViewDirection(CT_std_angle(ln3.Direction()-PI/2));
|
||
m_drawEnt.SetViewDirection2(CT_std_angle(ln2.Direction()-PI/2));
|
||
}
|
||
}
|
||
|
||
|
||
m_drawEnt.SetTextLocation(0, m_drawEnt.GetDefaultTextLocation(0));
|
||
m_drawEnt.SetTextLocation(1, m_drawEnt.GetDefaultTextLocation(1));
|
||
//add by lgy 20120319 9.0中添加剖面符号文字,需要设置其显示的位置点
|
||
m_drawEnt.SetIndexLocation(0, m_drawEnt.GetDefaultIndexLocation(0));
|
||
m_drawEnt.SetIndexLocation(1, m_drawEnt.GetDefaultIndexLocation(1));
|
||
}
|
||
else
|
||
{
|
||
//modify by lgy 20120525 考虑非转正剖切时剖视角度
|
||
//if(nSide==OFFSET_LEFT)
|
||
// m_drawEnt.SetViewDirection(CT_std_angle(ln1.Direction()+PI/2));
|
||
//else
|
||
// m_drawEnt.SetViewDirection(CT_std_angle(ln1.Direction()-PI/2));
|
||
if (m_nMode != 3)
|
||
{
|
||
XLine ln1(*poly[nLen-2], *poly[nLen-1]);
|
||
int nSide=ln1.OnWhichSide(m_ptResult);
|
||
if(nSide==OFFSET_LEFT)
|
||
{
|
||
m_drawEnt.SetViewDirection(CT_std_angle(ln1.Direction()+PI/2));
|
||
}
|
||
else
|
||
{
|
||
m_drawEnt.SetViewDirection(CT_std_angle(ln1.Direction()-PI/2));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_drawEnt.SetNonPerpendicularitySection(TRUE);
|
||
XLine ln2(*poly[nLen-2], *poly[nLen-1]);
|
||
XLine ln3(*poly[0], *poly[1]);
|
||
int nSide=ln3.OnWhichSide(m_ptResult);
|
||
if (nSide == OFFSET_LEFT)
|
||
{
|
||
m_drawEnt.SetViewDirection(CT_std_angle(ln3.Direction()+PI/2));
|
||
m_drawEnt.SetViewDirection2(CT_std_angle(ln2.Direction()+PI/2));
|
||
}
|
||
else
|
||
{
|
||
m_drawEnt.SetViewDirection(CT_std_angle(ln3.Direction()-PI/2));
|
||
m_drawEnt.SetViewDirection2(CT_std_angle(ln2.Direction()-PI/2));
|
||
}
|
||
}
|
||
|
||
|
||
m_drawEnt.SetTextLocation(1, m_drawEnt.GetDefaultTextLocation(1));
|
||
//add by lgy 20120319 9.0中添加剖面符号文字,需要设置其显示的位置点
|
||
m_drawEnt.SetIndexLocation(0, m_drawEnt.GetDefaultIndexLocation(0));
|
||
m_drawEnt.SetIndexLocation(1, m_drawEnt.GetDefaultIndexLocation(1));
|
||
}
|
||
|
||
}
|
||
else if(m_nOperCode==kViewDirection)
|
||
{
|
||
XPoly2D poly;
|
||
m_pDrawEnt->GetPoly2D(poly);
|
||
int nLen=poly.Length();
|
||
//modify by lgy 20120525 考虑非正交转正剖切
|
||
// ASSERT(nLen>=2);
|
||
// XLine ln(*poly[nLen-2], *poly[nLen-1]);
|
||
// int nSide=ln.OnWhichSide(m_ptResult);
|
||
// if(nSide==OFFSET_LEFT)
|
||
// m_pDrawEnt->SetViewDirection(CT_std_angle(ln.Direction()+PI/2));
|
||
// else
|
||
// m_pDrawEnt->SetViewDirection(CT_std_angle(ln.Direction()-PI/2));
|
||
if (m_nMode != 3)
|
||
{
|
||
if (nLen < 2)
|
||
{
|
||
return Adesk::kFalse;
|
||
}
|
||
XLine ln(*poly[nLen-2], *poly[nLen-1]);
|
||
int nSide=ln.OnWhichSide(m_ptResult);
|
||
if(nSide==OFFSET_LEFT)
|
||
{
|
||
m_pDrawEnt->SetViewDirection(CT_std_angle(ln.Direction()+PI/2));
|
||
}
|
||
else
|
||
{
|
||
m_pDrawEnt->SetViewDirection(CT_std_angle(ln.Direction()-PI/2));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (nLen < 2)
|
||
{
|
||
return Adesk::kFalse;
|
||
}
|
||
m_pDrawEnt->SetNonPerpendicularitySection(TRUE);
|
||
|
||
XLine ln(*poly[nLen-2], *poly[nLen-1]);
|
||
XLine ln1(*poly[0], *poly[1]);
|
||
int nSide=ln.OnWhichSide(m_ptResult);
|
||
if(nSide==OFFSET_LEFT)
|
||
{
|
||
m_pDrawEnt->SetViewDirection(CT_std_angle(ln1.Direction()+PI/2));
|
||
m_pDrawEnt->SetViewDirection2(CT_std_angle(ln.Direction()+PI/2));
|
||
}
|
||
else
|
||
{
|
||
m_pDrawEnt->SetViewDirection(CT_std_angle(ln1.Direction()-PI/2));
|
||
m_pDrawEnt->SetViewDirection2(CT_std_angle(ln.Direction()-PI/2));
|
||
}
|
||
}
|
||
|
||
|
||
|
||
m_pDrawEnt->SetTextLocation(0, m_pDrawEnt->GetDefaultTextLocation(0));
|
||
m_pDrawEnt->SetTextLocation(1, m_pDrawEnt->GetDefaultTextLocation(1));
|
||
//add by lgy 20120319 9.0中添加剖面符号文字,需要设置其显示的位置点
|
||
m_pDrawEnt->SetIndexLocation(0, m_pDrawEnt->GetDefaultIndexLocation(0));
|
||
m_pDrawEnt->SetIndexLocation(1, m_pDrawEnt->GetDefaultIndexLocation(1));
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* TSectionEdJig::entity() const
|
||
{
|
||
|
||
return ((m_nOperCode==kSectPointOther)? (AcDbEntity *)&m_drawEnt : (AcDbEntity *)m_pDrawEnt);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
TCloudLineJig::TCloudLineJig(TDbSymbModi *pModi, XPoint ptFirst, double dMax, double dMin)
|
||
{
|
||
m_dMax = dMax;
|
||
m_dMin = dMin;
|
||
m_ptFirst = ptFirst;
|
||
|
||
m_pline.Reset();
|
||
m_pline.AppendNode(m_ptFirst);
|
||
|
||
m_pModi = pModi;
|
||
m_pModi->SetModiPoly(m_pline);
|
||
}
|
||
|
||
TCloudLineJig::~TCloudLineJig()
|
||
{
|
||
}
|
||
|
||
int TCloudLineJig::DoIt(int *keyIndex)
|
||
{
|
||
int nLength = m_pline.Length();
|
||
if (nLength > 1)
|
||
m_ptResult = *m_pline[nLength-1];
|
||
else
|
||
m_ptResult = m_ptFirst;
|
||
|
||
int nRet = TSymbEdJig::DoIt(keyIndex);
|
||
|
||
{
|
||
XPoint ptLast;
|
||
int nLength = m_pline.Length();
|
||
if (nLength > 1)
|
||
ptLast = *m_pline[nLength-1];
|
||
else
|
||
ptLast = m_ptFirst;
|
||
|
||
double dLengh(0.0);
|
||
XCurveSegment segTemp(ptLast, m_ptFirst, 0);
|
||
while (dLengh < segTemp.GetLength() - _DIST_SNAP)
|
||
{
|
||
TADSGePointDir2d ptMid;
|
||
segTemp.Polar(dLengh, ptMid);
|
||
m_pline.AppendNode(ptMid.AsAcGePoint3d());
|
||
|
||
double dTotalLen = (rand()%10)/10.000;
|
||
dTotalLen = dTotalLen*m_dMax;
|
||
if (dTotalLen < m_dMin)
|
||
{
|
||
dTotalLen += m_dMin;
|
||
}
|
||
|
||
dLengh = dLengh + dTotalLen;
|
||
}
|
||
}
|
||
|
||
m_pline.SetClosed();
|
||
if (m_pline.PathArea() > 0)
|
||
m_pline.Reverse();
|
||
m_pModi->SetModiPoly(m_pline);
|
||
return nRet;
|
||
}
|
||
|
||
AcEdJig::DragStatus TCloudLineJig::GetPoint(XPoint &pt)
|
||
{
|
||
XPoint ptBase;
|
||
int nLength = m_pline.Length();
|
||
if (nLength > 1)
|
||
ptBase = *m_pline[nLength-1];
|
||
else
|
||
ptBase = m_ptFirst;
|
||
|
||
AcEdJig::DragStatus status;
|
||
status = acquirePoint(pt, ptBase);
|
||
|
||
double dDistance = pt.Distance(ptBase);
|
||
if (dDistance>m_dMin-_DIST_SNAP && dDistance<m_dMax+_DIST_SNAP) // 直接1个弧就可以解决
|
||
{
|
||
m_pline.AppendNode(pt);
|
||
}
|
||
else if (dDistance > m_dMax+_DIST_SNAP) // 需要多个弧连接
|
||
{
|
||
XCurveSegment segTemp(ptBase, pt, 0);
|
||
|
||
double dLengh(0.0);
|
||
while (dLengh < dDistance + _DIST_SNAP)
|
||
{
|
||
TADSGePointDir2d ptMid;
|
||
segTemp.Polar(dLengh, ptMid);
|
||
m_pline.AppendNode(ptMid.AsAcGePoint3d());
|
||
|
||
double dTotalLen = (rand()%10)/10.000;
|
||
dTotalLen = dTotalLen*m_dMax;
|
||
if (dTotalLen < m_dMin)
|
||
{
|
||
dTotalLen += m_dMin;
|
||
}
|
||
dLengh = dLengh + dTotalLen;
|
||
}
|
||
}
|
||
return status;
|
||
}
|
||
|
||
Adesk::Boolean TCloudLineJig::update()
|
||
{
|
||
if (m_pline.PathArea() > 0)
|
||
m_pModi->SetArcAngle(-0.5);
|
||
else
|
||
m_pModi->SetArcAngle(0.5);
|
||
|
||
m_pModi->SetModiPoly(m_pline);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* TCloudLineJig::entity() const
|
||
{
|
||
return (AcDbEntity*)m_pModi;
|
||
}
|
||
|
||
|
||
|