817 lines
19 KiB
C++
817 lines
19 KiB
C++
#include "stdafx.h"
|
||
#include "TlandScapeDragjig.h"
|
||
#include <gepnt2d.h>
|
||
#include "TDbRoadEntity.h"
|
||
#include "LandScapeStyle.h"
|
||
#include "GlwGlobalVariable.h"
|
||
using namespace RoadDrag;
|
||
extern void Point3DTo2D(AcGePoint3d &ptOri, AcGePoint2d &ptDest);
|
||
|
||
inline bool KeyRet(AcEdJig::DragStatus ret)
|
||
{
|
||
return ret >= AcEdJig::kKW1 && ret <= AcEdJig::kKW9;
|
||
}
|
||
|
||
CString CLandScapeStateData::m_arSzPrompt[] =
|
||
{
|
||
_T("\n指定起点<退出>: "),
|
||
_T("\n直段下一点或[弧段(A)] <退出>: "),
|
||
_T("\n直段下一点或[弧段(A) /回退(U)] <退出>: "),
|
||
_T("\n直段下一点或[弧段(A) /回退(U) /闭合(C)] <退出>: "),
|
||
_T("\n弧段终点或[直段(L)] <退出>: "),
|
||
_T("\n弧段终点或[直段(L)/回退(U)] <退出>: "),
|
||
_T("\n点取弧上任意点<结束>: ")
|
||
};
|
||
|
||
CString CLandScapeStateData::m_szKeyListLine = _T("A");
|
||
CString CLandScapeStateData::m_szKeyListNextLine = _T("A U C");
|
||
CString CLandScapeStateData::m_szKeyListArc = _T("L");
|
||
CString CLandScapeStateData::m_szKeyListNextArc = _T("L U");
|
||
CString CLandScapeStateData::m_szKeyListArcRad = _T("U");
|
||
|
||
|
||
TlandScapeDragjig::TlandScapeDragjig(CLandScapeStyle* landStyle)
|
||
: m_pLandStyle(landStyle)
|
||
{
|
||
m_pState = NULL;
|
||
m_pLineRoad = new TDbLineLandScapeEntity();
|
||
m_pArcRoad = new TDbArcLandScapeEntity();
|
||
m_pRoad = new CMixRoadForJig(m_pLineRoad, m_pArcRoad);
|
||
NullShow(); // 初始不绘制。
|
||
}
|
||
|
||
TlandScapeDragjig::~TlandScapeDragjig(void)
|
||
{
|
||
// 当然,如果该实体被添加到了CAD中,该实体不需要删除,
|
||
// 因此,实体被绘制之后,需要取消针对该实体的引用(置空)
|
||
ASSERT(m_pLineRoad != NULL);
|
||
ASSERT(m_pArcRoad != NULL);
|
||
ASSERT(m_pRoad != NULL);
|
||
|
||
delete m_pRoad;
|
||
m_pRoad = NULL;
|
||
delete m_pLineRoad;
|
||
m_pLineRoad = NULL;
|
||
delete m_pArcRoad;
|
||
m_pArcRoad = NULL;
|
||
|
||
//m_pDrawDlg->SetCmdNum(1);
|
||
}
|
||
|
||
// 读取对话框的内容,构造圆弧道路
|
||
Adesk::Boolean TlandScapeDragjig::ConArcRoad()
|
||
{
|
||
CLandScapeStyle* pLandScape = GET_GLOBAL_VARIABLE(CLandScapeStyle);
|
||
//ASSERT(m_pDrawDlg != NULL);
|
||
|
||
if (m_ptFirst.distanceTo(m_ptNext) < 1.0
|
||
|| m_ptFirst.distanceTo(m_ptThird) < 1.0
|
||
|| m_ptThird.distanceTo(m_ptNext) < 1.0
|
||
)
|
||
{
|
||
return Adesk::kFalse;
|
||
}
|
||
|
||
m_pArcRoad->SetArcRoad(m_ptFirst, m_ptThird, m_ptNext, m_pLandStyle);
|
||
|
||
m_pRoad->SetState(CMixRoadForJig::eArc);
|
||
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
// 读取对话框的内容,构造直线道路。
|
||
Adesk::Boolean TlandScapeDragjig::ConLineRoad()
|
||
{
|
||
if (m_ptFirst.distanceTo(m_ptNext) < 1.0)
|
||
{
|
||
return Adesk::kFalse;
|
||
}
|
||
|
||
m_pLineRoad->SetLineRoad(m_ptFirst, m_ptNext, m_pLandStyle);
|
||
|
||
m_pRoad->SetState(CMixRoadForJig::eLine);
|
||
|
||
return Adesk::kTrue;
|
||
}
|
||
Adesk::Boolean TlandScapeDragjig::NullShow()
|
||
{
|
||
m_pRoad->SetState(CMixRoadForJig::eNone);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
void TlandScapeDragjig::NextPoint()
|
||
{
|
||
m_ptFirst = m_ptNext;
|
||
}
|
||
|
||
void TlandScapeDragjig::DoIt()
|
||
{
|
||
ASSERT(m_pState != NULL);
|
||
m_pState->Drag();
|
||
}
|
||
|
||
// overide of parent cls
|
||
AcEdJig::DragStatus TlandScapeDragjig::sampler()
|
||
{
|
||
//m_pDrawDlg->SetCmdNum(2);
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted
|
||
| AcEdJig::kNoNegativeResponseAccepted
|
||
| AcEdJig::kNoZeroResponseAccepted));
|
||
|
||
ASSERT(m_pState != NULL);
|
||
return m_pState->sampler();
|
||
}
|
||
|
||
Adesk::Boolean TlandScapeDragjig::update()
|
||
{
|
||
ASSERT(m_pState != NULL);
|
||
return m_pState->update();
|
||
}
|
||
|
||
AcDbEntity* TlandScapeDragjig::entity() const
|
||
{
|
||
return m_pRoad;// 这个road中集成几种道路类型
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// state fun!!
|
||
|
||
CLandScapeStateData::CLandScapeStateData (TlandScapeDragjig *jig, TLandScapeDragContext *pContext) : m_pRoadJig(jig), m_pContext(pContext)
|
||
{
|
||
|
||
}
|
||
|
||
CLandScapeStateData::~CLandScapeStateData()
|
||
{
|
||
|
||
}
|
||
|
||
|
||
AcEdJig::DragStatus CLandScapeStateData::LineSamplerFun(CString &m_szKeyList)
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setKeywordList(m_szKeyList);
|
||
AcGePoint3d ptDump;
|
||
AcEdJig::DragStatus ret = m_pRoadJig->acquirePoint(ptDump, POINT_2D_TO_3D(PtFirst()));
|
||
|
||
if (ret == AcEdJig::kNormal)
|
||
{
|
||
AcGePoint2d ptDump2d;
|
||
Point3DTo2D(ptDump, ptDump2d);
|
||
m_pRoadJig->m_ptNext = ptDump2d;
|
||
if (m_pRoadJig->m_ptFirst.distanceTo(ptDump2d) < 1.0)
|
||
return AcEdJig::kNoChange;
|
||
|
||
if (m_pRoadJig->m_ptCheck.distanceTo(ptDump2d) < 1.0)
|
||
return AcEdJig::kNoChange;
|
||
else
|
||
m_pRoadJig->m_ptCheck = ptDump2d;
|
||
}
|
||
|
||
return ret; // 需要处理,然后生成实体
|
||
}
|
||
|
||
AcEdJig::DragStatus CLandScapeStateData::ArcSamplerFun(CString &m_szKeyList)
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setKeywordList(m_szKeyList);
|
||
AcGePoint3d ptDump;
|
||
AcEdJig::DragStatus ret = m_pRoadJig->acquirePoint(ptDump, POINT_2D_TO_3D(PtFirst()));
|
||
|
||
if (ret == AcEdJig::kNormal)
|
||
{
|
||
AcGePoint2d ptDump2d;
|
||
Point3DTo2D(ptDump, ptDump2d);
|
||
|
||
m_pRoadJig->m_ptNext = ptDump2d;
|
||
|
||
if (PtFirst().distanceTo(ptDump2d) < 1.0)
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
// First in
|
||
AcEdJig::DragStatus CLandScapeFirstInState::Drag()
|
||
{
|
||
m_pRoadJig->setDispPrompt(m_arSzPrompt[TLandScapeDragContext::eFirstIn]);
|
||
|
||
AcEdJig::DragStatus ret = m_pRoadJig->drag();
|
||
|
||
// 需要判断的返回类型:
|
||
// 1、正常选中一个点,
|
||
// 2、其他
|
||
if (ret == AcEdJig::kNormal)
|
||
{ // 应该是进入下一个状态了。
|
||
m_pContext->SetSequenceState(m_pContext->SequenceAfterFirstIn());
|
||
}
|
||
else
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
// 取点
|
||
AcEdJig::DragStatus CLandScapeFirstInState::sampler()
|
||
{
|
||
AcGePoint3d ptDump;
|
||
AcEdJig::DragStatus ret = m_pRoadJig->acquirePoint(ptDump);
|
||
|
||
// 这个决定了drag的返回值
|
||
if (ret == AcEdJig::kNormal)
|
||
{
|
||
Point3DTo2D(ptDump, PtFirst());
|
||
m_pContext->RecordFirstPoint(PtFirst());
|
||
m_pRoadJig->NullShow();
|
||
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
|
||
return ret; // 需要处理,然后生成实体
|
||
}
|
||
|
||
Adesk::Boolean CLandScapeFirstInState::update()
|
||
{
|
||
return m_pRoadJig->NullShow();
|
||
}
|
||
|
||
// LineRoad
|
||
AcEdJig::DragStatus CLineLandScapeState::Drag()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setDispPrompt(m_arSzPrompt[TLandScapeDragContext::eLineRoad]);
|
||
|
||
AcEdJig::DragStatus ret;
|
||
INITGET_BEG(-1, m_szKeyListLine)
|
||
ret = m_pRoadJig->drag();
|
||
INITGET_END()
|
||
|
||
if (ret == AcEdJig::kNull)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
else if (ret == AcEdJig::kNormal)
|
||
{
|
||
// 下一个道路了
|
||
m_pContext->PushPoint(PtFirst());
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eNextLineRoad);
|
||
m_pRoadJig->NextPoint();
|
||
m_pContext->AddLineRoad(m_pRoadJig->m_pLineRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW1)
|
||
{ // 关键字1,切换到圆弧
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eArcRoad);
|
||
}
|
||
else
|
||
{ // 其他的情况!
|
||
// do Nothing!!
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus CLineLandScapeState::sampler()
|
||
{
|
||
return LineSamplerFun(m_szKeyListLine);
|
||
}
|
||
|
||
Adesk::Boolean CLineLandScapeState::update()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
// 这时候,需要处理实体
|
||
return m_pRoadJig->ConLineRoad();
|
||
}
|
||
|
||
|
||
// NextLineRoad
|
||
AcEdJig::DragStatus CNextLineLandScapeState::Drag()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setDispPrompt(m_arSzPrompt[TLandScapeDragContext::eNextLineRoad]);
|
||
|
||
AcEdJig::DragStatus ret;
|
||
INITGET_BEG(-1, m_szKeyListNextLine)
|
||
ret = m_pRoadJig->drag();
|
||
INITGET_END()
|
||
|
||
if (ret == AcEdJig::kNull)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
else if (ret == AcEdJig::kNormal)
|
||
{
|
||
// still this state
|
||
m_pContext->PushPoint(PtFirst());
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eThirdLineRoad);
|
||
m_pRoadJig->NextPoint();
|
||
m_pContext->AddLineRoad(m_pRoadJig->m_pLineRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW1)
|
||
{ // 关键字_T("A U C");
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eNextArcRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW2)
|
||
{// 关键字_T("A U C");
|
||
PtFirst() = m_pContext->RoolBack();
|
||
}
|
||
else
|
||
{ // 其他的情况!
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus CNextLineLandScapeState::sampler()
|
||
{
|
||
return LineSamplerFun(m_szKeyListNextLine);
|
||
}
|
||
|
||
Adesk::Boolean CNextLineLandScapeState::update()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
// 这时候,需要处理实体
|
||
return m_pRoadJig->ConLineRoad();
|
||
}
|
||
|
||
|
||
// NextLineRoad
|
||
AcEdJig::DragStatus CThirdLineLandScapeState::Drag()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setDispPrompt(m_arSzPrompt[TLandScapeDragContext::eThirdLineRoad]);
|
||
|
||
AcEdJig::DragStatus ret;
|
||
INITGET_BEG(-1, m_szKeyListNextLine)
|
||
ret = m_pRoadJig->drag();
|
||
INITGET_END()
|
||
|
||
if (ret == AcEdJig::kNull)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
else if (ret == AcEdJig::kNormal)
|
||
{
|
||
// still this state
|
||
m_pContext->PushPoint(PtFirst());
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eThirdLineRoad);
|
||
m_pRoadJig->NextPoint();
|
||
m_pContext->AddLineRoad(m_pRoadJig->m_pLineRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW1)
|
||
{ // 关键字_T("A U C");
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eNextArcRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW2)
|
||
{// 关键字_T("A U C");
|
||
PtFirst() = m_pContext->RoolBack();
|
||
}
|
||
else if (ret == AcEdJig::kKW3)
|
||
{// 关键字_T("A U C");
|
||
m_pRoadJig->MakeClosed(m_pContext->GetFirstPoint());
|
||
if (m_pRoadJig->ConLineRoad())
|
||
m_pContext->AddLineRoad(m_pRoadJig->m_pLineRoad);
|
||
m_pContext->ClearStep();
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eFirstIn);
|
||
m_pContext->SetStateAfterFirstIn(TRUE);
|
||
}
|
||
else
|
||
{ // 其他的情况!
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus CThirdLineLandScapeState::sampler()
|
||
{
|
||
return LineSamplerFun(m_szKeyListNextLine);
|
||
}
|
||
|
||
Adesk::Boolean CThirdLineLandScapeState::update()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
// 这时候,需要处理实体
|
||
return m_pRoadJig->ConLineRoad();
|
||
}
|
||
|
||
// ArcRoad
|
||
AcEdJig::DragStatus CArcLandScapeState::Drag()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setDispPrompt(m_arSzPrompt[TLandScapeDragContext::eArcRoad]);
|
||
|
||
AcEdJig::DragStatus ret;
|
||
INITGET_BEG(-1, m_szKeyListArc)
|
||
ret = m_pRoadJig->drag();
|
||
INITGET_END()
|
||
|
||
if (ret == AcEdJig::kNull)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eFirstIn);
|
||
m_pContext->SetStateAfterFirstIn(FALSE);
|
||
m_pContext->ClearStep();
|
||
}
|
||
else if (ret == AcEdJig::kNormal)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eArcMidRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW1)
|
||
{ // 关键字1,切换到线段
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eLineRoad);
|
||
}
|
||
else
|
||
{ // 其他的情况!
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus CArcLandScapeState::sampler()
|
||
{
|
||
return ArcSamplerFun(m_szKeyListArc);
|
||
}
|
||
|
||
Adesk::Boolean CArcLandScapeState::update()
|
||
{
|
||
return m_pRoadJig->NullShow();
|
||
}
|
||
|
||
|
||
// NextArcRoad
|
||
AcEdJig::DragStatus CNextArcLandScapeState::Drag()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setDispPrompt(m_arSzPrompt[TLandScapeDragContext::eNextArcRoad]);
|
||
|
||
AcEdJig::DragStatus ret;
|
||
INITGET_BEG(-1, m_szKeyListNextArc)
|
||
ret = m_pRoadJig->drag();
|
||
INITGET_END()
|
||
|
||
// 需要判断的返回类型:
|
||
// 1、选中了一个点,(组成了一个线段回路)
|
||
// 2、取消
|
||
// 3、关键字选中
|
||
// 3、其他,比如:右键,空格,回车等
|
||
if (ret == AcEdJig::kNull)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
|
||
}
|
||
else if (ret == AcEdJig::kNormal)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eArcMidRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW1)
|
||
{ // 关键字,切换到LineRoad,_T("L U");
|
||
if (m_pContext->PushPointNum() >= 2)
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eThirdLineRoad);
|
||
else
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eNextLineRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW2)
|
||
{ // Undo;
|
||
PtFirst() = m_pContext->RoolBack();
|
||
}
|
||
else
|
||
{ // 其他的情况!
|
||
// do Nothing!!
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus CNextArcLandScapeState::sampler()
|
||
{
|
||
return ArcSamplerFun(m_szKeyListNextArc);
|
||
}
|
||
|
||
Adesk::Boolean CNextArcLandScapeState::update()
|
||
{
|
||
return m_pRoadJig->NullShow();
|
||
}
|
||
|
||
|
||
// MidArcRoad
|
||
AcEdJig::DragStatus CMidArcLandScapeState::Drag()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setDispPrompt(m_arSzPrompt[TLandScapeDragContext::eArcMidRoad]);
|
||
|
||
|
||
AcEdJig::DragStatus ret;
|
||
INITGET_BEG(-1, m_szKeyListArcRad)
|
||
ret = m_pRoadJig->drag();
|
||
INITGET_END()
|
||
|
||
// 需要判断的返回类型:
|
||
// 1、选中了一个点,(组成了一个线段回路)
|
||
// 2、取消
|
||
// 3、关键字选中
|
||
// 3、其他,比如:右键,空格,回车等
|
||
if (ret == AcEdJig::kCancel)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
else if (ret == AcEdJig::kNull)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
else if (ret == AcEdJig::kNormal)
|
||
{
|
||
m_pContext->PushPoint(PtFirst());
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eNextArcRoad);
|
||
m_pRoadJig->NextPoint();
|
||
|
||
m_pContext->AddArcRoad(m_pRoadJig->m_pArcRoad);
|
||
}
|
||
else if (ret == AcEdJig::kKW1)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eArcRad);
|
||
|
||
}
|
||
else if (ret == AcEdJig::kKW2)
|
||
{ // Undo;
|
||
PtFirst() = m_pContext->RoolBack();
|
||
}
|
||
else if (ret == AcEdJig::kNoChange)
|
||
{
|
||
// do nothing;
|
||
}
|
||
else
|
||
{ // 其他的情况!
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus CMidArcLandScapeState::sampler()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
m_pRoadJig->setKeywordList(m_szKeyListArcRad);
|
||
AcGePoint3d ptDump;
|
||
AcEdJig::DragStatus ret = m_pRoadJig->acquirePoint(ptDump);
|
||
|
||
if (ret == AcEdJig::kNormal)
|
||
{
|
||
AcGePoint2d ptDump2d;
|
||
Point3DTo2D(ptDump, ptDump2d);
|
||
if (PtFirst().distanceTo(ptDump2d) < 1.0)
|
||
return AcEdJig::kNoChange;
|
||
else if (m_pRoadJig->m_ptNext.distanceTo(ptDump2d) < 1.0)
|
||
return AcEdJig::kNoChange;
|
||
|
||
m_pRoadJig->m_ptThird = ptDump2d;
|
||
if (m_pRoadJig->m_ptCheck.distanceTo(ptDump2d) < 1.0)
|
||
return AcEdJig::kNoChange;
|
||
else
|
||
m_pRoadJig->m_ptCheck = ptDump2d;
|
||
}
|
||
|
||
return ret; // 需要处理,然后生成实体
|
||
}
|
||
|
||
Adesk::Boolean CMidArcLandScapeState::update()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
return m_pRoadJig->ConArcRoad();
|
||
}
|
||
|
||
AcEdJig::DragStatus CArcRadLandScapeState::Drag()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
CLandScapeStyle* pLandScape = GET_GLOBAL_VARIABLE(CLandScapeStyle);
|
||
m_dArcRad = pLandScape->m_dArcRad;
|
||
CString strPrompt = _T("输入半径");
|
||
if (DocGetMeterUnitDraw())
|
||
{
|
||
strPrompt.Format(_T("\n输入半径<%.3f>"), m_dArcRad);
|
||
}
|
||
else
|
||
{
|
||
strPrompt.Format(_T("\n输入半径<%.0f>"), m_dArcRad);
|
||
}
|
||
m_pRoadJig->setDispPrompt(strPrompt);
|
||
|
||
|
||
AcEdJig::DragStatus ret;
|
||
INITGET_BEG(-1, m_szKeyListArcRad)
|
||
ret = m_pRoadJig->drag();
|
||
INITGET_END()
|
||
// 需要判断的返回类型:
|
||
// 1、选中了一个点,(组成了一个线段回路)
|
||
// 2、取消
|
||
// 3、关键字选中
|
||
// 3、其他,比如:右键,空格,回车等
|
||
if (ret == AcEdJig::kCancel)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
/*else if (ret == AcEdJig::kNull)
|
||
{
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}*/
|
||
else if (ret == AcEdJig::kNormal || ret == AcEdJig::kNull || ret == AcEdJig::kOther)
|
||
{
|
||
m_pContext->PushPoint(PtFirst());
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eNextArcRoad);
|
||
m_pRoadJig->NextPoint();
|
||
|
||
m_pContext->AddArcRoad(m_pRoadJig->m_pArcRoad);
|
||
}
|
||
|
||
else if (ret == AcEdJig::kNoChange)
|
||
{
|
||
// do nothing;
|
||
}
|
||
else
|
||
{ // 其他的情况!
|
||
m_pContext->SetSequenceState(TLandScapeDragContext::eSequenceCancel);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus CArcRadLandScapeState::sampler()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
CLandScapeStyle* pLandScape = GET_GLOBAL_VARIABLE(CLandScapeStyle);
|
||
double dTemp;
|
||
XPoint ptBase;
|
||
m_pRoadJig->setUserInputControls((AcEdJig::UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted
|
||
| AcEdJig::kNoNegativeResponseAccepted
|
||
| AcEdJig::kNoZeroResponseAccepted));
|
||
AcGePoint3d ptDump;
|
||
AcEdJig::DragStatus ret = m_pRoadJig->acquireDist(dTemp, POINT_2D_TO_3D(m_pRoadJig->m_ptNext));
|
||
|
||
if (ret == AcEdJig::kNormal)
|
||
{
|
||
if (fabs(dTemp-m_dArcRad)>_DIST_SNAP && dTemp > 0) {
|
||
m_dArcRad = dTemp;
|
||
pLandScape->m_dArcRad = m_dArcRad;
|
||
}
|
||
else
|
||
{
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
}
|
||
|
||
return ret; // 需要处理,然后生成实体
|
||
}
|
||
|
||
Adesk::Boolean CArcRadLandScapeState::update()
|
||
{
|
||
ASSERT(m_pRoadJig != NULL);
|
||
|
||
XPoint ptBase, ptPrev;
|
||
double nChordLen=m_pRoadJig->m_ptFirst.distanceTo(m_pRoadJig->m_ptNext);
|
||
if(nChordLen<2.0*m_dArcRad+1.0E-6) {
|
||
double bulge=2.0*asin(nChordLen/2.0/m_dArcRad);
|
||
if(XLine((XPoint)m_pRoadJig->m_ptFirst, (XPoint)m_pRoadJig->m_ptNext).OnWhichSide(m_pRoadJig->m_ptCheck)==OFFSET_LEFT)
|
||
bulge = -bulge;
|
||
XArc* pxArc = new XArc((XPoint)m_pRoadJig->m_ptFirst, (XPoint)m_pRoadJig->m_ptNext, bulge);
|
||
m_pRoadJig->m_ptThird = pxArc->MidPoint();
|
||
}
|
||
else
|
||
{
|
||
return Adesk::kFalse;
|
||
}
|
||
|
||
return m_pRoadJig->ConArcRoad();
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// TRoadDragContext
|
||
|
||
TLandScapeDragContext::TLandScapeDragContext(CLandScapeStyle* pLandStyle)
|
||
: m_pLandStyle(pLandStyle), m_bLineAfterFirstrIn(TRUE), m_eSequence(eFirstIn)
|
||
{
|
||
|
||
|
||
}
|
||
|
||
TLandScapeDragContext::~TLandScapeDragContext()
|
||
{
|
||
ClearStep();
|
||
}
|
||
|
||
|
||
void TLandScapeDragContext::AddArcRoad(TDbArcLandScapeEntity *pArcRoadEnt)
|
||
{
|
||
ASSERT(pArcRoadEnt != NULL);
|
||
CLandScapeStyle* pLandScape = GET_GLOBAL_VARIABLE(CLandScapeStyle);
|
||
PickSet ssAll(SS_FREE);
|
||
pLandScape->ssAll = ssAll;
|
||
pLandScape->ssAll.IncludeBegin();
|
||
CArcRoad *pArcRoad = pArcRoadEnt->CreateArcRoad(m_pLandStyle);
|
||
AcGeCircArc2d circle2d = AcGeCircArc2d(AsMMUnitPoint2d(pArcRoadEnt->GetFirstPt()), AsMMUnitPoint2d(pArcRoadEnt->GetThirdPt()), AsMMUnitPoint2d(pArcRoadEnt->GetEndPt()));
|
||
pLandScape->m_dArcRad = circle2d.radius();
|
||
m_datas.AddArcRoad(*pArcRoad);
|
||
delete pArcRoad;
|
||
pArcRoad = NULL;
|
||
}
|
||
|
||
void TLandScapeDragContext::AddLineRoad(TDbLineLandScapeEntity *pLineRoadEnt)
|
||
{
|
||
ASSERT(pLineRoadEnt != NULL);
|
||
CLandScapeStyle* pLandScape = GET_GLOBAL_VARIABLE(CLandScapeStyle);
|
||
PickSet ssAll(SS_FREE);
|
||
pLandScape->ssAll = ssAll;
|
||
pLandScape->ssAll.IncludeBegin();
|
||
CLineRoad *pLineRoad = pLineRoadEnt->CreateLineRoad(m_pLandStyle);
|
||
m_datas.AddLineRoad(*pLineRoad);
|
||
delete pLineRoad;
|
||
pLineRoad = NULL;
|
||
}
|
||
|
||
void TLandScapeDragContext::PushPoint(const AcGePoint2d &ptPush)
|
||
{
|
||
m_arPushPoint.append(ptPush);
|
||
}
|
||
|
||
AcGePoint2d TLandScapeDragContext::PopPoint()
|
||
{
|
||
if (PushPointNum() > 0)
|
||
{
|
||
PopSequence();// 调整状态
|
||
AcGePoint2d ptPop = m_arPushPoint[m_arPushPoint.length() - 1];
|
||
m_arPushPoint.removeLast();
|
||
return ptPop;
|
||
}
|
||
else
|
||
{
|
||
ASSERT(0);
|
||
return AcGePoint2d();
|
||
}
|
||
}
|
||
|
||
AcGePoint2d TLandScapeDragContext::RoolBack()
|
||
{
|
||
m_datas.RoolBack();
|
||
return PopPoint();
|
||
}
|
||
|
||
|
||
|
||
TLandScapeDragContext::ESequence TLandScapeDragContext::SequenceAfterFirstIn()
|
||
{
|
||
return m_bLineAfterFirstrIn ? eLineRoad : eArcRoad;
|
||
}
|
||
|
||
void TLandScapeDragContext::PopSequence()
|
||
{
|
||
ASSERT(PushPointNum() > 0);
|
||
if (m_eSequence == eNextLineRoad)
|
||
{
|
||
m_eSequence = eLineRoad;
|
||
}
|
||
else if (m_eSequence == eThirdLineRoad)
|
||
{
|
||
if (PushPointNum() > 2)
|
||
m_eSequence = eThirdLineRoad;
|
||
else
|
||
m_eSequence = eNextLineRoad;
|
||
}
|
||
else if (m_eSequence == eNextArcRoad)
|
||
{
|
||
if (PushPointNum() > 1)
|
||
m_eSequence = eNextArcRoad;
|
||
else
|
||
m_eSequence = eArcRoad;
|
||
}
|
||
else
|
||
{
|
||
ASSERT(0);
|
||
}
|
||
}
|
||
|
||
void TLandScapeDragContext ::ClearStep()
|
||
{
|
||
ClearAcaryAll(m_arPushPoint);
|
||
m_datas.ClearStep();
|
||
}
|
||
|