1846 lines
47 KiB
C++
1846 lines
47 KiB
C++
#include "stdafx.h"
|
|
#include "ParkingAlterDlg.h"
|
|
#include "TDbParking.h"
|
|
|
|
extern XString InitCarBlock();
|
|
extern AcDbObjectId FormBlock(AcDbEntity* pEnt,XPoint &pt,AcDbObjectId &idlayer);
|
|
//单排布置车位时的编号
|
|
extern CString GetTextForSingle(CString &strPrefix, CString &strPostfix, BOOL bIsFirst, int &nNum, int &nNumLength);
|
|
//双排时布置车位的编号
|
|
extern CString GetTextForDouble(CString &strPrefix, CString &strPostfix, int &nTasksNum, int nNumLength);
|
|
extern int CutStrToPreAndnum(CString &strSerialNum, CString &strPrefix, CString &strPostFix, int* nNum);
|
|
extern void CutOutArc(TGGeCurveSegment &segSrc, TGGeCurveSegment &segRet, XPoint &ptOnArc, BOOL bIsFromSt);
|
|
namespace
|
|
{
|
|
enum DIrecRetCode
|
|
{
|
|
eAllIsArc,
|
|
eLeftStToEnd,
|
|
eRightStToEnd,
|
|
eLeftEndToSt,
|
|
eRightEndToSt,
|
|
eCancle
|
|
};
|
|
}
|
|
//编号数据
|
|
struct ParkingTextData
|
|
{
|
|
CString strSerialNum;
|
|
XPoint ptText;
|
|
double dTextHeight;
|
|
AcDbObjectId idText;
|
|
AcDbObjectId idTextStyle;
|
|
|
|
};
|
|
struct ParkingBlockData
|
|
{
|
|
XPoint ptBlockCenter;
|
|
AcDbObjectId idBlock;
|
|
};
|
|
struct ObliqueLineData
|
|
{
|
|
XPoly2D polyLine;
|
|
AcDbObjectId idLine;
|
|
};
|
|
struct PakingSegData
|
|
{
|
|
TGGeCurveSegment segPath;
|
|
BOOL bIsDoubleRow; //是否是双排
|
|
BOOL bIsLeft; //单排时车位与线的方位
|
|
CString strStartSerial; //连续车位的起始编号
|
|
CString strEndSerial; //双排车位的结束编号
|
|
int nParkingNum; //一组车位的单排车位个数
|
|
double dWidth; //车位宽度(基于弧布置的车位,dWidth为一个车位的弧长)
|
|
int nAngle;
|
|
double dDept;
|
|
int nTextLoc; //文字位置
|
|
double dTextHeight; //文字高度
|
|
int nStyle;
|
|
AcDbObjectId idTextStyle;
|
|
int nLeftQMode; //左边车位所在象限
|
|
int nRightQMode; //右边车位所在象限
|
|
BOOL BIsCCW;
|
|
};
|
|
struct OneParking
|
|
{
|
|
XPoly2D poly2D;
|
|
ParkingTextData stText;
|
|
BOOL bIsBelongTo; //是否与其他车位在同一线上
|
|
int m_nStyle; //车位样式
|
|
AcDbObjectId idPoly; //边线ID 用于删除实体
|
|
AcDbObjectId idSlashOrBlock; //斜线或图块Id
|
|
};
|
|
//转换弧度
|
|
int GetSettingAngle(double dAngle)
|
|
{
|
|
int nAngle = 0;
|
|
double dBugle = dAngle * 180 / PI;
|
|
nAngle = dAngle * 180 / PI;
|
|
if (abs(nAngle - dBugle) > 0.5)
|
|
{
|
|
nAngle += 1;
|
|
}
|
|
/*if (abs(dAngle - 0.5 * PI) < 1.0e-6)
|
|
{
|
|
nAngle = 90;
|
|
}
|
|
else if (abs(dAngle - (120 * PI / 180)) < 1.0e-6)
|
|
{
|
|
nAngle = 120;
|
|
}
|
|
else if (abs(dAngle - (60 *PI / 180)) < 1.0e-6)
|
|
{
|
|
nAngle = 60;
|
|
}
|
|
else if (abs(dAngle - 0.75 * PI) < 1.0e-6)
|
|
{
|
|
nAngle = 135;
|
|
}
|
|
else if (abs(dAngle - 0.25 * PI) < 1.0e-6)
|
|
{
|
|
nAngle = 45;
|
|
}
|
|
else if (abs(dAngle - 150 * PI / 180) < 1.0e-6)
|
|
{
|
|
nAngle = 150;
|
|
}
|
|
else if (abs(dAngle - 30 * PI / 180) < 1.0e-6)
|
|
{
|
|
nAngle = 30;
|
|
}*/
|
|
return nAngle;
|
|
}
|
|
//沿端点延长曲线
|
|
void ExtendArc(TGGeCurveSegment &seg, double dLength, BOOL bIsStTo)
|
|
{
|
|
XArc arc = seg.GetArc();
|
|
XPoint ptSt, ptEnd, ptCenter, ptThird;
|
|
double dRad, dChordLength;
|
|
dRad = arc.GetRadius();
|
|
double dAngle = abs(dLength) / dRad;
|
|
/*dAngle = 0.5 * (PI - dAngle);*/
|
|
dChordLength = 2 * dRad * cos(dAngle);
|
|
ptCenter = arc.GetCenterPt();
|
|
arc.GetStartPoint(ptSt);
|
|
arc.GetEndPoint(ptEnd);
|
|
AcGeVector3d vec;
|
|
if (bIsStTo)
|
|
{
|
|
vec = ptSt - ptCenter;
|
|
}
|
|
else
|
|
{
|
|
vec = ptEnd - ptCenter;
|
|
}
|
|
if (dLength > 0)
|
|
{
|
|
if (seg.GetBulge() > 0)
|
|
{
|
|
if (bIsStTo)
|
|
{
|
|
vec = vec.rotateBy(-dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
vec = vec.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bIsStTo)
|
|
{
|
|
vec = vec.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
vec = vec.rotateBy(-dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
}
|
|
ptThird = ptCenter + dRad * vec / vec.length();
|
|
if (bIsStTo)
|
|
{
|
|
XArc arcTemp(ptThird, ptSt, ptEnd);
|
|
TGGeCurveSegment segtemp;
|
|
segtemp = arcTemp;
|
|
if (seg.GetBulge() > 0)
|
|
{
|
|
seg = segtemp;
|
|
}
|
|
else
|
|
{
|
|
seg.SetStartPoint(ptThird);
|
|
seg.SetEndPoint(ptEnd);
|
|
seg.SetBulge(-segtemp.GetBulge());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
XArc arcTemp(ptSt, ptEnd, ptThird);
|
|
TGGeCurveSegment segtemp;
|
|
segtemp = arcTemp;
|
|
if (seg.GetBulge() > 0)
|
|
{
|
|
seg = segtemp;
|
|
}
|
|
else
|
|
{
|
|
seg.SetStartPoint(ptSt);
|
|
seg.SetEndPoint(ptThird);
|
|
seg.SetBulge(-segtemp.GetBulge());
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (seg.GetBulge() > 0)
|
|
{
|
|
if (bIsStTo)
|
|
{
|
|
vec = vec.rotateBy(-dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
vec = vec.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bIsStTo)
|
|
{
|
|
vec = vec.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
vec = vec.rotateBy(-dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
}
|
|
ptThird = ptCenter + dRad * vec / vec.length();
|
|
if (bIsStTo)
|
|
{
|
|
TGGeCurveSegment segTemp = seg;
|
|
CutOutArc(segTemp, seg, ptThird, FALSE);
|
|
|
|
}
|
|
else
|
|
{
|
|
TGGeCurveSegment segTemp = seg;
|
|
CutOutArc(segTemp, seg, ptThird, TRUE);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
//沿弧布置车位时,一个车位的弧长
|
|
double GetOneParkingArcLength(XArc &arc, double dWidth, double dDept, BOOL bIsInside)
|
|
{
|
|
double dArcLength = 0;
|
|
double dRad = arc.GetRadius();
|
|
if (bIsInside)
|
|
{
|
|
AcDbArc *pArc = new AcDbArc(arc.GetCenterPt(), arc.GetRadius(), arc.GetStarAngle(), arc.GetEndAngle());
|
|
TADSGePoint3d ptStart;
|
|
pArc->getStartPoint(ptStart);
|
|
TADSGePoint3d ptEnd;
|
|
pArc->getEndPoint(ptEnd);
|
|
double dMax = ptStart.AsAcGePoint3d().distanceTo(ptEnd);
|
|
TADSGePoint3d ptCenter = pArc->center();
|
|
TADSGePoint3d ptVertex1 = ptStart;
|
|
TADSGePoint3d ptVertex2;
|
|
TADSGePoint3d ptVertex3;
|
|
TADSGePoint3d ptVertex4;
|
|
for (int i=dWidth; i<(int)dMax; i++)
|
|
{
|
|
pArc->getPointAtDist(i,ptVertex2);
|
|
XLine lineBase(ptVertex1,ptVertex2);
|
|
ads_real rAng = lineBase.Direction();
|
|
ads_point pt1;
|
|
ads_point pt2;
|
|
acutPolar(ptVertex1,(rAng+0.5*PI),dDept,pt1);
|
|
acutPolar(ptVertex2,(rAng+0.5*PI),dDept,pt2);
|
|
|
|
XLine line1(pt1,pt2);
|
|
XLine line3(ptCenter,ptVertex2);
|
|
XLine line4(ptCenter,ptVertex1);
|
|
line1.Intersection(&line3,ptVertex3);
|
|
line1.Intersection(&line4,ptVertex4);
|
|
//离散计算
|
|
if (fabs(ptVertex3.AsAcGePoint3d().distanceTo(ptVertex4) - dWidth) < 1 )
|
|
{
|
|
AcGeVector3d v1 = ptVertex1 - pArc->center();
|
|
AcGeVector3d v2 = ptVertex2 - pArc->center();
|
|
dArcLength = v1.angleTo(v2) * dRad;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dArcLength = dWidth;
|
|
}
|
|
return dArcLength;
|
|
|
|
}
|
|
|
|
void AddSerialNumForArc(XPoint &ptCenter, TDbParking &dbPark, CString &strSerialNum, PakingSegData* pSegData)
|
|
{
|
|
XPoint ptText = dbPark.GetPtText();
|
|
double angle = ads_angle(XPoint(ptCenter), XPoint(ptText));
|
|
if (ptText.y < ptCenter.y)
|
|
angle += 0.5 * PI;
|
|
else
|
|
angle -= 0.5 * PI;
|
|
TDbText* text = new TDbText;
|
|
text->SetText(strSerialNum);
|
|
text->SetHeight(pSegData->dTextHeight);
|
|
text->SetRotation(angle);
|
|
text->SetLocation(dbPark.GetPtText());
|
|
if (pSegData->idTextStyle.isValid())
|
|
text->SetStyleId(pSegData->idTextStyle);
|
|
else
|
|
text->SetStyleId(acdbCurDwg()->textstyle());
|
|
text->setLayer(::InitLayer(LAY_PKNG_SING));
|
|
text->SetAlignment(XExplodeDraw::kMiddleCenter);
|
|
AddToCurrentSpace(text, Adesk::kTrue);
|
|
}
|
|
|
|
void AddSerialNum(TDbParking &dbPark, CString &strSerialNum, AcGeVector3d &VectorOffet, PakingSegData *pSegData, int nSize = 1)
|
|
{
|
|
AcGeVector3d vec = AcGeVector3d(1, 0, 0);
|
|
TDbText* text = new TDbText;
|
|
text->SetText(strSerialNum);
|
|
text->SetHeight(pSegData->dTextHeight);
|
|
int nAngle = pSegData->nAngle;
|
|
double dangle = vec.angleTo(VectorOffet);
|
|
if (pSegData->dWidth > pSegData->dDept)
|
|
{
|
|
if ((vec.angleTo(VectorOffet) > 0.5 * PI))
|
|
{
|
|
if (nSize == -1)
|
|
{
|
|
if (nAngle == 90)
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle());
|
|
}
|
|
else
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + PI);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nAngle == 90)
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + PI);
|
|
}
|
|
else
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + PI);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nSize == -1)
|
|
{
|
|
if (nAngle == 90)
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + PI);
|
|
}
|
|
else
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nAngle == 90)
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle());
|
|
}
|
|
else
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle());
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((vec.angleTo(VectorOffet) > 0.5 * PI))
|
|
{
|
|
if (nSize == -1)
|
|
{
|
|
if (nAngle == 90)
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle());
|
|
}
|
|
else
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + PI + nAngle*PI/180);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nAngle == 90)
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + PI);
|
|
}
|
|
else
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + PI + (90 - nAngle)*PI/180);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nSize == -1)
|
|
{
|
|
if (nAngle == 90)
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + PI);
|
|
}
|
|
else
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + nAngle*PI/180);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nAngle == 90)
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle());
|
|
}
|
|
else
|
|
{
|
|
text->SetRotation(dbPark.GetRotAngle() + (90 - nAngle)*PI/180);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
text->SetLocation(dbPark.GetPtText());
|
|
if (pSegData->idTextStyle.isValid())
|
|
text->SetStyleId(pSegData->idTextStyle);
|
|
else
|
|
text->SetStyleId(acdbCurDwg()->textstyle());
|
|
text->setLayer(::InitLayer(LAY_PKNG_SING));
|
|
text->SetAlignment(XExplodeDraw::kMiddleCenter);
|
|
AddToCurrentSpace(text, Adesk::kTrue);
|
|
}
|
|
void GetParkInfo(AcGeVector3d &outVector,int &ioutNum,double &doutAngl,
|
|
TGGeCurveSegment &segBase,int angle, double iWidth, double iHeight,int iSize,int iIndex)
|
|
{
|
|
AcGeVector3d vec(0,0,0);
|
|
double dRoateAngle = 0;
|
|
int iNum = 0;
|
|
if (segBase.GetLength() < 0)
|
|
{
|
|
return ;
|
|
}
|
|
//圆弧
|
|
if (abs(segBase.GetBulge()) > 1.0e-6)
|
|
{
|
|
XArc arc = segBase.GetArc();
|
|
//圆弧外侧
|
|
AcDbArc* pArc = new AcDbArc(arc.GetCenterPt(), arc.GetRadius(), arc.GetStarAngle(), arc.GetEndAngle());
|
|
if (iSize == -1)
|
|
{
|
|
TADSGePoint3d ptVertex1;
|
|
pArc->getStartPoint(ptVertex1);
|
|
TADSGePoint3d ptVertex2;
|
|
pArc->getPointAtDist(iWidth,ptVertex2);
|
|
vec = ptVertex2 - ptVertex1;
|
|
|
|
TADSGePoint3d ptEnd;
|
|
pArc->getEndPoint(ptEnd);
|
|
AcGeVector3d v1 = ptVertex1 - pArc->center();
|
|
AcGeVector3d v2 = ptVertex2 - pArc->center();
|
|
AcGeVector3d v3 = ptEnd - pArc->center();
|
|
|
|
dRoateAngle = v1.angleTo(v2);
|
|
iNum = v1.angleTo(v3)/dRoateAngle;
|
|
}
|
|
//圆弧内侧
|
|
else if (iSize == 1)
|
|
{
|
|
TADSGePoint3d ptStart;
|
|
pArc->getStartPoint(ptStart);
|
|
TADSGePoint3d ptEnd;
|
|
pArc->getEndPoint(ptEnd);
|
|
double dMax = ptStart.AsAcGePoint3d().distanceTo(ptEnd);
|
|
TADSGePoint3d ptCenter = pArc->center();
|
|
|
|
TADSGePoint3d ptVertex1 = ptStart;
|
|
TADSGePoint3d ptVertex2;
|
|
TADSGePoint3d ptVertex3;
|
|
TADSGePoint3d ptVertex4;
|
|
for (int i=iWidth; i<(int)dMax; i++)
|
|
{
|
|
pArc->getPointAtDist(i,ptVertex2);
|
|
XLine lineBase(ptVertex1,ptVertex2);
|
|
ads_real rAng = lineBase.Direction();
|
|
ads_point pt1;
|
|
ads_point pt2;
|
|
acutPolar(ptVertex1,(rAng+iSize*0.5*PI),iHeight,pt1);
|
|
acutPolar(ptVertex2,(rAng+iSize*0.5*PI),iHeight,pt2);
|
|
|
|
XLine line1(pt1,pt2);
|
|
XLine line3(ptCenter,ptVertex2);
|
|
XLine line4(ptCenter,ptVertex1);
|
|
line1.Intersection(&line3,ptVertex3);
|
|
line1.Intersection(&line4,ptVertex4);
|
|
//离散计算
|
|
if (fabs(ptVertex3.AsAcGePoint3d().distanceTo(ptVertex4) - iWidth) < 1 )
|
|
{
|
|
vec = ptVertex2 - ptVertex1;
|
|
|
|
AcGeVector3d v1 = ptVertex1 - pArc->center();
|
|
AcGeVector3d v2 = ptVertex2 - pArc->center();
|
|
AcGeVector3d v3 = ptEnd - pArc->center();
|
|
|
|
dRoateAngle = v1.angleTo(v2);
|
|
iNum = v1.angleTo(v3)/dRoateAngle;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TADSGePoint3d ptStart;
|
|
ptStart = segBase.GetStartPoint();
|
|
TADSGePoint3d ptEnd;
|
|
ptEnd = segBase.GetEndPoint();
|
|
XLine lineBase(ptStart,ptEnd);
|
|
ads_real rAngBase = lineBase.Direction();
|
|
|
|
ads_point ptads4;
|
|
acutPolar(ptStart,(rAngBase + angle * PI / 180),iHeight,ptads4);
|
|
TADSGePoint3d ptVertex4 = ptads4;
|
|
|
|
TADSGePoint3d ptVertex2;
|
|
ads_point pt20;
|
|
ads_point pt30;
|
|
XLine line14(ptStart,ptVertex4);
|
|
ads_real rAng14 = line14.Direction();
|
|
acutPolar(ptStart,(rAng14-0.5 * PI),iWidth,pt20);
|
|
acutPolar(ptVertex4,(rAng14-0.5 * PI),iWidth,pt30);
|
|
XLine line23(pt20,pt30);
|
|
ads_point pt2;
|
|
acutPolar(ptStart,(rAngBase),100,pt2);
|
|
XLine line2(ptStart,pt2);
|
|
line23.Intersection(&line2,ptVertex2);
|
|
|
|
vec = ptVertex2 - ptStart;
|
|
double d = vec.length();
|
|
double dLength = (ptStart.AsAcGePoint3d().distanceTo(ptEnd));
|
|
iNum = (ptStart.AsAcGePoint3d().distanceTo(ptEnd))/vec.length();
|
|
}
|
|
outVector = vec;
|
|
ioutNum = iNum;
|
|
doutAngl = dRoateAngle;
|
|
}
|
|
//将边线、斜线、图块、编号归并到各个车位
|
|
void AnalysisParkingToGroup(TDPtrList<ObliqueLineData> &lstPoly, TDPtrList<ObliqueLineData> &lstSingleSlash, TDPtrList<ObliqueLineData> &lstDoubleSlash, TDPtrList<ParkingBlockData> &lstPtBlock, TDPtrList<ParkingTextData> &lstText, TDPtrList<OneParking> &lstParking, double length)
|
|
{
|
|
for (int i = 0; i < lstPoly.Length(); ++i)
|
|
{
|
|
double dDept = 0;
|
|
ObliqueLineData* lineData;
|
|
XPoint ptSt, ptEnd, ptMid;
|
|
XPoly2D polyFrame;
|
|
lineData = lstPoly.GetAt(i);
|
|
/*if (lineData->idLine.isValid())
|
|
{
|
|
OPENOBJ_BEGIN(lineData->idLine, AcDb::kForWrite, AcDbPolyline, pPoly)
|
|
if (pPoly)
|
|
{
|
|
pParkingData->idPoly = pPoly->objectId();
|
|
}
|
|
OPENOBJ_END()
|
|
}*/
|
|
polyFrame = lineData->polyLine;
|
|
OneParking* pParkingData = new OneParking;
|
|
pParkingData->m_nStyle = 0;
|
|
pParkingData->poly2D = polyFrame;
|
|
pParkingData->bIsBelongTo = FALSE;
|
|
pParkingData->m_nStyle = 0;
|
|
pParkingData->idPoly = lineData->idLine;
|
|
ptSt = *polyFrame.GetPointListAt(0);
|
|
ptEnd = *polyFrame.GetPointListAt(1);
|
|
dDept = ptEnd.Distance(*polyFrame.GetPointListAt(2));
|
|
dDept = dDept + 0.8 * length * DocGetPScale();
|
|
XLine line(ptSt, ptEnd);
|
|
AcGeVector3d vec;
|
|
AcGeVector3d vecText;
|
|
if (abs(polyFrame.GetPointListAt(0)->Distance(*polyFrame.GetPointListAt(1)) - polyFrame.GetPointListAt(2)->Distance(*polyFrame.GetPointListAt(3))) > 1.0e-6)
|
|
{
|
|
vec = ptEnd - ptSt;
|
|
if (line.OnWhichSide(*polyFrame.GetPointListAt(2)))
|
|
{
|
|
vec = vec.rotateBy(-0.5 * PI, AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
vec = vec.rotateBy(0.5 * PI, AcGeVector3d::kZAxis);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
vec = *polyFrame.GetPointListAt(2) - *polyFrame.GetPointListAt(1);
|
|
vecText = ptEnd - ptSt;
|
|
if (line.OnWhichSide(*polyFrame.GetPointListAt(2)))
|
|
{
|
|
vecText = vecText.rotateBy(-0.5 * PI, AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
vecText = vecText.rotateBy(0.5 * PI, AcGeVector3d::kZAxis);
|
|
}
|
|
}
|
|
ptMid = line.MidPoint();
|
|
XLine lineMid(ptMid, ptMid + dDept * vec / vec.length());
|
|
XLine line34(*polyFrame.GetPointListAt(2), *polyFrame.GetPointListAt(3));
|
|
XLine lineText(line34.MidPoint(), line34.MidPoint() + 0.8 * length * DocGetPScale() * vecText / vecText.length());
|
|
for (int k = 0; k < lstText.Length(); ++k)
|
|
{
|
|
ParkingTextData stText;
|
|
stText = *lstText.GetAt(k);
|
|
int nFlag = lineMid.HitTest2d(stText.ptText);
|
|
int nTextFlag = lineText.HitTest2d(stText.ptText);
|
|
if (((nFlag >= 3) && (nFlag <= 5)) || ((nTextFlag == 5) || (nTextFlag == 7) || (nTextFlag == 4)))
|
|
{
|
|
/*if (stText.idText.isValid())
|
|
{
|
|
AcDbEntity* pEntity;
|
|
OPENOBJ_BEGIN(stText.idText, AcDb::kForWrite, AcDbEntity, pEntity)
|
|
if (pEntity)
|
|
{
|
|
pEntity->erase();
|
|
}
|
|
OPENOBJ_END()
|
|
}*/
|
|
pParkingData->stText = stText;
|
|
break;
|
|
}
|
|
}
|
|
for (int i = 0; i < lstSingleSlash.Length(); i++)
|
|
{
|
|
ObliqueLineData slashData = *lstSingleSlash.GetAt(i);
|
|
XPoly2D polySlash = slashData.polyLine;
|
|
TGGeCurveSegment seg;
|
|
polySlash.Nth(0, seg);
|
|
ptMid = seg.MidPoint();
|
|
int nFlag = lineMid.HitTest2d(ptMid);
|
|
if (lineMid.HitTest2d(ptMid) == 5)
|
|
{
|
|
/*if (slashData.idLine.isValid())
|
|
{
|
|
OPENOBJ_BEGIN(slashData.idLine, AcDb::kForWrite, AcDbPolyline, pPoly)
|
|
if (pPoly)
|
|
{
|
|
pPoly->erase();
|
|
}
|
|
OPENOBJ_END()
|
|
}*/
|
|
pParkingData->m_nStyle = 1;
|
|
pParkingData->idSlashOrBlock = slashData.idLine;
|
|
lstSingleSlash.Remove(i);
|
|
break;
|
|
}
|
|
}
|
|
XLine lineHead(*polyFrame.GetPointListAt(2), *polyFrame.GetPointListAt(3));
|
|
for (int i = 0; i < lstDoubleSlash.Length(); i++)
|
|
{
|
|
ObliqueLineData slashData = *lstDoubleSlash.GetAt(i);
|
|
XPoly2D polySlash = slashData.polyLine;
|
|
int nFlag = lineHead.HitTest2d(*polySlash.GetPointListAt(1));
|
|
if (lineHead.HitTest2d(*polySlash.GetPointListAt(1)) == 5)
|
|
{
|
|
/*if (slashData.idLine.isValid())
|
|
{
|
|
OPENOBJ_BEGIN(slashData.idLine, AcDb::kForWrite, AcDbPolyline, pPoly)
|
|
if (pPoly)
|
|
{
|
|
pPoly->erase();
|
|
}
|
|
OPENOBJ_END()
|
|
} */
|
|
pParkingData->m_nStyle = 2;
|
|
pParkingData->idSlashOrBlock = slashData.idLine;
|
|
lstDoubleSlash.Remove(i);
|
|
break;
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < lstPtBlock.Length(); i++)
|
|
{
|
|
ParkingBlockData pStblockData = *lstPtBlock.GetAt(i);
|
|
if ((lineMid.HitTest2d(pStblockData.ptBlockCenter) == 5))
|
|
{
|
|
/*if (pStblockData.idBlock.isValid())
|
|
{
|
|
OPENOBJ_BEGIN(pStblockData.idBlock, AcDb::kForWrite, AcDbBlockReference, pBlock)
|
|
if (pBlock)
|
|
{
|
|
pBlock->erase();
|
|
}
|
|
OPENOBJ_END()
|
|
} */
|
|
pParkingData->m_nStyle = 3;
|
|
pParkingData->idSlashOrBlock = pStblockData.idBlock;
|
|
lstPtBlock.Remove(i);
|
|
break;
|
|
}
|
|
}
|
|
lstParking.Append(pParkingData);
|
|
}
|
|
}
|
|
void DrawParkingForArc(PakingSegData* pSegData, double dWidth, double dDept, XString &sBlockName, AcDbObjectId &idlayer)
|
|
{
|
|
AcGeVector3d baseVector(AcGeVector3d(0,0,0));
|
|
int iNum = 0;
|
|
double dAngl = 0, dOffset = 0;
|
|
BOOL bIsDrawText = FALSE;
|
|
XArc arc = pSegData->segPath.GetArc();
|
|
if (!pSegData->strStartSerial.IsEmpty())
|
|
{
|
|
bIsDrawText = TRUE;
|
|
}
|
|
if (bIsDrawText)
|
|
{
|
|
switch (pSegData->nTextLoc)
|
|
{
|
|
case 0:
|
|
dOffset = /*dDept*/ + 0.8 * pSegData->dTextHeight * DocGetPScale();
|
|
break;
|
|
case 1:
|
|
dOffset = /*dDept */- 0.8 * pSegData->dTextHeight * DocGetPScale();
|
|
break;
|
|
case 2:
|
|
dOffset = -0.5 * dDept;
|
|
break;
|
|
}
|
|
}
|
|
CString strPrefix, strPostfix, strNum;
|
|
int nNumLength, nStNum, nEndNum, nTasksNum, nDoubleMax;
|
|
BOOL bIsFirst = TRUE;
|
|
if (bIsDrawText)
|
|
{
|
|
bIsDrawText = TRUE;
|
|
nNumLength = CutStrToPreAndnum(pSegData->strStartSerial, strPrefix, strPostfix, &nStNum);
|
|
if (!pSegData->strEndSerial.IsEmpty())
|
|
{
|
|
CString str1, str2;
|
|
CutStrToPreAndnum(pSegData->strEndSerial, str1, str2, &nTasksNum);
|
|
}
|
|
}
|
|
XPoint ptStart, ptCenter;
|
|
ptStart= pSegData->segPath.GetStartPoint();
|
|
ptCenter = arc.GetCenterPt();
|
|
//弧双排
|
|
if(pSegData->bIsDoubleRow)
|
|
{
|
|
|
|
GetParkInfo(baseVector,iNum,dAngl,pSegData->segPath,pSegData->nAngle,dWidth,dDept,1,0);
|
|
if (bIsDrawText)
|
|
{
|
|
if (!pSegData->strEndSerial.IsEmpty())
|
|
{
|
|
CString str1, str2;
|
|
CutStrToPreAndnum(pSegData->strEndSerial, str1, str2, &nTasksNum);
|
|
}
|
|
else
|
|
{
|
|
nTasksNum = iNum + nStNum;
|
|
}
|
|
}
|
|
|
|
for (int i=0;i<iNum;i++)
|
|
{
|
|
TDbParking *pParking = new TDbParking(sBlockName);
|
|
pParking->SetTextOffset(dOffset);
|
|
pParking->Fill(ptCenter, ptStart,baseVector,dWidth,dDept,1,pSegData->nStyle);
|
|
ptStart+=baseVector;
|
|
if (bIsDrawText)
|
|
{
|
|
AddSerialNumForArc(ptCenter, *pParking, GetTextForSingle(strPrefix, strPostfix, bIsFirst, nStNum, nNumLength), pSegData);
|
|
bIsFirst = FALSE;
|
|
}
|
|
|
|
baseVector.rotateBy(dAngl,AcGeVector3d(0,0,1));
|
|
XPoint pt = pParking->GetBasePt();
|
|
AcDbObjectId id = FormBlock(pParking,pt,idlayer);
|
|
}
|
|
|
|
ptStart= pSegData->segPath.GetStartPoint();
|
|
GetParkInfo(baseVector,iNum,dAngl,pSegData->segPath,pSegData->nAngle,dWidth,dDept,-1,0);
|
|
|
|
if (bIsDrawText)
|
|
{
|
|
if (pSegData->strEndSerial.IsEmpty())
|
|
{
|
|
nTasksNum = nTasksNum + iNum;
|
|
nDoubleMax = nTasksNum + 1;
|
|
}
|
|
}
|
|
for (int j=0;j<iNum;j++)
|
|
{
|
|
TDbParking *pParking = new TDbParking(sBlockName);
|
|
pParking->SetTextOffset(dOffset);
|
|
pParking->Fill(ptCenter, ptStart,baseVector,dWidth,dDept,-1,pSegData->nStyle);
|
|
ptStart+=baseVector;
|
|
if (bIsDrawText)
|
|
{
|
|
CString strTemp = strPrefix;
|
|
AddSerialNumForArc(ptCenter, *pParking, GetTextForDouble(strTemp, strPostfix, nTasksNum, nNumLength), pSegData);
|
|
bIsFirst = FALSE;
|
|
if (j == iNum - 1)
|
|
{
|
|
pSegData->strStartSerial = GetTextForDouble(strTemp, strPostfix, nDoubleMax, nNumLength);
|
|
}
|
|
}
|
|
baseVector.rotateBy(dAngl,AcGeVector3d(0,0,1));
|
|
XPoint pt = pParking->GetBasePt();
|
|
AcDbObjectId id = FormBlock(pParking,pt,idlayer);
|
|
}
|
|
}
|
|
//弧单排
|
|
else
|
|
{
|
|
int iSize = 1;
|
|
if (pSegData->BIsCCW)
|
|
{
|
|
if (!pSegData->bIsLeft)
|
|
{
|
|
iSize = -1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!pSegData->bIsLeft)
|
|
{
|
|
iSize = -1;
|
|
}
|
|
}
|
|
|
|
GetParkInfo(baseVector,iNum,dAngl,pSegData->segPath,pSegData->nAngle,dWidth,dDept,iSize,0);
|
|
for (int i=0;i<iNum;i++)
|
|
{
|
|
TDbParking *pParking = new TDbParking(sBlockName);
|
|
pParking->SetTextOffset(dOffset);
|
|
pParking->Fill(ptCenter,TADSGePoint3d(ptStart),baseVector,dWidth,dDept,iSize,pSegData->nStyle);
|
|
ptStart+=baseVector;
|
|
if (bIsDrawText)
|
|
{
|
|
AddSerialNumForArc(ptCenter, *pParking, GetTextForSingle(strPrefix, strPostfix, bIsFirst, nStNum, nNumLength), pSegData);
|
|
if (i == iNum - 1)
|
|
{
|
|
pSegData->strStartSerial = GetTextForSingle(strPrefix, strPostfix, bIsFirst, nStNum, nNumLength);
|
|
}
|
|
bIsFirst = FALSE;
|
|
}
|
|
baseVector.rotateBy(dAngl,AcGeVector3d(0,0,1));
|
|
XPoint pt = pParking->GetBasePt();
|
|
AcDbObjectId id = FormBlock(pParking,pt,idlayer);
|
|
}
|
|
|
|
}
|
|
}
|
|
void DrawParkingForLine(PakingSegData* pSegData, double dWidth, double dDept, XString &sBlockName, AcDbObjectId &idlayer)
|
|
{
|
|
AcGeVector3d baseVector(AcGeVector3d(0,0,0));
|
|
int iNum = 0;
|
|
double dAngl = 0, dOffset = 0;
|
|
BOOL bIsDrawText = FALSE;
|
|
//直线段单排
|
|
if (!pSegData->strStartSerial.IsEmpty())
|
|
{
|
|
bIsDrawText = TRUE;
|
|
}
|
|
if (bIsDrawText)
|
|
{
|
|
switch (pSegData->nTextLoc)
|
|
{
|
|
case 0:
|
|
dOffset = /*dDept +*/ 0.8 * pSegData->dTextHeight * DocGetPScale();
|
|
break;
|
|
case 1:
|
|
dOffset = /*dDept*/ - 0.8 * pSegData->dTextHeight * DocGetPScale();
|
|
break;
|
|
case 2:
|
|
dOffset = -0.5 * dDept;
|
|
break;
|
|
}
|
|
}
|
|
CString strPrefix, strPostfix, strNum;
|
|
int nNumLength, nStNum, nEndNum, nTasksNum, nDoubleMax;
|
|
BOOL bIsFirst = TRUE;
|
|
nNumLength = CutStrToPreAndnum(pSegData->strStartSerial, strPrefix, strPostfix, &nStNum);
|
|
if(!pSegData->bIsDoubleRow)
|
|
{
|
|
|
|
XPoint ptStart, ptend;
|
|
ptStart = pSegData->segPath.GetStartPoint();
|
|
ptend = pSegData->segPath.GetEndPoint();
|
|
XLine line(ptStart, ptend);
|
|
GetParkInfo(baseVector,iNum,dAngl,pSegData->segPath,pSegData->nAngle,dWidth,dDept,1,0);
|
|
|
|
//哪一侧
|
|
int iSize = 1;
|
|
if (!pSegData->bIsLeft)
|
|
{
|
|
iSize = -1;
|
|
}
|
|
for(int i=0;i<iNum;i++)
|
|
{
|
|
TDbParking *pParking = new TDbParking(sBlockName);
|
|
pParking->SetTextOffset(dOffset);
|
|
pParking->Fill(TADSGePoint3d((ptStart+i*baseVector)),baseVector,pSegData->nAngle,dWidth,dDept,1,pSegData->nStyle,pSegData->nLeftQMode);
|
|
XPoint pt = pParking->GetBasePt();
|
|
if (bIsDrawText)
|
|
{
|
|
AddSerialNum(*pParking, GetTextForSingle(strPrefix, strPostfix, bIsFirst, nStNum, nNumLength), baseVector, pSegData, iSize);
|
|
if (i == iNum - 1)
|
|
{
|
|
pSegData->strStartSerial = GetTextForSingle(strPrefix, strPostfix, bIsFirst, nStNum, nNumLength);
|
|
}
|
|
bIsFirst = FALSE;
|
|
}
|
|
AcDbObjectId id = FormBlock(pParking,pt,idlayer);
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
AcGePoint3d ptStart;
|
|
ptStart = pSegData->segPath.GetStartPoint();
|
|
GetParkInfo(baseVector,iNum,dAngl,pSegData->segPath,pSegData->nAngle,dWidth,dDept,1,0);
|
|
if (bIsDrawText)
|
|
{
|
|
CString str1, str2;
|
|
if (!pSegData->strEndSerial.IsEmpty())
|
|
{
|
|
CutStrToPreAndnum(pSegData->strEndSerial, str1, str2, &nTasksNum);
|
|
}
|
|
else
|
|
{
|
|
nTasksNum = nStNum + 2 * iNum - 1;
|
|
nDoubleMax = nTasksNum + 1;
|
|
}
|
|
}
|
|
for(int i=0;i<iNum;i++)
|
|
{
|
|
TDbParking *pParking = new TDbParking(sBlockName);
|
|
pParking->SetTextOffset(dOffset);
|
|
pParking->Fill(TADSGePoint3d((ptStart+i*baseVector)),baseVector,pSegData->nAngle,dWidth,dDept,1,pSegData->nStyle,pSegData->nLeftQMode);
|
|
XPoint pt = pParking->GetBasePt();
|
|
if (bIsDrawText)
|
|
{
|
|
AddSerialNum(*pParking, GetTextForSingle(strPrefix, strPostfix, bIsFirst, nStNum, nNumLength), baseVector, pSegData);
|
|
}
|
|
AcDbObjectId id = FormBlock(pParking,pt,idlayer);
|
|
TDbParking *pParking1 = new TDbParking(sBlockName);
|
|
pParking1->SetTextOffset(dOffset);
|
|
pParking1->Fill(TADSGePoint3d((ptStart+i*baseVector)),baseVector,pSegData->nAngle,dWidth,dDept,1,pSegData->nStyle,pSegData->nRightQMode);
|
|
XPoint pt1 = pParking1->GetBasePt();
|
|
CString strTemp = strPrefix;
|
|
if (bIsDrawText)
|
|
{
|
|
AddSerialNum(*pParking1, GetTextForDouble(strTemp, strPostfix, nTasksNum, nNumLength), baseVector, pSegData);
|
|
if (i == iNum - 1)
|
|
{
|
|
pSegData->strStartSerial = GetTextForDouble(strTemp, strPostfix, nDoubleMax, nNumLength);
|
|
}
|
|
}
|
|
AcDbObjectId id1 = FormBlock(pParking1,pt1,idlayer);
|
|
bIsFirst = FALSE;
|
|
}
|
|
}
|
|
}
|
|
void ChangeParking(CParkingAlterDlg* pDlg, TDPtrList<PakingSegData> &lstSegParking, DIrecRetCode eChangeDirec)
|
|
{
|
|
AcDbObjectId idLayer = InitLayer(LAY_PKNG_TSRP);
|
|
XString sName = InitCarBlock();
|
|
double dWidth = 0, dDept = 0;
|
|
XPoint ptSt, ptEnd;
|
|
double dMoveLength = 0;
|
|
CString strSerial = _T("");
|
|
if (pDlg->IsRefromSerial())
|
|
{
|
|
strSerial = pDlg->GetStartSerialNum();
|
|
}
|
|
for (int i = 0; i < lstSegParking.Length(); ++i)
|
|
{
|
|
PakingSegData* pSegData = lstSegParking.GetAt(i);
|
|
dWidth = pSegData->dWidth;
|
|
dDept = pSegData->dDept;
|
|
if (!strSerial.IsEmpty())
|
|
{
|
|
if (pSegData->strStartSerial.IsEmpty())
|
|
{
|
|
if (DocGetMeterUnitDraw())
|
|
{
|
|
pSegData->dTextHeight = 1;
|
|
}
|
|
else
|
|
{
|
|
pSegData->dTextHeight = 10;
|
|
}
|
|
pSegData->nTextLoc = 0;
|
|
}
|
|
pSegData->strStartSerial = strSerial;
|
|
pSegData->strEndSerial = _T("");
|
|
}
|
|
if (pDlg->IsChangeDept())
|
|
{
|
|
dDept = pDlg->GetParkingDept();
|
|
}
|
|
if (pDlg->IsResetSerial())
|
|
{
|
|
pSegData->nTextLoc = pDlg->SerialLoc();
|
|
}
|
|
if (pDlg->IsChangeWidth())
|
|
{
|
|
|
|
if (abs(pSegData->segPath.GetBulge()) > 1.0e-6)
|
|
{
|
|
double dLength;
|
|
if (pSegData->bIsLeft)
|
|
{
|
|
dLength = GetOneParkingArcLength(pSegData->segPath.GetArc(), pDlg->GetParkingWidth(), dDept, TRUE);
|
|
}
|
|
else
|
|
{
|
|
dLength = GetOneParkingArcLength(pSegData->segPath.GetArc(), pDlg->GetParkingWidth(), dDept, FALSE);
|
|
}
|
|
dMoveLength = 0.5 * (dLength - pSegData->dWidth) * pSegData->nParkingNum;
|
|
}
|
|
else
|
|
{
|
|
dWidth = pDlg->GetParkingWidth() / sin(pSegData->nAngle * PI / 180);
|
|
dMoveLength = 0.5 * (dWidth - pSegData->dWidth) * pSegData->nParkingNum;
|
|
}
|
|
pSegData->dWidth = pDlg->GetParkingWidth();
|
|
}
|
|
|
|
if (abs(pSegData->segPath.GetBulge()) > 1.0e-6)
|
|
{
|
|
if (pDlg->IsChangeWidth())
|
|
{
|
|
if (pDlg->WidthChangeDirec())
|
|
{
|
|
if ((eChangeDirec == eLeftStToEnd) || (eChangeDirec == eRightStToEnd))
|
|
{
|
|
ExtendArc(pSegData->segPath, 2 * dMoveLength + 0.5 * dWidth, FALSE);
|
|
}
|
|
else
|
|
{
|
|
ExtendArc(pSegData->segPath, 2 * dMoveLength + 0.5 * dWidth, TRUE);
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ExtendArc(pSegData->segPath, dMoveLength, TRUE);
|
|
ExtendArc(pSegData->segPath, dMoveLength + 0.5 * dWidth, FALSE);
|
|
}
|
|
}
|
|
if (pDlg->IsChangeDept())
|
|
{
|
|
if (pDlg->DeptChangeDirec())
|
|
{
|
|
if (!pSegData->bIsDoubleRow)
|
|
{
|
|
if ((eChangeDirec == eLeftStToEnd) || (eChangeDirec == eLeftEndToSt))
|
|
{
|
|
if (!pSegData->bIsLeft)
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(-(dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset((dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((eChangeDirec == eLeftStToEnd) || (eChangeDirec == eLeftEndToSt))
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(-(dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
else
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset((dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((eChangeDirec == eLeftStToEnd) || (eChangeDirec == eLeftEndToSt))
|
|
{
|
|
if (!pSegData->bIsLeft)
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(-0.5 * (dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
else
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(0.5 * (dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(0.5 * (dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
else
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(-0.5 * (dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
DrawParkingForArc(pSegData, pDlg->GetParkingWidth(), dDept, sName, idLayer);
|
|
}
|
|
else
|
|
{
|
|
ptSt = pSegData->segPath.GetStartPoint();
|
|
ptEnd = pSegData->segPath.GetEndPoint();
|
|
AcGeVector3d vec = ptEnd - ptSt;
|
|
if (pDlg->IsChangeWidth())
|
|
{
|
|
if (pDlg->WidthChangeDirec())
|
|
{
|
|
if ((eChangeDirec == eLeftStToEnd) || (eChangeDirec == eRightStToEnd))
|
|
{
|
|
ptEnd = ptEnd + 2 * dMoveLength * vec / vec.length();
|
|
}
|
|
else
|
|
{
|
|
ptSt = ptSt - 2 * dMoveLength * vec / vec.length();
|
|
}
|
|
pSegData->segPath.SetStartPoint(ptSt);
|
|
pSegData->segPath.SetEndPoint(ptEnd);
|
|
}
|
|
else
|
|
{
|
|
ptSt = ptSt - dMoveLength * vec / vec.length();
|
|
ptEnd = ptEnd + dMoveLength * vec / vec.length();
|
|
pSegData->segPath.SetStartPoint(ptSt);
|
|
pSegData->segPath.SetEndPoint(ptEnd);
|
|
}
|
|
}
|
|
if (pDlg->IsChangeDept())
|
|
{
|
|
if (pDlg->DeptChangeDirec())
|
|
{
|
|
if (!pSegData->bIsDoubleRow)
|
|
{
|
|
if ((eChangeDirec == eLeftStToEnd) || (eChangeDirec == eLeftEndToSt))
|
|
{
|
|
if (!pSegData->bIsLeft)
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(-(dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset((dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((eChangeDirec == eLeftStToEnd) || (eChangeDirec == eLeftEndToSt))
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(-(dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
else
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset((dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((eChangeDirec == eLeftStToEnd) || (eChangeDirec == eLeftEndToSt))
|
|
{
|
|
if (!pSegData->bIsDoubleRow)
|
|
{
|
|
if (!pSegData->bIsLeft)
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(-0.5 * (dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
else
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(0.5 * (dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!pSegData->bIsDoubleRow)
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(0.5 * (dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
else
|
|
{
|
|
pSegData->segPath = pSegData->segPath.Offset(-0.5 * (dDept - pSegData->dDept), LS_INFINITE);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
DrawParkingForLine(pSegData, pDlg->GetParkingWidth(), dDept, sName, idLayer);
|
|
}
|
|
if (pDlg->IsRefromSerial())
|
|
{
|
|
strSerial = pSegData->strStartSerial;
|
|
}
|
|
}
|
|
}
|
|
//判断是否是双排
|
|
void PolyIsOnSeg(TDPtrList<OneParking> &lstParking, PakingSegData* pSegData, int &nParkingNum)
|
|
{
|
|
XPoint ptSt, ptEnd;
|
|
ptSt = pSegData->segPath.GetStartPoint();
|
|
ptEnd = pSegData->segPath.GetEndPoint();
|
|
for (int i = 0; i < lstParking.Length(); ++i)
|
|
{
|
|
OneParking* pParkingData;
|
|
pParkingData = lstParking.GetAt(i);
|
|
if (!pParkingData->bIsBelongTo)
|
|
{
|
|
int nFlagSt = pSegData->segPath.HitTest2d(*pParkingData->poly2D.GetPointListAt(0));
|
|
int nFlagEnd = pSegData->segPath.HitTest2d(*pParkingData->poly2D.GetPointListAt(1));
|
|
if (((nFlagSt >= 3) && (nFlagSt <= 5)) || ((nFlagEnd >= 3) && (nFlagEnd <= 5)))
|
|
{
|
|
if (pParkingData->stText.strSerialNum > pSegData->strEndSerial)
|
|
{
|
|
pSegData->strEndSerial = pParkingData->stText.strSerialNum;
|
|
}
|
|
if ((pSegData->segPath.GetBulge()) < 1.0e-6)
|
|
{
|
|
AcGeVector3d vecBase = *pParkingData->poly2D.GetPointListAt(1) - *pParkingData->poly2D.GetPointListAt(0);
|
|
AcGeVector3d vec = *pParkingData->poly2D.GetPointListAt(2) - *pParkingData->poly2D.GetPointListAt(1);
|
|
int nAngle = GetSettingAngle(vecBase.angleTo(vec));
|
|
if (nAngle > 90) //确定第二排车位的象限
|
|
{
|
|
if (ptEnd.x > ptSt.x)
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
pSegData->nRightQMode = 2;
|
|
else
|
|
pSegData->nRightQMode = 3;
|
|
}
|
|
else
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
pSegData->nRightQMode = 2;
|
|
else
|
|
pSegData->nRightQMode = 3;
|
|
}
|
|
}
|
|
else if(nAngle < 90)
|
|
{
|
|
if (ptEnd.x > ptSt.x)
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
pSegData->nRightQMode = 1;
|
|
else
|
|
pSegData->nRightQMode = 0;
|
|
}
|
|
else
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
pSegData->nRightQMode = 1;
|
|
else
|
|
pSegData->nRightQMode = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ptEnd.x > ptSt.x)
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
pSegData->nRightQMode = 1;
|
|
else
|
|
pSegData->nRightQMode = 0;
|
|
}
|
|
else
|
|
{
|
|
if (pSegData->bIsLeft)
|
|
pSegData->nRightQMode = 0;
|
|
else
|
|
pSegData->nRightQMode = 1;
|
|
}
|
|
}
|
|
if (nAngle < pSegData->nAngle)
|
|
{
|
|
pSegData->nAngle = nAngle;
|
|
}
|
|
}
|
|
pSegData->bIsDoubleRow = TRUE;
|
|
pParkingData->bIsBelongTo = TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
nParkingNum++;
|
|
}
|
|
}
|
|
}
|
|
//获取车位基线、车位样式等
|
|
void AnalysisParkingToSeg(TDPtrList<OneParking> &lstParking, TDPtrList<PakingSegData> &lstSegParking)
|
|
{
|
|
int nlength;
|
|
TDPtrList<OneParking> lstParkingTmp;
|
|
while (lstParking.Length() > 0)
|
|
{
|
|
XPoint ptStart, ptEnd, ptMid;
|
|
CString strSerialNum;
|
|
double dTailWidth = 0, dHeadWidth = 0, dDept = 0, dTrapezoidDept;
|
|
OneParking parkingDataRight, parkingDataLeft;
|
|
parkingDataLeft = parkingDataRight = *lstParking.GetAt(0);
|
|
ptStart = *parkingDataRight.poly2D.GetPointListAt(0);
|
|
ptEnd = *parkingDataRight.poly2D.GetPointListAt(1);
|
|
dHeadWidth = (*parkingDataRight.poly2D.GetPointListAt(2)).Distance(*parkingDataRight.poly2D.GetPointListAt(3));
|
|
dTailWidth = (ptStart.Distance(ptEnd));
|
|
TGGeCurveSegment segChord(ptStart, ptEnd, 0);
|
|
if (abs(dHeadWidth - dTailWidth) > 1.0e-6)
|
|
{
|
|
dDept = abs(segChord.GetDist2Me(*parkingDataRight.poly2D.GetPointListAt(2)));
|
|
}
|
|
else
|
|
{
|
|
dDept = abs(parkingDataRight.poly2D.GetPointListAt(1)->Distance(*parkingDataRight.poly2D.GetPointListAt(2)));
|
|
}
|
|
lstParking.GetAt(0)->bIsBelongTo = TRUE;
|
|
PakingSegData* pPsegData = new PakingSegData;
|
|
pPsegData->strStartSerial = parkingDataLeft.stText.strSerialNum;
|
|
pPsegData->bIsDoubleRow = FALSE;
|
|
pPsegData->bIsLeft = TRUE;
|
|
pPsegData->nAngle = 0;
|
|
pPsegData->dTextHeight = parkingDataRight.stText.dTextHeight;
|
|
pPsegData->nStyle = parkingDataRight.m_nStyle;
|
|
pPsegData->idTextStyle = parkingDataRight.stText.idTextStyle;
|
|
pPsegData->BIsCCW = TRUE;
|
|
XLine baseLine(ptStart, ptEnd);
|
|
ptMid = baseLine.MidPoint();
|
|
|
|
if (baseLine.OnWhichSide(*parkingDataRight.poly2D.GetPointListAt(2)))
|
|
{
|
|
pPsegData->bIsLeft = FALSE;
|
|
}
|
|
nlength = lstParking.Length();
|
|
for (int n = 0; n < nlength; ++n)
|
|
{
|
|
OneParking* pParkingDataSec;
|
|
pParkingDataSec = lstParking.GetAt(n);
|
|
if (!pParkingDataSec->stText.strSerialNum.IsEmpty())
|
|
{
|
|
if (!pPsegData->strStartSerial.IsEmpty())
|
|
{
|
|
if (pParkingDataSec->stText.strSerialNum < pPsegData->strStartSerial)
|
|
{
|
|
pPsegData->strStartSerial = pParkingDataSec->stText.strSerialNum;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pPsegData->strStartSerial = pParkingDataSec->stText.strSerialNum;
|
|
}
|
|
|
|
}
|
|
|
|
if (*parkingDataRight.poly2D.GetPointListAt(1) == *pParkingDataSec->poly2D.GetPointListAt(0))
|
|
{
|
|
parkingDataRight = *pParkingDataSec;
|
|
pParkingDataSec->bIsBelongTo = TRUE;
|
|
XLine line12(*parkingDataRight.poly2D.GetPointListAt(0), *parkingDataRight.poly2D.GetPointListAt(1));
|
|
if (!parkingDataRight.stText.strSerialNum.IsEmpty())
|
|
{
|
|
double dLength = parkingDataRight.stText.ptText.Distance(line12.MidPoint());
|
|
if (dLength > dDept)
|
|
{
|
|
pPsegData->nTextLoc = 0;
|
|
}
|
|
else if(abs(dLength - 0.5 * dDept) < 1.0e-6)
|
|
{
|
|
pPsegData->nTextLoc = 2;
|
|
}
|
|
else
|
|
{
|
|
pPsegData->nTextLoc = 1;
|
|
}
|
|
pPsegData->dTextHeight = parkingDataRight.stText.dTextHeight;
|
|
}
|
|
}
|
|
else if (*parkingDataLeft.poly2D.GetPointListAt(0) == *pParkingDataSec->poly2D.GetPointListAt(1))
|
|
{
|
|
|
|
parkingDataLeft = *pParkingDataSec;
|
|
pParkingDataSec->bIsBelongTo = TRUE;
|
|
XLine line12(*parkingDataLeft.poly2D.GetPointListAt(0), *parkingDataLeft.poly2D.GetPointListAt(1));
|
|
if (!parkingDataLeft.stText.strSerialNum.IsEmpty())
|
|
{
|
|
double dLength = parkingDataLeft.stText.ptText.Distance(line12.MidPoint());
|
|
if (dLength > dDept)
|
|
{
|
|
pPsegData->nTextLoc = 0;
|
|
}
|
|
else if(abs(dLength - 0.5 * dDept) < 1.0e-6)
|
|
{
|
|
pPsegData->nTextLoc = 2;
|
|
}
|
|
else
|
|
{
|
|
pPsegData->nTextLoc = 1;
|
|
}
|
|
pPsegData->dTextHeight = parkingDataLeft.stText.dTextHeight;
|
|
}
|
|
}
|
|
}
|
|
ptStart = *parkingDataLeft.poly2D.GetPointListAt(0);
|
|
ptEnd = *parkingDataRight.poly2D.GetPointListAt(1);
|
|
if (abs(dHeadWidth - dTailWidth) > 1.0e-6)
|
|
{
|
|
|
|
XArc arc(ptStart, *parkingDataLeft.poly2D.GetPointListAt(1), ptEnd);
|
|
XLine line(ptStart, ptEnd);
|
|
int nFlag = line.OnWhichSide(*parkingDataLeft.poly2D.GetPointListAt(1));
|
|
pPsegData->segPath = arc;
|
|
if(pPsegData->segPath.OnWhichSide(*parkingDataLeft.poly2D.GetPointListAt(2)))
|
|
{
|
|
pPsegData->bIsLeft = FALSE;
|
|
}
|
|
else
|
|
{
|
|
pPsegData->bIsLeft = TRUE;
|
|
}
|
|
if (line.OnWhichSide(*parkingDataLeft.poly2D.GetPointListAt(1)))
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
pPsegData->BIsCCW = FALSE;
|
|
/*TGGeCurveSegment seg;
|
|
seg = arc;
|
|
double dBugle = seg.GetBulge();
|
|
pPsegData->segPath.SetStartPoint(ptStart);
|
|
pPsegData->segPath.SetEndPoint(ptEnd);
|
|
pPsegData->segPath.SetBulge(-dBugle);*/
|
|
}
|
|
double dRad = arc.GetRadius();
|
|
pPsegData->dWidth = dRad * acos((2 * dRad * dRad - dTailWidth * dTailWidth) / (2 * dRad * dRad));
|
|
}
|
|
else
|
|
{
|
|
|
|
pPsegData->dWidth = dTailWidth;
|
|
AcGeVector3d vecBase = *parkingDataLeft.poly2D.GetPointListAt(1) - *parkingDataLeft.poly2D.GetPointListAt(0);
|
|
AcGeVector3d vec = *parkingDataLeft.poly2D.GetPointListAt(3) - *parkingDataLeft.poly2D.GetPointListAt(0);
|
|
AcGeVector3d vecStToE = ptEnd - ptStart;
|
|
|
|
pPsegData->nAngle = GetSettingAngle(vecBase.angleTo(vec));
|
|
if (pPsegData->nAngle > 90)
|
|
{
|
|
if (ptEnd.x > ptStart.x)
|
|
{
|
|
if (pPsegData->bIsLeft)
|
|
pPsegData->nLeftQMode = 3;
|
|
else
|
|
pPsegData->nLeftQMode = 2;
|
|
}
|
|
else
|
|
{
|
|
if (pPsegData->bIsLeft)
|
|
pPsegData->nLeftQMode = 3;
|
|
else
|
|
pPsegData->nLeftQMode = 2;
|
|
}
|
|
pPsegData->nAngle -= 90;
|
|
}
|
|
else if(pPsegData->nAngle < 90)
|
|
{
|
|
if (ptEnd.x > ptStart.x)
|
|
{
|
|
if (pPsegData->bIsLeft)
|
|
pPsegData->nLeftQMode = 0;
|
|
else
|
|
pPsegData->nLeftQMode = 1;
|
|
}
|
|
else
|
|
{
|
|
if (pPsegData->bIsLeft)
|
|
pPsegData->nLeftQMode = 0;
|
|
else
|
|
pPsegData->nLeftQMode = 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ptEnd.x > ptStart.x)
|
|
{
|
|
if (pPsegData->bIsLeft)
|
|
pPsegData->nLeftQMode = 0;
|
|
else
|
|
pPsegData->nLeftQMode = 1;
|
|
}
|
|
else
|
|
{
|
|
if (pPsegData->bIsLeft)
|
|
pPsegData->nLeftQMode = 1;
|
|
else
|
|
pPsegData->nLeftQMode = 0;
|
|
}
|
|
}
|
|
pPsegData->segPath.SetStartPoint(ptStart);
|
|
pPsegData->segPath.SetEndPoint(ptEnd);
|
|
|
|
}
|
|
int nParkingNum = 0;
|
|
PolyIsOnSeg(lstParking, pPsegData, nParkingNum);
|
|
|
|
TDPtrList<OneParking> lstTemp;
|
|
lstTemp.copyFrom(lstParking);
|
|
lstParking.Reset();
|
|
for (int k = 0; k < lstTemp.Length(); ++k)
|
|
{
|
|
if (!lstTemp.GetAt(k)->bIsBelongTo)
|
|
{
|
|
OneParking* pParkingData = new OneParking;
|
|
OneParking* pTmp = lstTemp.GetAt(k);
|
|
pParkingData->poly2D = pTmp->poly2D;
|
|
pParkingData->stText = pTmp->stText;
|
|
pParkingData->bIsBelongTo = FALSE;
|
|
pParkingData->m_nStyle = pTmp->m_nStyle;
|
|
pParkingData->idPoly = pTmp->idPoly;
|
|
pParkingData->idSlashOrBlock = pTmp->idSlashOrBlock;
|
|
lstParking.Append(pParkingData);
|
|
}
|
|
else
|
|
{
|
|
OneParking* pParkingData = new OneParking;
|
|
OneParking* pTmp = lstTemp.GetAt(k);
|
|
pParkingData->poly2D = pTmp->poly2D;
|
|
pParkingData->stText = pTmp->stText;
|
|
pParkingData->bIsBelongTo = TRUE;
|
|
pParkingData->m_nStyle = pTmp->m_nStyle;
|
|
pParkingData->idPoly = pTmp->idPoly;
|
|
pParkingData->idSlashOrBlock = pTmp->idSlashOrBlock;
|
|
lstParkingTmp.Append(pParkingData);
|
|
}
|
|
}
|
|
lstTemp.Reset();
|
|
ptStart = *parkingDataLeft.poly2D.GetPointListAt(0);
|
|
ptEnd = *parkingDataRight.poly2D.GetPointListAt(1);
|
|
double dNum = 0;
|
|
if ((pPsegData->segPath.GetBulge()) > 1.0e-6)
|
|
{
|
|
dNum = (pPsegData->segPath.GetBulge()) / (2 * asin(0.5 * dTailWidth / pPsegData->segPath.GetArc().GetRadius()));
|
|
}
|
|
else
|
|
{
|
|
dNum = ptStart.Distance(ptEnd) / dTailWidth;
|
|
}
|
|
|
|
pPsegData->dDept = dDept;
|
|
pPsegData->nParkingNum = nParkingNum;
|
|
lstSegParking.Append(pPsegData);
|
|
}
|
|
lstParking.copyFrom(lstParkingTmp);
|
|
lstParkingTmp.Reset();
|
|
}
|
|
//删除原有实体
|
|
void DeleteEnt(TDPtrList<OneParking> &lstParking)
|
|
{
|
|
for (int i = 0; i < lstParking.Length(); ++i)
|
|
{
|
|
OneParking* pTmp = lstParking.GetAt(i);
|
|
if (pTmp->bIsBelongTo)
|
|
{
|
|
if (pTmp->stText.idText.isValid())
|
|
{
|
|
AcDbEntity* pEntity;
|
|
OPENOBJ_BEGIN(pTmp->stText.idText, AcDb::kForWrite, AcDbEntity, pEntity)
|
|
if (pEntity)
|
|
{
|
|
pEntity->erase();
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
if (pTmp->idPoly.isValid())
|
|
{
|
|
AcDbEntity* pEntity;
|
|
OPENOBJ_BEGIN(pTmp->idPoly, AcDb::kForWrite, AcDbEntity, pEntity)
|
|
if (pEntity)
|
|
{
|
|
pEntity->erase();
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
if (pTmp->idSlashOrBlock.isValid())
|
|
{
|
|
AcDbEntity* pEntity;
|
|
OPENOBJ_BEGIN(pTmp->idSlashOrBlock, AcDb::kForWrite, AcDbEntity, pEntity)
|
|
if (pEntity)
|
|
{
|
|
pEntity->erase();
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void SortParkingSeg(TDPtrList<PakingSegData> &lstSegParking)
|
|
{
|
|
|
|
}
|
|
//确定车位伸缩方向
|
|
DIrecRetCode SelectChangeDirec(PakingSegData &segData)
|
|
{
|
|
DIrecRetCode nRetCode = eLeftStToEnd;
|
|
TGGeCurveSegment segBase;
|
|
XPoint pt, ptMid;
|
|
segBase = segData.segPath;
|
|
|
|
if (!segData.bIsDoubleRow)
|
|
{
|
|
double dOffset = 0.5 * segData.dDept;
|
|
if (abs(segBase.GetBulge()) < 1.0e-6)
|
|
{
|
|
dOffset = dOffset * sin(segData.nAngle * PI / 180);
|
|
}
|
|
if (segData.bIsLeft)
|
|
{
|
|
segBase = segBase.Offset(-dOffset, LS_INFINITE);
|
|
}
|
|
else
|
|
{
|
|
segBase = segBase.Offset(dOffset, LS_INFINITE);
|
|
}
|
|
}
|
|
int iRet = RTNORM;
|
|
ptMid = segBase.MidPoint();
|
|
AcGeVector3d vec = segBase.GetEndPoint() - segBase.GetStartPoint();
|
|
if (!segData.bIsDoubleRow)
|
|
{
|
|
if (abs(segBase.GetBulge()) < 1.0e-6)
|
|
{
|
|
if ((segData.nLeftQMode == 2) || (segData.nLeftQMode == 3))
|
|
{
|
|
ptMid = ptMid - (0.5 * segData.dDept * sin(segData.nAngle * PI / 180) + 0.25 * segData.dWidth) * vec / vec.length();
|
|
}
|
|
else
|
|
{
|
|
ptMid = ptMid + (0.5 * segData.dDept * sin(segData.nAngle * PI / 180) - 0.25 * segData.dWidth) * vec / vec.length();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ptMid = ptMid - 0.25 * segData.dWidth * vec / vec.length();
|
|
}
|
|
iRet = ads_getpoint(ptMid, _T("\n请点取发生变化的一侧<退出>: "), pt);
|
|
if (iRet == RTNORM)
|
|
{
|
|
if (abs(segBase.GetBulge()) > 1.0e-6)
|
|
{
|
|
XLine lineRadial(ptMid, segBase.GetArc().GetCenterPt());
|
|
if (segBase.OnWhichSide(pt))
|
|
{
|
|
if (lineRadial.OnWhichSide(pt))
|
|
{
|
|
nRetCode = eRightStToEnd;
|
|
}
|
|
else
|
|
{
|
|
nRetCode = eRightEndToSt;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (lineRadial.OnWhichSide(pt))
|
|
{
|
|
nRetCode = eLeftStToEnd;
|
|
}
|
|
else
|
|
{
|
|
nRetCode = eLeftEndToSt;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (segBase.OnWhichSide(pt))
|
|
{
|
|
if (segBase.GetStartPoint().x > segBase.GetEndPoint().x)
|
|
{
|
|
if (pt.x > ptMid.x)
|
|
{
|
|
nRetCode = eRightEndToSt;
|
|
}
|
|
else
|
|
{
|
|
nRetCode = eRightStToEnd;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pt.x > ptMid.x)
|
|
{
|
|
nRetCode = eRightStToEnd;
|
|
}
|
|
else
|
|
{
|
|
nRetCode = eRightEndToSt;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (segBase.GetStartPoint().x > segBase.GetEndPoint().x)
|
|
{
|
|
if (pt.x > ptMid.x)
|
|
{
|
|
nRetCode = eLeftEndToSt;
|
|
}
|
|
else
|
|
{
|
|
nRetCode = eLeftStToEnd;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pt.x > ptMid.x)
|
|
{
|
|
nRetCode = eLeftStToEnd;
|
|
}
|
|
else
|
|
{
|
|
nRetCode = eLeftEndToSt;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
nRetCode = eCancle;
|
|
}
|
|
return nRetCode;
|
|
}
|
|
void ParkingAlterCmd()
|
|
{
|
|
|
|
//非模态对话框
|
|
CParkingAlterDlg dlg(acedGetAcadFrame());
|
|
dlg.Create(IDD_DLG_PARKING_ALTER);
|
|
dlg.ShowWindow(SW_SHOW);
|
|
while (true)
|
|
{
|
|
TDPtrList<ObliqueLineData> lstPoly, lstSingleSlash, lstDoubleSlash;
|
|
TDPtrList<ParkingTextData> lstText;
|
|
TDPtrList<OneParking> lstParking;
|
|
TDPtrList<PakingSegData> lstSegParking;
|
|
TDPtrList<ParkingBlockData> lstPtBlock;
|
|
PickSet ss(SS_FREE);
|
|
RBList rbMark(RTDXF0, _T("POLYLINE,LWPOLYLINE,TCH_TEXT,TCH_INSERT,INSERT,TCH_MVINSERT,TCH_BLOCK_INSERT"),NULL);
|
|
int nRetCode=SelectEntities(_T("\n请选择需要修改的停车位<退出>:"), ss, rbMark);
|
|
if (nRetCode != RTNORM) // 命令结束
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
long n = ss.Length() - 1;
|
|
double length = 0;
|
|
for (n; n >= 0; --n)
|
|
{
|
|
AcDbEntity* pEntity;
|
|
CString strlay;
|
|
Entity ssEnt=ss[n];
|
|
OPENOBJ_BEGIN(ssEnt,AcDb::kForWrite,AcDbEntity,pEntity);
|
|
if(pEntity)
|
|
{
|
|
strlay = pEntity->layer();
|
|
if (pEntity->isKindOf(TDbText::desc()))
|
|
{
|
|
if (!strlay.CompareNoCase(LAY_PKNG_SING))
|
|
{
|
|
TDbText* pText = TDbText::cast(pEntity);
|
|
ParkingTextData* stText = new ParkingTextData;
|
|
stText->strSerialNum = _T("");
|
|
stText->strSerialNum = pText->GetText();
|
|
stText->ptText = pText->GetLocation();
|
|
stText->dTextHeight = pText->GetHeight();
|
|
if(stText->dTextHeight > length)
|
|
length = stText->dTextHeight;
|
|
stText->idTextStyle = pText->GetStyleId();
|
|
stText->idText = pEntity->objectId();
|
|
lstText.Append(stText);
|
|
}
|
|
}
|
|
else if(pEntity->isKindOf(AcDbBlockReference::desc()))
|
|
{
|
|
AcDbBlockReference* pBlock = AcDbBlockReference::cast(pEntity);
|
|
ParkingBlockData* blockData = new ParkingBlockData;
|
|
blockData->ptBlockCenter = XPoint(pBlock->position());
|
|
blockData->idBlock = pEntity->objectId();
|
|
lstPtBlock.Append(blockData);
|
|
}
|
|
else
|
|
{
|
|
if(!strlay.CompareNoCase(_T("PKNG-TSRP")))
|
|
{
|
|
AcDbPolyline* poly = AcDbPolyline::cast(pEntity);
|
|
XPoly2D poly2D;
|
|
PolyConvert(*poly, poly2D);
|
|
ObliqueLineData* polyData = new ObliqueLineData;
|
|
polyData->polyLine = poly2D;
|
|
polyData->idLine = pEntity->objectId();
|
|
if (poly2D.TotalSegments() == 1)
|
|
{
|
|
lstSingleSlash.Append(polyData);
|
|
}
|
|
else if(poly2D.TotalSegments() == 2)
|
|
{
|
|
lstDoubleSlash.Append(polyData);
|
|
}
|
|
else if(poly2D.TotalSegments() == 4)
|
|
{
|
|
lstPoly.Append(polyData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
AnalysisParkingToGroup(lstPoly, lstSingleSlash, lstDoubleSlash, lstPtBlock, lstText, lstParking, length);
|
|
AnalysisParkingToSeg(lstParking, lstSegParking);
|
|
DIrecRetCode nRet = eLeftStToEnd;
|
|
if ((dlg.IsChangeWidth() && dlg.WidthChangeDirec()) || (dlg.IsChangeDept() && dlg.DeptChangeDirec()))
|
|
{
|
|
nRet = SelectChangeDirec(*lstSegParking.GetAt(0));
|
|
if (nRet == eCancle)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
DeleteEnt(lstParking);
|
|
ChangeParking(&dlg, lstSegParking, nRet);
|
|
}
|
|
} |