-
Notifications
You must be signed in to change notification settings - Fork 41
/
CJig.cpp
82 lines (73 loc) · 1.62 KB
/
CJig.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "stdafx.h"
#include "CJig.h"
#include "CDwgDatebaseUtil.h"
#include "dbjig.h"
#define PI 3.141592654
CJig::CJig()
{
m_pPoly = NULL;
}
CJig::~CJig()
{
}
bool CJig::doit(const AcGePoint3d & centerPoint, AcDbObjectId & polyid)
{
m_centerPoint = centerPoint;
//拖动开始前,将多线段创建出来
m_pPoly = new AcDbPolyline();
for (int i = 0; i < 4; i++)
{
m_pPoly->addVertexAt(i, AcGePoint2d(m_centerPoint.x, m_centerPoint.y));
}
m_pPoly->setClosed(true);
//进入拖到流程
CString prompt = _T("\n指定标注插入点: ");
setDispPrompt(prompt);
AcEdJig::DragStatus status = drag();
//拖动结束,函数返回部分
if (status==kNormal)
{
polyid = CDwgDatebaseUtil::PostToModelSpace(m_pPoly);
return true;
}
else
{
delete m_pPoly;
return false;
}
}
AcEdJig::DragStatus CJig::sampler()
{
setUserInputControls((UserInputControls)(AcEdJig::kAccept3dCoordinates | AcEdJig::kNoNegativeResponseAccepted | AcEdJig::kNullResponseAccepted));
//判断点是否发生了变化
static AcGePoint3d pointtem;
DragStatus sta = acquirePoint(m_curPoint);
if (pointtem!=m_curPoint)
{
pointtem = m_curPoint;
}
else if (sta==kNormal)
{
return DragStatus::kNoChange;
}
return sta;
}
Adesk::Boolean CJig::update()
{
//更新操作
AcGePoint2d center(m_centerPoint.x, m_centerPoint.y);
AcGePoint2d curpoint(m_curPoint.x, m_curPoint.y);
double dist = center.distanceTo(curpoint);
for (int i = 0; i < 4; i++)
{
double angle = i * PI*0.5 + PI * 0.25;
AcGePoint2d pt(center.x + dist * cos(angle), center.y + dist * sin(angle));
m_pPoly->setPointAt(i, pt);
}
return Adesk::kTrue;
}
AcDbEntity * CJig::entity() const
{
return m_pPoly;
return nullptr;
}