3048 lines
72 KiB
C++
3048 lines
72 KiB
C++
#include "stdafx.h"
|
||
#include "AcDbObjectPtr.h"
|
||
#include "globalFunc.h"
|
||
#include "EntityEdJig.h"
|
||
#include "AecDbDimension.h"
|
||
#include "ADSGePointDir2d.h"
|
||
|
||
AcDbObjectId InitTextStyle(const TCHAR *pszStyle, AcDbDatabase *pDb = NULL);
|
||
AcDbObjectId InitTextStyle(TTextStyle ts, AcDbDatabase *pDb = NULL);
|
||
namespace
|
||
{
|
||
int CmpPointByX(const ADSGePoint3d *pt1, const ADSGePoint3d *pt2)
|
||
{
|
||
if (pt1->x < pt2->x)
|
||
return -1;
|
||
else
|
||
return 1;
|
||
}
|
||
|
||
int CmpPointByY(const ADSGePoint3d *pt1, const ADSGePoint3d *pt2)
|
||
{
|
||
if (pt1->y < pt2->y)
|
||
return -1;
|
||
else
|
||
return 1;
|
||
}
|
||
}
|
||
|
||
AcDbObjectId InitDimStyle(TDimStyle ds);
|
||
|
||
#pragma region DimensionEdJig
|
||
//add by lgy 20120315 设置弧长标记
|
||
void DimensionEdJig::SetIsArcDim()
|
||
{
|
||
m_bIsArcDim = true;
|
||
}
|
||
|
||
//add by whl on 03/08/08
|
||
void DimensionEdJig::FindAndRemoveSeg(ADSGePoint3d pt)
|
||
{
|
||
GeCurveSegment seg = m_pDrawEnt->GetDimCurve();
|
||
ADSGePoint3d ptOnSeg;
|
||
seg.ProjectToMe(pt, ptOnSeg);
|
||
double value = seg.StartPoint().Distance2d(ptOnSeg);
|
||
long i = -1;
|
||
if (value > g_Option::instance()._DIST_SNAP)
|
||
{
|
||
double curValue = 0;
|
||
for (i = 0; i < m_pDrawEnt->GetSegmentNum(); i++)
|
||
{
|
||
curValue += m_pDrawEnt->GetSegment(i);
|
||
if (fabs(curValue - value) < g_Option::instance()._DIST_SNAP)
|
||
break;
|
||
}
|
||
}
|
||
if (i >= m_pDrawEnt->GetSegmentNum())
|
||
return;//useful
|
||
|
||
if (i >= 0)
|
||
{
|
||
double temp = m_pDrawEnt->GetSegment(i);
|
||
if (i < (m_pDrawEnt->GetSegmentNum() - 1))//是中间段
|
||
m_pDrawEnt->SetSegment(i + 1, temp + m_pDrawEnt->GetSegment(i + 1));//后一段合并之
|
||
m_pDrawEnt->RemoveSegment(i);
|
||
}
|
||
else//第一个标注段的起点(不一定是DimContinue中提示的第一点)特殊处理
|
||
{
|
||
double temp = m_pDrawEnt->GetSegment(0);
|
||
m_pDrawEnt->RemoveSegment(0);
|
||
Vector3D vt = seg.EndPoint() - seg.StartPoint();
|
||
vt.Scale(temp / vt.Length());
|
||
m_pDrawEnt->SetLocation(m_pDrawEnt->GetLocation() + vt);
|
||
}
|
||
}
|
||
void DimensionEdJig::Step()
|
||
{
|
||
ptStack.Push(m_ptDim);
|
||
}
|
||
bool DimensionEdJig::CanUndo()
|
||
{
|
||
return ptStack.GetDepth() > 1;
|
||
}
|
||
void DimensionEdJig::Undo()
|
||
{
|
||
ADSGePoint3d pt;
|
||
ptStack.GetTopData(pt);
|
||
ptStack.GoBack();
|
||
if (CanUndo())
|
||
m_pDrawEnt->FindAndRemoveSegment(pt);
|
||
}
|
||
ADSGePoint3d DimensionEdJig::GetLastPoint()
|
||
{
|
||
ADSGePoint3d pt;
|
||
ptStack.GetTopData(pt);
|
||
return pt;
|
||
}
|
||
//end
|
||
|
||
void DimensionEdJig::Swap()
|
||
{
|
||
if (m_pTemp) {
|
||
AcDbDeepCloneFiler filer;
|
||
if (m_pTemp->dwgOut(&filer) == Acad::eOk) {
|
||
filer.seek(0L, 0);
|
||
VERIFY(m_pDrawEnt->dwgIn(&filer) == Acad::eOk);
|
||
}
|
||
ASSERT(m_pTemp && m_pTemp->IsValid());
|
||
}
|
||
else {
|
||
m_pTemp = (AecDbDimension *)m_pDrawEnt->clone();
|
||
ASSERT(m_pTemp && m_pTemp->IsValid());
|
||
}
|
||
}
|
||
|
||
// 转换成ADS代码
|
||
int DimensionEdJig::GetRetCode(int *kwordId) const
|
||
{
|
||
int ret = m_nRetCode;
|
||
if (ret == AcEdJig::kCancel)
|
||
ret = RTCAN;
|
||
else if (ret == AcEdJig::kNull)
|
||
ret = RTNONE;
|
||
else if (ret <= 0)
|
||
ret = RTNORM;
|
||
else {
|
||
if (kwordId) *kwordId = ret;
|
||
ret = RTKWORD;
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
|
||
DimensionEdJig::DimensionEdJig(AecDbDimension *pDim, const TCHAR *pszPrompt, const TCHAR *pszKeyword)
|
||
:m_pDrawEnt(pDim), m_pszPrompt(pszPrompt), m_pszKeyword(pszKeyword), m_nRetCode(0), m_cMonitor(curDoc())
|
||
{
|
||
m_pTemp = NULL;
|
||
m_nFlag = 0;
|
||
m_ptDim = pDim->GetLocation();
|
||
//add by lgy 20120315 弧长标注标记
|
||
m_bIsArcDim = false; //false为不是弧长标注
|
||
|
||
m_bInView = FALSE; //add by lgy 20120503 保存标注是否是在视口中绘制
|
||
m_nPortNum = 0; //add by lgy 20120509 默认视口为0
|
||
m_bSaveStyle = FALSE;//add by lgy 20120519 默认不保存标注样式
|
||
m_bKeyword = FALSE;
|
||
}
|
||
|
||
|
||
DimensionEdJig::~DimensionEdJig()
|
||
{
|
||
if (m_pTemp)
|
||
delete m_pTemp;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int DimensionEdJig::doIt()
|
||
{
|
||
setDispPrompt(m_pszPrompt);
|
||
try
|
||
{
|
||
if (m_nFlag == 1)
|
||
{
|
||
if (m_pDrawEnt->IsDimChord() && m_pDrawEnt->IsAngular())
|
||
{//玄长jig
|
||
|
||
GeCurveSegment seg = m_pDrawEnt->GetDimCurve();
|
||
ADSGePoint3d pt1, pt2, ptc;
|
||
ptc = seg.MidPoint();
|
||
pt1 = seg.GetStartPoint();
|
||
pt2 = seg.GetEndPoint();
|
||
|
||
while (m_pDrawEnt->GetSegmentNum() > 0)
|
||
m_pDrawEnt->RemoveSegment(0);
|
||
|
||
m_pDrawEnt->SetObjRadius(0);
|
||
m_pDrawEnt->SetDimRadius(0);
|
||
|
||
m_pDrawEnt->SetAngular(FALSE);
|
||
m_pDrawEnt->SetDimChord(FALSE);
|
||
|
||
m_pDrawEnt->AppendSegment(pt1.Distance2d(pt2));
|
||
m_pDrawEnt->AddSegment(pt1);
|
||
|
||
m_pDrawEnt->SetLocation(pt1);
|
||
m_pDrawEnt->SetFixLinePos(pt1);
|
||
GeCurveSegment seg1(pt1, pt2, 0);
|
||
double nDirection = seg1.Direction(ptc);
|
||
m_pDrawEnt->SetRotation(nDirection);
|
||
}
|
||
}
|
||
m_nRetCode = drag();
|
||
}
|
||
catch (...)
|
||
{
|
||
m_nRetCode = AcEdJig::kCancel;
|
||
}
|
||
return GetRetCode();
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus DimensionEdJig::sampler()
|
||
{
|
||
DragStatus stat;
|
||
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
|
||
if (m_pszKeyword) setKeywordList(m_pszKeyword);
|
||
ADSGePoint3d ptTemp;
|
||
if (m_nFlag == 0)
|
||
{
|
||
stat = acquirePoint(ptTemp, m_pDrawEnt->GetLocation().AsAcGePoint3d());
|
||
}
|
||
else if ((m_nFlag == 1) || (m_nFlag == 2) || (m_nFlag == 5))
|
||
{
|
||
ADSGePoint3d ptCur;
|
||
GlobalFunc::GetWcsCursor(ptCur);
|
||
ptCur.z = 0;
|
||
//辅助计算直线wlw mod 20150518 辅助线需要清零z,否则引线会飞
|
||
ADSGePoint3d pt1(ptStack[0]), pt2(ptStack[1]);
|
||
pt1.z = 0.0;
|
||
pt2.z = 0.0;
|
||
GeLine line1(pt1, pt2);
|
||
ads_real rAng = line1.Direction();
|
||
ADSGePoint3d pt;
|
||
ads_polar(ptCur, rAng + 0.5 * PI, 100.0, pt);
|
||
GeLine line2(ptCur, pt);
|
||
|
||
//获取基点
|
||
ads_point ptIntersection;
|
||
line1.Intersection(&line2, ptIntersection);
|
||
AcGePoint3d ptBase = asPnt3d(ptIntersection);
|
||
|
||
if (!m_bIsArcDim)
|
||
{
|
||
stat = acquirePoint(ptTemp, ptBase);
|
||
}
|
||
else
|
||
{
|
||
stat = acquirePoint(ptTemp);
|
||
}
|
||
}
|
||
else if (m_nFlag == 3)
|
||
{
|
||
//modidfied by whl on 03/08/08
|
||
ADSGePoint3d ptLast = GetLastPoint();
|
||
stat = acquirePoint(ptTemp, ptLast);
|
||
}
|
||
else if (m_nFlag == 4)
|
||
{
|
||
ADSGePoint3d ptLast;
|
||
GlobalFunc::TGGetVar(_T("LASTPOINT"), ptLast);
|
||
ptLast = GlobalFunc::Ucs2Wcs(ptLast);
|
||
stat = acquirePoint(ptTemp, ptLast);
|
||
}
|
||
|
||
if (stat == AcEdJig::kNormal)
|
||
{
|
||
if (ptTemp.Distance2d(m_ptDim) > g_Option::instance()._DIST_SNAP)
|
||
{
|
||
double nDist = m_ptDim.Distance2d(ptTemp);
|
||
m_ptDim = ptTemp;
|
||
}
|
||
else
|
||
{
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
}
|
||
|
||
return stat;
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean DimensionEdJig::update()
|
||
{
|
||
if (m_nFlag == 0)
|
||
{
|
||
m_pDrawEnt->SetRotation(ads_angle(m_ptDim, m_pDrawEnt->GetLocation()) + PI);
|
||
double nVal = m_ptDim.Distance2d(m_pDrawEnt->GetLocation());
|
||
//modify by lgy 20120503 如果标注在图纸空间中的视口中
|
||
//if(m_pDrawEnt->IsValidSegment(nVal))
|
||
// m_pDrawEnt->SetSegment(0, nVal);
|
||
if (m_pDrawEnt->IsValidSegment(nVal))
|
||
{
|
||
m_pDrawEnt->SetSegment(0, nVal);
|
||
|
||
if (m_bInView)
|
||
{
|
||
double dScale = 1.0;
|
||
BOOL bFit = FALSE;
|
||
int nNum = GlobalFunc::GetPtOnWhichPort(m_ptDim, dScale, bFit, m_entSet);
|
||
if (nNum == m_nPortNum || !bFit)
|
||
{
|
||
m_pDrawEnt->SetStyleId(m_idDimNew);
|
||
m_bSaveStyle = TRUE;
|
||
}
|
||
else
|
||
{
|
||
m_pDrawEnt->SetStyleId(m_idDimOld);
|
||
m_bSaveStyle = FALSE;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
else if (m_nFlag == 1)
|
||
{
|
||
GeCurveSegment seg = m_pDrawEnt->GetDimCurve();
|
||
ADSGePoint3d ptOnSeg;
|
||
if (seg.ProjectToMe(m_ptDim, ptOnSeg) == RTNORM)
|
||
{
|
||
double nDistMove = m_ptDim.Distance2d(ptOnSeg);
|
||
int nSideLoc = seg.OnWhichSide(m_pDrawEnt->GetLocation());
|
||
int nSide = seg.OnWhichSide(m_ptDim);
|
||
double nDist2Dim = m_pDrawEnt->GetDist2DimLine(FALSE);
|
||
|
||
if (fabs(nDist2Dim) > 1.0E-6)
|
||
{
|
||
double nFactor = nDist2Dim / fabs(nDist2Dim);
|
||
if (nSide != nSideLoc)
|
||
nDistMove *= nFactor;
|
||
else
|
||
nDistMove *= -nFactor;
|
||
}
|
||
else
|
||
{
|
||
if (nSideLoc == OFFSET_LEFT)
|
||
nDistMove = -nDistMove;
|
||
}
|
||
if (m_pDrawEnt->IsAngular())
|
||
{ //弧墙有错,不知道原因
|
||
nDist2Dim += nDistMove;
|
||
double nDistRad = m_pDrawEnt->GetDimRadius();
|
||
//seg.GetArc().center.Distance(m_ptDim);
|
||
nDistRad -= nDistMove;
|
||
if (nDistRad > g_Option::instance()._DIST_SNAP)
|
||
{
|
||
m_pDrawEnt->SetDimRadius(nDistRad);
|
||
m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
nDist2Dim += nDistMove;
|
||
m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
}
|
||
|
||
}
|
||
}
|
||
else if (m_nFlag == 2)
|
||
{ //修改标注位置
|
||
AcDbIntArray indices;
|
||
indices.append(3);
|
||
AcGePoint3dArray ptArray;
|
||
m_pDrawEnt->getStretchPoints(ptArray);
|
||
ASSERT(ptArray.length() > 3);
|
||
AcGeVector3d vtOffset = m_ptDim.AsAcGePoint3d() - ptArray[3];
|
||
m_pDrawEnt->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
else if (m_nFlag == 3)
|
||
{//modified by whl on 03/08/08
|
||
ASSERT(m_pTemp);
|
||
GlobalFunc::CopyObject(*m_pDrawEnt, *m_pTemp);
|
||
if (CanUndo())
|
||
{
|
||
if (!m_pTemp->AddSegment(m_ptDim))
|
||
return Adesk::kFalse;
|
||
}
|
||
else
|
||
{
|
||
m_pTemp->SetRotation(ads_angle(m_ptDim, m_pTemp->GetLocation()) + PI);
|
||
double nVal = m_ptDim.Distance2d(m_pTemp->GetLocation());
|
||
if (m_pTemp->IsValidSegment(nVal))
|
||
m_pTemp->SetSegment(0, nVal);
|
||
}
|
||
ASSERT(m_pTemp && m_pTemp->IsValid());
|
||
}
|
||
else if (m_nFlag == 4)
|
||
{
|
||
ASSERT(m_pTemp);
|
||
GlobalFunc::CopyObject(*m_pDrawEnt, *m_pTemp);
|
||
m_pTemp->AddSegment(m_ptDim);
|
||
}
|
||
else if (m_nFlag == 5)
|
||
{
|
||
double dr = m_pDrawEnt->GetObjRadius();
|
||
ADSGePoint3d pt1, pt2;
|
||
m_ObjarDim.GetStartPoint(pt1);
|
||
m_ObjarDim.GetEndPoint(pt2);
|
||
double dDist2d = m_ptDim.Distance2d(m_ObjarDim.GetCenterPt());
|
||
GeCurveSegment ln1(m_ObjarDim.GetCenterPt(), m_ptDim, 0), ln2(pt1, pt2, 0);
|
||
ln2.SetLineFlag(LS_FINITE);
|
||
ln1.SetLineFlag(LS_FINITE);
|
||
int nptins = ln1.Intersection(ln2, pt1, pt2);
|
||
m_pDrawEnt->SetStyleId(InitDimStyle(DS_ANGLE));
|
||
if (dDist2d < dr)
|
||
{//圆内
|
||
if (nptins > 0)
|
||
{//玄长
|
||
m_pDrawEnt->SetStyleId(InitDimStyle(DS_LINEAR));
|
||
m_pDrawEnt->SetAngular(TRUE);
|
||
m_pDrawEnt->SetDimArcLen(FALSE);
|
||
m_pDrawEnt->SetDimChord(TRUE);
|
||
m_pDrawEnt->SetDist2DimLine(0.0);
|
||
m_pDrawEnt->SetDimRadius(m_ObjarDim.GetRadius()/*-6*GlobalFunc::DocGetPScale()*/);
|
||
}
|
||
else
|
||
{//角度
|
||
m_pDrawEnt->SetAngular(TRUE);
|
||
m_pDrawEnt->SetDimArcLen(FALSE);
|
||
m_pDrawEnt->SetDimChord(FALSE);
|
||
m_pDrawEnt->SetDist2DimLine(10);
|
||
m_pDrawEnt->SetDimRadius(m_ObjarDim.GetRadius() - 10 * GlobalFunc::DocGetPScale());
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
if (nptins > 0)
|
||
{//弧长
|
||
m_pDrawEnt->SetAngular(TRUE);
|
||
m_pDrawEnt->SetDimArcLen(TRUE);
|
||
m_pDrawEnt->SetDimChord(FALSE);
|
||
m_pDrawEnt->SetDist2DimLine(-6);
|
||
m_pDrawEnt->SetDimRadius(m_ObjarDim.GetRadius() + 6.0 * GlobalFunc::DocGetPScale());
|
||
}
|
||
else
|
||
{//角度
|
||
m_pDrawEnt->SetAngular(TRUE);
|
||
m_pDrawEnt->SetDimArcLen(FALSE);
|
||
m_pDrawEnt->SetDimChord(FALSE);
|
||
m_pDrawEnt->SetDist2DimLine(10);
|
||
m_pDrawEnt->SetDimRadius(m_ObjarDim.GetRadius() - 10 * GlobalFunc::DocGetPScale());
|
||
|
||
}
|
||
}
|
||
}
|
||
ASSERT(m_pDrawEnt && m_pDrawEnt->IsValid());
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* DimensionEdJig::entity() const
|
||
{
|
||
if ((m_nFlag == 3 || m_nFlag == 4) && m_pTemp)
|
||
return m_pTemp;
|
||
else
|
||
return m_pDrawEnt;
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region DimAngleJig
|
||
DimAngleJig::DimAngleJig(AecDbDimension *pDim,
|
||
AcGeLine2d &line1, AcGeLine2d &line2, ADSGePoint3d &pt,
|
||
TCHAR *pszPrompt, TCHAR *pszKeyword) :
|
||
m_pDim(pDim),
|
||
m_line1(line1), m_line2(line2), m_ptCen(pt),
|
||
m_pszPrompt(pszPrompt), m_pszKeyword(pszKeyword)
|
||
{
|
||
}
|
||
|
||
DimAngleJig::~DimAngleJig()
|
||
{
|
||
}
|
||
|
||
AcEdJig::DragStatus DimAngleJig::doIt()
|
||
{
|
||
setDispPrompt(m_pszPrompt);
|
||
AcEdJig::DragStatus status = AcEdJig::kNull;
|
||
try
|
||
{
|
||
status = drag();
|
||
}
|
||
catch (...)
|
||
{
|
||
status = AcEdJig::kCancel;
|
||
}
|
||
return status;
|
||
}
|
||
|
||
AcEdJig::DragStatus DimAngleJig::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)(AcEdJig::kAccept3dCoordinates |
|
||
AcEdJig::kNullResponseAccepted));
|
||
|
||
AcEdJig::DragStatus status = AcEdJig::kCancel;
|
||
|
||
status = acquirePoint(m_ptCur);
|
||
|
||
if (status == AcEdJig::kNormal)
|
||
{
|
||
if (m_ptCur.isEqualTo(m_ptLast))
|
||
{
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
}
|
||
m_ptLast = m_ptCur;
|
||
|
||
return status;
|
||
}
|
||
|
||
int DimAngleJig::QsortFun(const void *p1, const void *p2)
|
||
{
|
||
double dangle1 = ads_angle(asDblArray(((pPTDATA)p1)->ptCenter), asDblArray(((pPTDATA)p1)->ptTem));
|
||
double dangle2 = ads_angle(asDblArray(((pPTDATA)p2)->ptCenter), asDblArray(((pPTDATA)p2)->ptTem));
|
||
return(dangle1 > dangle2);
|
||
}
|
||
|
||
Adesk::Boolean DimAngleJig::update()
|
||
{
|
||
double dRadiu = m_ptCen.Distance(m_ptCur);
|
||
if (dRadiu < 5.0)
|
||
{
|
||
return Adesk::kFalse;
|
||
}
|
||
|
||
//构造圆
|
||
AcGeCircArc2d circle(m_ptCen, dRadiu);
|
||
|
||
//求圆与直线交点
|
||
int iCount = 0;
|
||
AcGePoint2d pt[4];
|
||
circle.intersectWith(m_line1, iCount, pt[0], pt[1]);
|
||
circle.intersectWith(m_line2, iCount, pt[2], pt[3]);
|
||
|
||
//点队列
|
||
CArray<PTDATA, PTDATA> arr;
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
PTDATA temp;
|
||
temp.ptCenter = m_ptCen;
|
||
temp.ptTem = pt[i];
|
||
arr.Add(temp);
|
||
}
|
||
|
||
PTDATA temp;
|
||
temp.ptCenter = m_ptCen;
|
||
temp.ptTem = AcGePoint2d(m_ptCur.x, m_ptCur.y);
|
||
arr.Add(temp);
|
||
|
||
//队列排序(升序)
|
||
qsort(&arr[0], arr.GetSize(), sizeof(PTDATA&), QsortFun);
|
||
|
||
//取标注起点和终点
|
||
ADSGePoint3d qt1(arr[0].ptTem), qt2(arr[1].ptTem);
|
||
|
||
int iPos = 1;
|
||
for (int j = 0; j < arr.GetSize(); j++)
|
||
{
|
||
if (arr[j].ptTem.isEqualTo(AcGePoint2d(m_ptCur.x, m_ptCur.y)))
|
||
{
|
||
iPos = j;
|
||
break;
|
||
}
|
||
}
|
||
if (iPos == arr.GetSize() - 1)
|
||
{
|
||
qt1 = arr[iPos - 1].ptTem;
|
||
qt2 = arr[0].ptTem;
|
||
}
|
||
else if (iPos == 0)
|
||
{
|
||
qt1 = arr[arr.GetSize() - 1].ptTem;
|
||
qt2 = arr[1].ptTem;
|
||
}
|
||
else
|
||
{
|
||
qt1 = arr[iPos - 1].ptTem;
|
||
qt2 = arr[iPos + 1].ptTem;
|
||
}
|
||
|
||
//初始化
|
||
m_pDim->RemoveSegment(m_pDim->GetSegmentNum() - 1);
|
||
|
||
//更新标注属性
|
||
ADSGePoint3d ptLoc;
|
||
ads_polar(qt1, ads_angle(m_ptCen, qt1),
|
||
2.0 * GlobalFunc::DocGetPScale(),
|
||
ptLoc);
|
||
m_pDim->SetLocation(ptLoc);
|
||
m_pDim->SetDimRadius(m_ptCen.Distance2d(qt1));
|
||
m_pDim->SetRotation(GlobalFunc::AngleRangeTo2PI(ads_angle(m_ptCen, qt1) + PI / 2));
|
||
m_pDim->SetObjRadius(m_ptCen.Distance2d(qt1) + 2.0 * GlobalFunc::DocGetPScale());
|
||
|
||
GeArc ar(m_ptCen, m_ptCen.Distance2d(qt1),
|
||
ads_angle(m_ptCen, qt1),
|
||
ads_angle(m_ptCen, qt2));
|
||
|
||
if (m_pDim->IsValidSegment(ar.GetLength()))
|
||
{
|
||
m_pDim->AppendSegment(ar.GetLength());
|
||
}
|
||
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity * DimAngleJig::entity() const
|
||
{
|
||
return(m_pDim);
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region QuickDimensionJig
|
||
QuickDimensionJig::QuickDimensionJig()
|
||
{
|
||
m_pszKeyword = NULL;
|
||
m_pDrawEntX = NULL;
|
||
m_pDrawEntY = NULL;
|
||
m_dimbEntity.m_iFlag = m_iFlag;
|
||
m_dFactor = 0.0;
|
||
m_dimbEntity.m_pDrawEntAll = NULL;
|
||
m_dimbEntity.m_pDrawEnt = new AecDbDimension;
|
||
}
|
||
|
||
QuickDimensionJig::~QuickDimensionJig()
|
||
{
|
||
if (m_pDrawEntX != NULL)
|
||
delete m_pDrawEntX;
|
||
if (m_pDrawEntY != NULL)
|
||
delete m_pDrawEntY;
|
||
}
|
||
|
||
void QuickDimensionJig::SetKeyword(const TCHAR *pszKeyword)
|
||
{
|
||
m_pszKeyword = pszKeyword;
|
||
}
|
||
|
||
void QuickDimensionJig::SetDimType(int iFlag)
|
||
{
|
||
m_iFlag = iFlag;
|
||
m_dimbEntity.m_iFlag = m_iFlag;
|
||
if (m_iFlag == 2 && m_dimbEntity.m_pDrawEntAll == NULL)
|
||
{
|
||
m_dimbEntity.m_pDrawEntAll = new AecDbDimension;
|
||
}
|
||
}
|
||
|
||
extern TCHAR* LAY_DIM;
|
||
void QuickDimensionJig::SetExtents(ADSGePoint3d lowPt, ADSGePoint3d upPt)
|
||
{
|
||
m_lowPt = GlobalFunc::Wcs2Ucs(lowPt);
|
||
m_upPt = GlobalFunc::Wcs2Ucs(upPt);
|
||
|
||
if (m_pDrawEntX != NULL)
|
||
{
|
||
delete m_pDrawEntX;
|
||
m_pDrawEntX = NULL;
|
||
}
|
||
m_pDrawEntX = new AecDbDimension;
|
||
m_pDrawEntX->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0));//add by whl on 060306
|
||
m_pDrawEntX->SetDist2DimLine(6.0);
|
||
m_pDrawEntX->SetLocation(lowPt);
|
||
m_pDrawEntX->SetRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
double dValX = m_upPt.x - m_lowPt.x;
|
||
if (fabs(dValX) > 1E-3)
|
||
m_pDrawEntX->AppendSegment(dValX);
|
||
|
||
AcDbObjectId idStyle = InitDimStyle(DS_LINEAR);
|
||
m_pDrawEntX->SetStyleId(idStyle);
|
||
m_pDrawEntX->setLayer(LAY_DIM);
|
||
|
||
if (m_pDrawEntY != NULL)
|
||
{
|
||
delete m_pDrawEntY;
|
||
m_pDrawEntY = NULL;
|
||
}
|
||
m_pDrawEntY = new AecDbDimension;
|
||
m_pDrawEntY->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0));//add by whl on 060306
|
||
m_pDrawEntY->SetDist2DimLine(6.0);
|
||
m_pDrawEntY->SetLocation(lowPt);
|
||
m_pDrawEntY->SetRotation(PI / 2 + GlobalFunc::Ucs2Wcs(0.0));
|
||
double dValY = m_upPt.y - m_lowPt.y;
|
||
if (fabs(dValY) > 1E-3)
|
||
m_pDrawEntY->AppendSegment(dValY);
|
||
|
||
m_pDrawEntY->SetStyleId(InitDimStyle(DS_LINEAR));
|
||
m_pDrawEntY->setLayer(LAY_DIM);
|
||
|
||
double dTexth = 3.5;
|
||
OPENOBJ_BEGIN(idStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pDimStyle);
|
||
ASSERT(pDimStyle);
|
||
dTexth = pDimStyle->dimtxt() * pDimStyle->dimscale();
|
||
OPENOBJ_END();
|
||
m_dFactor = 2 * dTexth * GlobalFunc::DocGetPScale();
|
||
m_dimbEntity.m_pDrawEnt->SetStyleId(idStyle);
|
||
if (m_iFlag == 2 && m_dimbEntity.m_pDrawEntAll != NULL)
|
||
{
|
||
m_dimbEntity.m_pDrawEntAll->SetStyleId(idStyle);
|
||
}
|
||
|
||
}
|
||
|
||
void QuickDimensionJig::SetMidPoints(AcGePoint3dArray &dimPoints)
|
||
{
|
||
if (m_iFlag == 0)
|
||
return;
|
||
|
||
long i;
|
||
ADSGePointList lstPointsX, lstPointsY;
|
||
for (i = 0; i < dimPoints.length(); i++)
|
||
{
|
||
ADSGePoint3d ptDim = dimPoints[i];
|
||
lstPointsX.Append(new ADSGePoint3d(ptDim));
|
||
lstPointsY.Append(new ADSGePoint3d(ptDim));
|
||
}
|
||
lstPointsX.QuickSort(CmpPointByX);
|
||
lstPointsY.QuickSort(CmpPointByY);
|
||
|
||
if (m_pDrawEntX->GetSegmentNum() > 0)
|
||
{
|
||
for (i = 0; i < lstPointsX.Length(); i++)
|
||
m_pDrawEntX->AddSegment(*lstPointsX[i]);
|
||
}
|
||
if (m_pDrawEntY->GetSegmentNum() > 0)
|
||
{
|
||
for (i = 0; i < lstPointsY.Length(); i++)
|
||
m_pDrawEntY->AddSegment(*lstPointsY[i]);
|
||
}
|
||
m_pDrawEntX->RemoveZeroSegment();
|
||
m_pDrawEntY->RemoveZeroSegment();
|
||
}
|
||
|
||
void QuickDimensionJig::AddToDataBase()
|
||
{
|
||
if (m_iFlag == 2 && m_dimbEntity.m_pDrawEntAll != NULL)
|
||
{
|
||
if (g_Option::instance().g_nDimAdjust)
|
||
m_dimbEntity.m_pDrawEntAll->AdjustDim(g_Option::instance().g_nDimAdjust != 2);
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
m_dimbEntity.m_pDrawEntAll->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
GlobalFunc::AddToSpace(Adesk::kTrue, m_dimbEntity.m_pDrawEntAll);
|
||
}
|
||
|
||
//add by whl on 060119
|
||
if (g_Option::instance().g_nDimAdjust)
|
||
m_dimbEntity.m_pDrawEnt->AdjustDim(g_Option::instance().g_nDimAdjust != 2);
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
m_dimbEntity.m_pDrawEnt->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//m_dimbEntity.m_pDrawEnt->AddToCSpace(Adesk::kTrue);
|
||
GlobalFunc::AddToSpace(Adesk::kTrue, m_dimbEntity.m_pDrawEnt);
|
||
}
|
||
|
||
int QuickDimensionJig::doIt()
|
||
{
|
||
int ret;
|
||
try
|
||
{
|
||
ret = drag();
|
||
}
|
||
catch (...)
|
||
{
|
||
ret = AcEdJig::kCancel;
|
||
}
|
||
|
||
if (ret == AcEdJig::kCancel)
|
||
ret = RTCAN;
|
||
else if (ret == AcEdJig::kNull)
|
||
ret = RTNONE;
|
||
else if (ret <= 0)
|
||
ret = RTNORM;
|
||
else
|
||
ret = RTKWORD;
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus QuickDimensionJig::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
if (m_pszKeyword)
|
||
setKeywordList(m_pszKeyword);
|
||
|
||
ADSGePoint3d ptCursor;
|
||
DragStatus stat = acquirePoint(ptCursor);
|
||
ptCursor = ptCursor;
|
||
if (stat == AcEdJig::kNormal)
|
||
{
|
||
if (ptCursor.Distance2d(m_ptDim) > g_Option::instance()._DIST_SNAP)
|
||
m_ptDim = ptCursor;
|
||
else
|
||
stat = AcEdJig::kNoChange;
|
||
}
|
||
return stat;
|
||
}
|
||
|
||
// 更新实体数据
|
||
//modified by whl on 050811
|
||
Adesk::Boolean QuickDimensionJig::update()
|
||
{
|
||
double nDist2Dim = 0.0;
|
||
BOOL b2 = FALSE;
|
||
while (m_dimbEntity.m_pDrawEnt->GetSegmentNum() > 0)
|
||
m_dimbEntity.m_pDrawEnt->RemoveSegment(0);
|
||
if (m_iFlag == 2 && m_dimbEntity.m_pDrawEntAll != NULL)
|
||
{
|
||
b2 = TRUE;
|
||
while (m_dimbEntity.m_pDrawEntAll->GetSegmentNum() > 0)
|
||
m_dimbEntity.m_pDrawEntAll->RemoveSegment(0);
|
||
}
|
||
|
||
|
||
|
||
ADSGePoint3d ptLoc(m_lowPt);
|
||
ADSGePoint3d ptDim = GlobalFunc::Wcs2Ucs(m_ptDim);
|
||
double dangle;
|
||
if (ptDim.y < m_upPt.y && ptDim.y > m_lowPt.y && (ptDim.x < m_lowPt.x || ptDim.x > m_upPt.x))
|
||
{
|
||
if (m_pDrawEntY->GetSegmentNum() > 0)
|
||
{
|
||
//m_dimbEntity.m_pDrawEnt->copyFrom(m_pDrawEntY);
|
||
for (long i = 0; i < m_pDrawEntY->GetSegmentNum(); i++)
|
||
m_dimbEntity.m_pDrawEnt->AppendSegment(m_pDrawEntY->GetSegment(i));
|
||
|
||
dangle = PI / 2 + GlobalFunc::Ucs2Wcs(0.0);
|
||
m_dimbEntity.m_pDrawEnt->SetRotation(dangle);
|
||
|
||
if (b2)
|
||
{
|
||
double dValY = m_upPt.y - m_lowPt.y;
|
||
if (fabs(dValY) > 1E-3)
|
||
m_dimbEntity.m_pDrawEntAll->AppendSegment(dValY);
|
||
m_dimbEntity.m_pDrawEntAll->SetRotation(dangle);
|
||
}
|
||
if (ptDim.x < (m_lowPt.x + m_upPt.x) * 0.5)
|
||
ptLoc.x = m_lowPt.x;
|
||
else
|
||
ptLoc.x = m_upPt.x;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (m_pDrawEntX->GetSegmentNum() > 0)
|
||
{
|
||
//m_dimbEntity.m_pDrawEnt->copyFrom(m_pDrawEntX);
|
||
for (long i = 0; i < m_pDrawEntX->GetSegmentNum(); i++)
|
||
m_dimbEntity.m_pDrawEnt->AppendSegment(m_pDrawEntX->GetSegment(i));
|
||
m_dimbEntity.m_pDrawEnt->SetRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
|
||
if (b2)
|
||
{
|
||
double dValX = m_upPt.x - m_lowPt.x;
|
||
if (fabs(dValX) > 1E-3)
|
||
m_dimbEntity.m_pDrawEntAll->AppendSegment(dValX);
|
||
m_dimbEntity.m_pDrawEntAll->SetRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
}
|
||
|
||
if (ptDim.y < (m_lowPt.y + m_upPt.y) * 0.5)
|
||
{
|
||
ptLoc.y = m_lowPt.y;
|
||
}
|
||
else
|
||
{
|
||
|
||
ptLoc.y = m_upPt.y;
|
||
}
|
||
}
|
||
}
|
||
m_dimbEntity.m_pDrawEnt->SetLocation(GlobalFunc::Ucs2Wcs(ptLoc));
|
||
if (b2)
|
||
m_dimbEntity.m_pDrawEntAll->SetLocation(GlobalFunc::Ucs2Wcs(ptLoc));
|
||
|
||
ADSGePoint3d ptOnSeg;
|
||
GeCurveSegment seg;
|
||
seg = m_dimbEntity.m_pDrawEnt->GetDimCurve();
|
||
if (b2)
|
||
seg = m_dimbEntity.m_pDrawEntAll->GetDimCurve();
|
||
if (seg.ProjectToMe(m_ptDim, ptOnSeg) == RTNORM)
|
||
{
|
||
double nDistMove = m_ptDim.Distance2d(ptOnSeg);
|
||
int nSideLoc = seg.OnWhichSide(m_dimbEntity.m_pDrawEnt->GetLocation());
|
||
int nSide = seg.OnWhichSide(m_ptDim);
|
||
nDist2Dim = m_dimbEntity.m_pDrawEnt->GetDist2DimLine(FALSE);
|
||
if (b2)
|
||
{
|
||
nSideLoc = seg.OnWhichSide(m_dimbEntity.m_pDrawEntAll->GetLocation());
|
||
nDist2Dim = m_dimbEntity.m_pDrawEntAll->GetDist2DimLine(FALSE);
|
||
}
|
||
double nFactor = nDist2Dim / fabs(nDist2Dim);
|
||
if (fabs(nDist2Dim) > 1.0E-6)
|
||
{
|
||
if (nSide != nSideLoc)
|
||
{
|
||
nDistMove *= nFactor;
|
||
}
|
||
else
|
||
{
|
||
nDistMove *= -nFactor;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (nSideLoc == OFFSET_LEFT)
|
||
nDistMove *= -1;
|
||
}
|
||
nDist2Dim += nDistMove;
|
||
if (b2)
|
||
{
|
||
m_dimbEntity.m_pDrawEntAll->SetDist2DimLine(nDist2Dim, FALSE);
|
||
|
||
if (nDist2Dim >= 0)
|
||
nDist2Dim -= m_dFactor;
|
||
else
|
||
nDist2Dim += m_dFactor;
|
||
m_dimbEntity.m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
}
|
||
else
|
||
m_dimbEntity.m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
|
||
}
|
||
ASSERT(m_dimbEntity.m_pDrawEnt && m_dimbEntity.m_pDrawEnt->IsValid());
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* QuickDimensionJig::entity() const
|
||
{
|
||
return (AcDbEntity*)&m_dimbEntity;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region SymbEdJig
|
||
int SymbEdJig::GetRetCode(int retCode, int *kwordId) const
|
||
{
|
||
int ret = retCode;
|
||
if (ret == AcEdJig::kCancel)
|
||
ret = RTCAN;
|
||
else if (ret == AcEdJig::kNull)
|
||
ret = RTNONE;
|
||
else if (ret <= 0)
|
||
ret = RTNORM;
|
||
else {
|
||
if (kwordId) *kwordId = ret - 1;
|
||
ret = RTKWORD;
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
|
||
// 开始执行拖动
|
||
int SymbEdJig::DoIt(int *keyIndex)
|
||
{
|
||
int nRetCode = 0;
|
||
acedGetAcadDwgView()->SetFocus(); //屏幕菜单点取时, 命令焦点没有在图形窗口
|
||
setDispPrompt(m_sPrompt);
|
||
if (!!m_sKeyword && keyIndex) {
|
||
INITGET_BEG(-1, m_sKeyword);
|
||
try {
|
||
nRetCode = drag();
|
||
}
|
||
catch (...) {
|
||
nRetCode = AcEdJig::kCancel;
|
||
}
|
||
INITGET_END();
|
||
}
|
||
else {
|
||
try {
|
||
nRetCode = drag();
|
||
}
|
||
catch (...) {
|
||
nRetCode = AcEdJig::kCancel;
|
||
}
|
||
}
|
||
nRetCode = GetRetCode(nRetCode, keyIndex);
|
||
return nRetCode;
|
||
}
|
||
|
||
AcEdJig::DragStatus SymbEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
return acquirePoint(pt);
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus SymbEdJig::sampler()
|
||
{
|
||
DragStatus stat;
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
if (!!m_sKeyword) setKeywordList(m_sKeyword);
|
||
else setKeywordList(NULL);
|
||
|
||
XPoint ptTemp;
|
||
stat = GetPoint(ptTemp);
|
||
|
||
if (stat == AcEdJig::kNormal) {
|
||
if (IsPosChanged(ptTemp)) {
|
||
m_ptResult = ptTemp;
|
||
}
|
||
else
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
|
||
return stat;
|
||
}
|
||
|
||
BOOL SymbEdJig::IsPosChanged(XPoint ptNew) const
|
||
{
|
||
return (ptNew.Distance(m_ptResult) > g_Option::instance()._DIST_SNAP);
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region NorthThumbEdJig
|
||
NorthThumbEdJig::NorthThumbEdJig(AecXDbSymbNorthThumb *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int NorthThumbEdJig::DoIt(int *keyIndex)
|
||
{
|
||
m_ptResult = m_nOperCode == kCenter ?
|
||
m_pDrawEnt->GetCenter() : m_pDrawEnt->GetNorthPoint();
|
||
|
||
int nRet = SymbEdJig::DoIt(keyIndex);
|
||
return nRet;
|
||
}
|
||
|
||
BOOL NorthThumbEdJig::IsPosChanged(XPoint ptNew) const
|
||
{
|
||
BOOL bRet;
|
||
if (m_nOperCode == kCenter)
|
||
bRet = SymbEdJig::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 < g_DimOption::instance()._angSnap || nAng2 < g_DimOption::instance()._angSnap)
|
||
bRet = FALSE;
|
||
else bRet = TRUE;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus NorthThumbEdJig::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 NorthThumbEdJig::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* NorthThumbEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region SymmetryEdJig
|
||
SymmetryEdJig::SymmetryEdJig(AecXDbSymbSymmetry *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
m_ptResult = m_pDrawEnt->GetEndPoint();
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus SymmetryEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
return acquirePoint(pt, m_pDrawEnt->GetStartPoint().AsAcGePoint3d());
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean SymmetryEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet = Adesk::kTrue;
|
||
m_pDrawEnt->SetEndPoint(m_ptResult);
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* SymmetryEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region CloudLineJig
|
||
CloudLineJig::CloudLineJig(AecXDbSymbModi *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);
|
||
}
|
||
|
||
CloudLineJig::~CloudLineJig()
|
||
{
|
||
}
|
||
|
||
int CloudLineJig::DoIt(int *keyIndex)
|
||
{
|
||
int nLength = m_pline.Length();
|
||
if (nLength > 1)
|
||
m_ptResult = *m_pline[nLength - 1];
|
||
else
|
||
m_ptResult = m_ptFirst;
|
||
|
||
int nRet = SymbEdJig::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() - g_Option::instance()._DIST_SNAP)
|
||
{
|
||
ADSGePointDir2d 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 CloudLineJig::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 - g_Option::instance()._DIST_SNAP && dDistance < m_dMax + g_Option::instance()._DIST_SNAP) // 直接1个弧就可以解决
|
||
{
|
||
m_pline.AppendNode(pt);
|
||
}
|
||
else if (dDistance > m_dMax + g_Option::instance()._DIST_SNAP) // 需要多个弧连接
|
||
{
|
||
XCurveSegment segTemp(ptBase, pt, 0);
|
||
|
||
double dLengh(0.0);
|
||
while (dLengh < dDistance + g_Option::instance()._DIST_SNAP)
|
||
{
|
||
ADSGePointDir2d 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 CloudLineJig::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* CloudLineJig::entity() const
|
||
{
|
||
return (AcDbEntity*)m_pModi;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region SectionEdJig
|
||
SectionEdJig::SectionEdJig(AecXDbSymbSection *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 SectionEdJig::SetJigDlg(CSectionDlg *pDlg)
|
||
{
|
||
m_pDlg = pDlg;
|
||
}
|
||
int SectionEdJig::GetiFlag2()
|
||
{
|
||
return m_iFlag2;
|
||
}
|
||
|
||
void SectionEdJig::SetJigMode(int nMode)
|
||
{
|
||
m_nMode = nMode;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int SectionEdJig::DoIt(int *keyIndex)
|
||
{
|
||
XPushVar<int> osmode(_T("OSMODE"), 0);//add by whl
|
||
|
||
if (m_nOperCode == kSectPointOther)
|
||
{
|
||
m_iFlag2 = 1 - m_iFlag2;
|
||
GlobalFunc::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();
|
||
}
|
||
|
||
int nRet = 0;
|
||
if (m_nMode != 3)
|
||
{
|
||
nRet = SymbEdJig::DoIt(keyIndex);
|
||
}
|
||
else //绘制模式为非正交转正剖切,需要恢复对象捕捉
|
||
{
|
||
XPushVar<int> osmode(_T("OSMODE"), 16383);
|
||
nRet = SymbEdJig::DoIt(keyIndex);
|
||
}
|
||
if (m_nOperCode == kSectPointOther)
|
||
{
|
||
if (nRet == RTNORM || (nRet == RTNONE && m_iFlag2 == 0))
|
||
GlobalFunc::CopyObject(m_drawEnt, *m_pDrawEnt);
|
||
}
|
||
return nRet;
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus SectionEdJig::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);
|
||
}
|
||
|
||
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 SectionEdJig::update()
|
||
{
|
||
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)
|
||
{
|
||
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
|
||
{
|
||
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();
|
||
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* SectionEdJig::entity() const
|
||
{
|
||
|
||
return ((m_nOperCode == kSectPointOther) ? (AcDbEntity *)&m_drawEnt : (AcDbEntity *)m_pDrawEnt);
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region SymbCutJig
|
||
|
||
|
||
///////////////////////////////////////////////////////////
|
||
SymbCutJig::SymbCutJig(const XPoint& pt)
|
||
{
|
||
pt0 = pt;
|
||
pt1 = pt;
|
||
pt3 = pt4 = pt2 = pt;
|
||
m_nRupNum = 1;
|
||
mPromptCounter = 0;
|
||
//m_ClipType = XDcClip::kClipOut;
|
||
//m_pSymbCut = new TDbSymbCut;
|
||
|
||
m_bIsTwo = FALSE; // add by lgy 20120511,是否是双折断线,默认为不是
|
||
}
|
||
|
||
int SymbCutJig::GetRetCode(int nRetCode, int *kwordId) const
|
||
{
|
||
int ret = nRetCode;
|
||
if (ret == AcEdJig::kCancel)
|
||
ret = RTCAN;
|
||
else if (ret == AcEdJig::kNull)
|
||
ret = RTNONE;
|
||
else if (ret <= 0)
|
||
ret = RTNORM;
|
||
else
|
||
{
|
||
if (kwordId)
|
||
*kwordId = ret - 1;
|
||
ret = RTKWORD;
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
int SymbCutJig::DoIt()
|
||
{
|
||
AcEdJig::DragStatus stat;
|
||
int iKey;
|
||
while (true)
|
||
{
|
||
if (!m_bIsTwo)
|
||
{
|
||
g_Option::instance().adsout << _T("\n点取折断线终点或 [改折断数目(N),当前=") << m_nRupNum << _T("]<退出>:");
|
||
}
|
||
else
|
||
{
|
||
g_Option::instance().adsout << _T("\n点取第一折断线终点或 [改折断数目(N),当前=") << m_nRupNum << _T("]<退出>:");
|
||
}
|
||
|
||
INITGET_BEG(-1, _T("N"))
|
||
try
|
||
{
|
||
stat = drag();
|
||
}
|
||
catch (...)
|
||
{
|
||
stat = AcEdJig::kCancel;
|
||
}
|
||
INITGET_END()
|
||
|
||
int nCode = GetRetCode(stat, &iKey);
|
||
if (nCode == RTKWORD)
|
||
{
|
||
g_Option::instance().adsout << _T("\n折断数目<") << m_nRupNum << _T(">:");
|
||
ads_initget(RSG_NONEG, NULL);
|
||
ads_getint(_T(""), &m_nRupNum);
|
||
}
|
||
else if (nCode != RTNORM)
|
||
return RTCAN;
|
||
else // 取点
|
||
break;
|
||
}
|
||
|
||
mPromptCounter++; // now == 1
|
||
// add by lgy 20120511 判断当前是否是双折断线
|
||
if (m_bIsTwo)
|
||
{
|
||
g_Option::instance().adsout << _T("\n点取第二折断线位置<退出>:");
|
||
|
||
//m_ClipType = XDcClip::kClipIn;
|
||
try
|
||
{
|
||
stat = drag();
|
||
}
|
||
catch (...)
|
||
{
|
||
stat = AcEdJig::kCancel;
|
||
}
|
||
|
||
if (stat == AcEdJig::kNormal)
|
||
{
|
||
return RTNORM;
|
||
}
|
||
else if (stat == AcEdJig::kCancel)
|
||
{
|
||
return RTCAN;
|
||
}
|
||
else
|
||
{
|
||
return RTNONE;
|
||
}
|
||
}
|
||
|
||
while (true)
|
||
{
|
||
try
|
||
{
|
||
stat = drag();
|
||
}
|
||
catch (...)
|
||
{
|
||
stat = AcEdJig::kCancel;
|
||
}
|
||
|
||
int nCode = GetRetCode(stat, &iKey);
|
||
if (nCode == RTNONE)
|
||
{
|
||
return RTNONE;
|
||
}
|
||
else if (nCode != RTNORM)
|
||
return RTCAN;
|
||
else // 取点
|
||
break;
|
||
}
|
||
return RTNORM;
|
||
}
|
||
|
||
AcEdJig::DragStatus SymbCutJig::sampler()
|
||
{
|
||
DragStatus stat;
|
||
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
|
||
if (mPromptCounter == 0)
|
||
{
|
||
setKeywordList(_T("N"));
|
||
static XPoint PointTemp1;
|
||
stat = acquirePoint(pt1, pt0);
|
||
|
||
if (PointTemp1 != pt1)
|
||
PointTemp1 = pt1;
|
||
else if (stat == AcEdJig::kNormal)
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
else if (mPromptCounter == 1)
|
||
{
|
||
setKeywordList(_T("Q"));
|
||
static XPoint PointTemp2;
|
||
stat = acquirePoint(pt2);
|
||
if (PointTemp2 != pt2)
|
||
PointTemp2 = pt2;
|
||
else if (stat == AcEdJig::kNormal)
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
return stat;
|
||
}
|
||
|
||
Adesk::Boolean
|
||
SymbCutJig::update()
|
||
{
|
||
switch (mPromptCounter)
|
||
{
|
||
case 0:
|
||
{
|
||
XCurveSegment aLine(pt0, pt1, LS_INFINITE);
|
||
aLine.SetElevation(0);
|
||
|
||
double dist = 1000;
|
||
int side = 0;
|
||
XCurveSegment aLine1 = aLine.Offset(side, dist, LS_INFINITE);
|
||
pt3 = aLine1.EndPoint();
|
||
pt4 = aLine1.StartPoint();
|
||
break;
|
||
}
|
||
case 1:
|
||
{
|
||
XCurveSegment aLine(pt0, pt1, LS_INFINITE);
|
||
aLine.SetElevation(0);
|
||
pt2.z = 0;
|
||
double dist = pt2.Distance(&aLine);
|
||
int side = aLine.OnWhichSide(pt2);
|
||
XCurveSegment aLine1 = aLine.Offset(side, dist, LS_INFINITE);
|
||
pt3 = aLine1.EndPoint();
|
||
pt4 = aLine1.StartPoint();
|
||
break;
|
||
}
|
||
}
|
||
XPoly2D aPoly;
|
||
aPoly.AppendNode(pt0);
|
||
aPoly.AppendNode(pt1);
|
||
aPoly.AppendNode(pt3);
|
||
aPoly.AppendNode(pt4);
|
||
//m_pSymbCut->SetOutline(aPoly);
|
||
//m_pSymbCut->SetEdgeType(0, m_nRupNum);
|
||
//add by lgy 20120511 双折断线
|
||
//if (m_bIsTwo)
|
||
//{
|
||
// m_pSymbCut->SetEdgeType(2, m_nRupNum);
|
||
//}
|
||
//m_pSymbCut->SetClipType(m_ClipType);
|
||
|
||
// delete by xly on 100915 实体图层设置放在AddToSpace中
|
||
//m_pSymbCut->setLayer(InitLayer(LAY_OTHER_DIM));
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* SymbCutJig::entity() const
|
||
{
|
||
//return m_pSymbCut;
|
||
return NULL;
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region ArrowEdJig
|
||
ArrowEdJig::ArrowEdJig(AecXDbSymbArrow *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
m_bFirst = TRUE;
|
||
}
|
||
|
||
AcEdJig::DragStatus ArrowEdJig::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 ArrowEdJig::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 = SymbEdJig::DoIt(keyIndex);
|
||
return nRet;
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean ArrowEdJig::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()) > g_Option::instance()._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((AecXDbSymbArrow::TArrowType)g_Option::instance().g_nSymbArrowStyle);
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* ArrowEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region CoordEdJig
|
||
CoordEdJig::CoordEdJig(AecXDbSymbCoord *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int CoordEdJig::DoIt()
|
||
{
|
||
// sg modify 120618,解决设置固定度角后,坐标文字位置不正确的问题
|
||
savePoint = m_saveFirstPt;
|
||
|
||
XPushVar<int> osmode(_T("OSMODE"), 0);//add by whl
|
||
return SymbEdJig::DoIt();
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean CoordEdJig::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 = GlobalFunc::Ucs2Wcs(savePoint);
|
||
if (CCoordDlg::m_bFixAngle)
|
||
{
|
||
//这个点的坐标有问题
|
||
double x0, y0;
|
||
double xi, yi;
|
||
x0 = savePoint.x;
|
||
y0 = savePoint.y;
|
||
xi = GlobalFunc::Wcs2Ucs(m_ptResult).x;
|
||
yi = GlobalFunc::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 = GlobalFunc::IsKeyPressed(VK_SHIFT);
|
||
XVector3D vt = m_ptResult - m_pDrawEnt->GetLocation();
|
||
double nAngle = ads_angle(XPoint(), vt);
|
||
nAngle = CT_std_angle(nAngle - GlobalFunc::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 = GlobalFunc::Wcs2Ucs(m_ptResult);
|
||
double x5 = GlobalFunc::Wcs2Ucs(m_ptResult.x);
|
||
double d1 = sqrt((GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(temp).x)
|
||
* (GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(temp).x)
|
||
+ (GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(temp).y)
|
||
* (GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(temp).y));
|
||
double d3 = atan2(GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(temp).y,
|
||
GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(temp).x);
|
||
double d2 = cos((m_dFixAngle / 180) * PI - d3);
|
||
double d = d1 * d2;
|
||
XPoint ptTemp;
|
||
ptTemp.y = GlobalFunc::Wcs2Ucs(temp).y + d * sin((m_dFixAngle / 180) * PI);
|
||
ptTemp.x = GlobalFunc::Wcs2Ucs(temp).x + d * cos((m_dFixAngle / 180) * PI);
|
||
m_pDrawEnt->SetQuadrant(nQuadrant);//设置象限
|
||
m_pDrawEnt->SetTurnPoint(GlobalFunc::Ucs2Wcs(ptTemp));
|
||
}
|
||
}
|
||
else if (!CCoordDlg::m_bFixAngle)
|
||
{
|
||
BOOL bShift = GlobalFunc::IsKeyPressed(VK_SHIFT);
|
||
XVector3D vt = m_ptResult - m_pDrawEnt->GetLocation();
|
||
double nAngle = ads_angle(XPoint(), vt);
|
||
|
||
nAngle = CT_std_angle(nAngle - GlobalFunc::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* CoordEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region ElevEdJig
|
||
ElevEdJig::ElevEdJig(AecXDbSymbElevation *pElev)
|
||
{
|
||
m_nOperCode = ElevEdJig::kNone;
|
||
m_pDrawEnt = pElev;
|
||
}
|
||
|
||
XPoint ElevEdJig::GetDragPoint() const
|
||
{
|
||
XPoint ptDrag = m_ptResult;
|
||
XPoint ptArray[7];
|
||
m_pDrawEnt->GetVertexes(ptArray);
|
||
if (m_nOperCode == ElevEdJig::kDirection)
|
||
ptDrag = ptArray[2];
|
||
else if (m_nOperCode == ElevEdJig::kBaseLine)
|
||
ptDrag = ptArray[4];
|
||
else if (m_nOperCode == ElevEdJig::kLeader)
|
||
ptDrag = ptArray[6];
|
||
else if (m_nOperCode == ElevEdJig::kMove) // add by zkm
|
||
ptDrag = ptArray[0];
|
||
return ptDrag;
|
||
}
|
||
|
||
XPoint ElevEdJig::GetBasePoint() const
|
||
{
|
||
XPoint ptDrag = m_ptResult;
|
||
XPoint ptArray[7];
|
||
m_pDrawEnt->GetVertexes(ptArray);
|
||
if (m_nOperCode == ElevEdJig::kDirection)
|
||
// ptDrag = ptArray[2];
|
||
ptDrag = ptArray[0]; // sg modify 090209,根据林工提出的意见,仿照理正修改,方向JIG更明显
|
||
else if (m_nOperCode == ElevEdJig::kBaseLine)
|
||
ptDrag = ptArray[0];
|
||
else if (m_nOperCode == ElevEdJig::kMove) // add by zkm
|
||
{
|
||
ptDrag = m_ptBase;
|
||
if (g_bHightWrite)
|
||
ptDrag = ptArray[0];
|
||
}
|
||
return ptDrag;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int ElevEdJig::DoIt(int *keyIndex)
|
||
{
|
||
m_ptResult = GetDragPoint();
|
||
return SymbEdJig::DoIt(keyIndex);
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus ElevEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
return acquirePoint(pt, GetBasePoint().AsAcGePoint3d());
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean ElevEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet = Adesk::kTrue;
|
||
AcGePoint3dArray gripPoints;
|
||
AecXDbSymbElevation *pElev = m_pDrawEnt;
|
||
VERIFY(pElev->getStretchPoints(gripPoints) == Acad::eOk);
|
||
if (m_nOperCode == ElevEdJig::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() > g_Option::instance()._DIST_SNAP * 10)
|
||
{
|
||
// sg modify 090330,解决灵敏度丢失问题,首先将矢量单位化,再扩大
|
||
vtOffset.normalize();
|
||
double dScale = (2 * GlobalFunc::DocGetEleTriangleSize() + 0.5) * GlobalFunc::DocGetPScale();
|
||
vtOffset *= dScale;
|
||
pElev->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
|
||
if (pElev->IsFilled() || pElev->IsHollowTriangle()) // sg add 090209,增加文字位置点设置
|
||
pElev->SetTextBaseLen(GlobalFunc::DocGetEleTriangleSize());
|
||
else if (pElev->IsDote())
|
||
pElev->SetTextBaseLen(GlobalFunc::DocGetEleDoteSize());
|
||
else
|
||
pElev->SetTextBaseLen(pElev->GetDefaultTextBaseLen());
|
||
pElev->SetTextPoint(pElev->GetDefaultTextLocation());
|
||
pElev->SetLowTextPt(pElev->GetDefaultTextLocation2()); // sg add 090223
|
||
}
|
||
else if (m_nOperCode == ElevEdJig::kBaseLine)
|
||
{
|
||
AcGeVector3d vtOffset = m_ptResult.AsAcGePoint3d() - gripPoints[3];
|
||
AcDbIntArray indices;
|
||
indices.append(3);
|
||
if (vtOffset.length() > g_Option::instance()._DIST_SNAP)
|
||
pElev->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
else if (m_nOperCode == ElevEdJig::kLeader)
|
||
{
|
||
int idx = pElev->HasBaseLine() ? 4 : 3;
|
||
AcGeVector3d vtOffset = m_ptResult.AsAcGePoint3d() - gripPoints[idx];
|
||
AcDbIntArray indices;
|
||
indices.append(idx);
|
||
if (vtOffset.length() > g_Option::instance()._DIST_SNAP * 10)
|
||
pElev->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
// add by zkm
|
||
else if (m_nOperCode == ElevEdJig::kMove)
|
||
{
|
||
XPoint pt = GlobalFunc::Wcs2Ucs(m_ptResult);
|
||
XPoint pt1 = GlobalFunc::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] = GlobalFunc::Ucs2Wcs(pt1).AsAcGePoint3d();
|
||
}
|
||
else
|
||
gripPoints[0] = m_ptResult.AsAcGePoint3d();
|
||
|
||
pElev->SetLocation(gripPoints[0]);
|
||
acedGetAcadDwgView()->SetFocus();
|
||
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* ElevEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region LeaderEdJig
|
||
extern XPoint pptfirst;
|
||
CString g_sLeadFixAngle = _T("45");
|
||
BOOL g_bLeadFixAngle = FALSE;
|
||
LeaderEdJig::LeaderEdJig(AecXDbSymbMultiLeader *pElev)
|
||
{
|
||
m_nOperCode = LeaderEdJig::kNone;
|
||
m_pDrawEnt = pElev;
|
||
}
|
||
|
||
XPoint LeaderEdJig::GetDragPoint() const
|
||
{
|
||
XPoint ptDrag = m_ptResult;
|
||
if (m_nOperCode == LeaderEdJig::kLeader)
|
||
ptDrag = m_pDrawEnt->GetLeaderPoint();
|
||
else if (m_nOperCode == LeaderEdJig::kTextLine)
|
||
ptDrag = m_pDrawEnt->GetTextBasePoint();
|
||
return ptDrag;
|
||
}
|
||
|
||
XPoint LeaderEdJig::GetBasePoint() const
|
||
{
|
||
XPoint ptDrag = m_ptResult;
|
||
if (m_nOperCode == LeaderEdJig::kLeader)
|
||
{
|
||
XPointList pts;
|
||
m_pDrawEnt->GetLeaderVertexes(pts);
|
||
if (pts.Length())
|
||
ptDrag = *pts[0];
|
||
}
|
||
else
|
||
{
|
||
ptDrag = m_pDrawEnt->GetLeaderPoint();
|
||
}
|
||
return ptDrag;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int LeaderEdJig::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 SymbEdJig::DoIt(keyIndex);
|
||
}
|
||
return SymbEdJig::DoIt(keyIndex);
|
||
}
|
||
void LeaderEdJig::SetDlg(CLeaderDlg *pLeadDlg)
|
||
{
|
||
m_pDlg = pLeadDlg;
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus
|
||
LeaderEdJig::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 LeaderEdJig::update()
|
||
{
|
||
Adesk::Boolean bRet = Adesk::kTrue;
|
||
if (m_nOperCode == LeaderEdJig::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 = GlobalFunc::Wcs2Ucs(m_ptResult).x;
|
||
yi = GlobalFunc::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 = GlobalFunc::Wcs2Ucs(temp);
|
||
double d1 = sqrt((GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(temp).x)
|
||
* (GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(temp).x)
|
||
+ (GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(temp).y)
|
||
* (GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(temp).y));
|
||
double d3 = atan2(GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(temp).y,
|
||
GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(temp).x);
|
||
double d2 = cos((m_dFixAngle / 180) * PI - d3);
|
||
double d = d1 * d2;
|
||
|
||
XPoint ptTemp;
|
||
ptTemp.y = GlobalFunc::Wcs2Ucs(temp).y + d * sin((m_dFixAngle / 180) * PI);
|
||
ptTemp.x = GlobalFunc::Wcs2Ucs(temp).x + d * cos((m_dFixAngle / 180) * PI);
|
||
XVector3D vtOffset = ptTemp - GlobalFunc::Wcs2Ucs(temp);
|
||
m_pDrawEnt->SetLeaderPoint(GlobalFunc::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 == LeaderEdJig::kVertex)
|
||
{
|
||
}
|
||
else if (m_nOperCode == LeaderEdJig::kTextLine)
|
||
{
|
||
XPoint ptLeader = m_pDrawEnt->GetLeaderPoint();
|
||
// mofidied by whl on 060208
|
||
// m_pDrawEnt->SetTextBaseLen(m_ptResult.x - ptLeader.x, FALSE);
|
||
m_pDrawEnt->SetTextBaseLen(GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(ptLeader).x, FALSE);
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
AcDbEntity* LeaderEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
LeaderAddOtherPtJig::LeaderAddOtherPtJig(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;
|
||
}
|
||
|
||
LeaderAddOtherPtJig::LeaderAddOtherPtJig(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 LeaderAddOtherPtJig::DoIt(int *keyIndex)
|
||
{
|
||
// modify by xly on 100903 对象捕捉有效,不影响用户设置
|
||
// XPushVar<int> osmode(_T("OSMODE"), 0); // 临时将对象捕捉关掉
|
||
return SymbEdJig::DoIt(keyIndex);
|
||
}
|
||
|
||
AcEdJig::DragStatus LeaderAddOtherPtJig::GetPoint(XPoint &pt)
|
||
{
|
||
return acquirePoint(pt); // 自由拖拽,不受正交控制
|
||
}
|
||
|
||
Adesk::Boolean LeaderAddOtherPtJig::update()
|
||
{
|
||
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(ADSGePoint3d(m_ptLeader), m_nLayoutRotation, 100.0, ptTemp);
|
||
XLine textbaseline(ADSGePoint3d(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(ADSGePoint3d(ptads).AsAcGePoint3d());
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
m_line.setEndPoint(m_ptResult);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* LeaderAddOtherPtJig::entity() const
|
||
{
|
||
return (AcDbEntity *)&m_line;
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region DrawingNameJig
|
||
DrawingNameJig::DrawingNameJig(AecXDbDrawingName *pEnt)
|
||
: m_pDrawEnt(pEnt)
|
||
, m_pszPrompt(NULL)
|
||
, m_pszKeyword(NULL)
|
||
{
|
||
}
|
||
|
||
void DrawingNameJig::SetPrompt(const TCHAR *pszPrompt)
|
||
{
|
||
m_pszPrompt = pszPrompt;
|
||
}
|
||
|
||
void DrawingNameJig::SetKeyword(const TCHAR *pszKeyword)
|
||
{
|
||
m_pszKeyword = pszKeyword;
|
||
}
|
||
|
||
int DrawingNameJig::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 DrawingNameJig::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 DrawingNameJig::update()
|
||
{
|
||
// m_pDrawEnt->SetLocation(m_ptIns); // sg modify 090112
|
||
m_pDrawEnt->SetMidLocation(m_ptIns);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity *DrawingNameJig::entity() const
|
||
{
|
||
//AecXDbDrawingName *p = (AecXDbDrawingName*)m_pDrawEnt->clone();
|
||
//p->m_bInJig = false;
|
||
return m_pDrawEnt;
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region DrawingIndexEdJig
|
||
DrawingIndexEdJig::DrawingIndexEdJig(AecXDbSymbDrawingIndex *pEnt, TCHAR *pszPormat, TCHAR *pszKeyWord) :
|
||
m_pEnt(pEnt),
|
||
m_ptCur(0, 0, 0),
|
||
m_ptLast(0, 0, 0),
|
||
m_pszPormat(pszPormat),
|
||
m_pszKeyWord(pszKeyWord)
|
||
{
|
||
}
|
||
|
||
DrawingIndexEdJig::~DrawingIndexEdJig()
|
||
{
|
||
|
||
}
|
||
|
||
AcEdJig::DragStatus DrawingIndexEdJig::doIt()
|
||
{
|
||
AcEdJig::DragStatus status = AcEdJig::kNull;
|
||
|
||
setDispPrompt(m_pszPormat);
|
||
|
||
try
|
||
{
|
||
status = drag();
|
||
}
|
||
catch (...)
|
||
{
|
||
status = AcEdJig::kCancel;
|
||
}
|
||
return status;
|
||
}
|
||
|
||
AcEdJig::DragStatus DrawingIndexEdJig::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 DrawingIndexEdJig::update()
|
||
{
|
||
m_pEnt->SetCenter(m_ptCur); //位置
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity *DrawingIndexEdJig::entity() const
|
||
{
|
||
return (m_pEnt);
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region IndexPointerEdJig
|
||
IndexPointerEdJig::IndexPointerEdJig(AecXDbSymbIndexPointer *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
m_pDlg = NULL;
|
||
}
|
||
|
||
void IndexPointerEdJig::InitCutLine()
|
||
{
|
||
ASSERT(m_pDrawEnt != NULL);
|
||
ASSERT(!m_pDrawEnt->IsIndexPointer());
|
||
|
||
m_pDrawEnt->GetCutLineAll(m_arCutAdded);
|
||
m_arCutAdded.RemoveAt(0); // 删除第一个。
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int IndexPointerEdJig::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 = SymbEdJig::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 IndexPointerEdJig::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 IndexPointerEdJig::update() // 更新实体数据
|
||
{
|
||
if ((m_pDlg != NULL) && (m_pDrawEnt != NULL))
|
||
{
|
||
if (m_pDlg->m_bDimOnExtent)
|
||
{
|
||
m_pDlg->UpdateData();
|
||
const double dMinLen = AecXDbSymbIndexPointer::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 = GlobalFunc::Wcs2Ucs(m_ptResult).x;
|
||
yi = GlobalFunc::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((GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(ptTemp).x)
|
||
* (GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(ptTemp).x)
|
||
+ (GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(ptTemp).y)
|
||
* (GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(ptTemp).y));
|
||
double d3 = atan2(GlobalFunc::Wcs2Ucs(m_ptResult).y - GlobalFunc::Wcs2Ucs(ptTemp).y,
|
||
GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::Wcs2Ucs(ptTemp).x);
|
||
double d2 = cos((m_dFixAngle / 180) * PI - d3);
|
||
double d = d1 * d2;
|
||
|
||
XPoint ptTurn;
|
||
ptTurn.y = GlobalFunc::Wcs2Ucs(ptTemp).y + d * sin((m_dFixAngle / 180) * PI);
|
||
ptTurn.x = GlobalFunc::Wcs2Ucs(ptTemp).x + d * cos((m_dFixAngle / 180) * PI);
|
||
m_pDrawEnt->SetTurnPoint(GlobalFunc::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 = GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::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(AecXDbSymbIndexPointer::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* IndexPointerEdJig::entity() const
|
||
{
|
||
return ((m_nOperCode == kSourceExtent) ? (AcDbEntity *)&m_drawEnt : (AcDbEntity *)m_pDrawEnt);
|
||
}
|
||
#pragma endregion
|
||
|
||
#pragma region ComposingEdJig
|
||
ComposingEdJig::ComposingEdJig(AecXDbSymbComposing *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
}
|
||
|
||
AcEdJig::DragStatus
|
||
ComposingEdJig::GetPoint(XPoint &pt)
|
||
{
|
||
XPoint ptBase = m_nOperCode == kTextLine ? m_pDrawEnt->GetTurnPoint() : m_pDrawEnt->GetStartPoint();
|
||
return acquirePoint(pt, ptBase);
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int ComposingEdJig::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 = SymbEdJig::DoIt(keyIndex);
|
||
return nRet;
|
||
}
|
||
|
||
// 更新实体数据,sg modify 081105
|
||
Adesk::Boolean ComposingEdJig::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 = GlobalFunc::Wcs2Ucs(m_ptResult).x - GlobalFunc::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 * GlobalFunc::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* ComposingEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
ComposingAddOtherPtJig::ComposingAddOtherPtJig(XPoint ptStart, XPoint ptBase)
|
||
{
|
||
m_ptLeader = ptBase.AsAcGePoint3d();
|
||
m_ptFirstVertexes = ptStart.AsAcGePoint3d();
|
||
m_line.setStartPoint(m_ptLeader);
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int ComposingAddOtherPtJig::DoIt(int *keyIndex)
|
||
{
|
||
return SymbEdJig::DoIt(keyIndex);
|
||
}
|
||
|
||
AcEdJig::DragStatus ComposingAddOtherPtJig::GetPoint(AcGePoint3d &pt)
|
||
{
|
||
// 自由拖拽,不受正交控制
|
||
return acquirePoint(pt);
|
||
}
|
||
|
||
Adesk::Boolean ComposingAddOtherPtJig::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* ComposingAddOtherPtJig::entity() const
|
||
{
|
||
return (AcDbEntity *)&m_line;
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region
|
||
#pragma endregion
|