-
-
Notifications
You must be signed in to change notification settings - Fork 557
/
Copy pathlinesegment.cpp
203 lines (164 loc) · 3.9 KB
/
linesegment.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// This file is a part of "grblControl" application.
// This file was originally ported from "LineSegment.java" class
// of "Universal GcodeSender" application written by Will Winder
// (https://github.com/winder/Universal-G-Code-Sender)
// Copyright 2015 Hayrullin Denis Ravilevich
#include "linesegment.h"
#include <QDebug>
LineSegment::LineSegment(QObject *parent) :
QObject(parent)
{
m_toolhead = 0; //DEFAULT TOOLHEAD ASSUMED TO BE 0!
m_isZMovement = false;
m_isArc = false;
m_isFastTraverse = false;
m_drawn = false;
m_isMetric = true;
m_isAbsolute = true;
m_isHightlight = false;
m_vertexIndex = -1;
}
LineSegment::LineSegment(QVector3D a, QVector3D b, int num) : LineSegment()
{
// m_toolhead = 0; //DEFAULT TOOLHEAD ASSUMED TO BE 0!
// m_isZMovement = false;
// m_isArc = false;
// m_isFastTraverse = false;
m_first = a;
m_second = b;
m_lineNumber = num;
}
LineSegment::LineSegment(LineSegment* initial)
{
m_toolhead = initial->getToolhead();
m_isZMovement = initial->isZMovement();
m_isArc = initial->isArc();
m_isFastTraverse = initial->isFastTraverse();
m_drawn = initial->drawn();
m_first = initial->getStart();
m_second = initial->getEnd();
m_lineNumber = initial->getLineNumber();
m_speed = initial->getSpeed();
m_isMetric = initial->isMetric();
m_isAbsolute = initial->isAbsolute();
m_isHightlight = initial->isHightlight();
m_vertexIndex = initial->vertexIndex();
}
LineSegment::~LineSegment()
{
}
int LineSegment::getLineNumber() {
return m_lineNumber;
}
QList<QVector3D> LineSegment::getPointArray()
{
QList<QVector3D> pointarr;
pointarr.append(m_first);
pointarr.append(m_second);
return pointarr;
}
QList<double> LineSegment::getPoints()
{
QList<double> points;
points.append(m_first.x());
points.append(m_first.y());
points.append(m_first.z());
points.append(m_second.x());
points.append(m_second.y());
points.append(m_second.z());
return points;
}
QVector3D LineSegment::getStart() {
return this->m_first;
}
void LineSegment::setStart(QVector3D vector)
{
m_first = vector;
}
QVector3D LineSegment::getEnd() {
return this->m_second;
}
void LineSegment::setEnd(QVector3D vector)
{
m_second = vector;
}
void LineSegment::setToolHead(int head) {
this->m_toolhead = head;
}
int LineSegment::getToolhead()
{
return m_toolhead;
}
void LineSegment::setSpeed(double s) {
this->m_speed = s;
}
double LineSegment::getSpeed()
{
return m_speed;
}
void LineSegment::setIsZMovement(bool isZ) {
this->m_isZMovement = isZ;
}
bool LineSegment::isZMovement() {
return m_isZMovement;
}
void LineSegment::setIsArc(bool isA) {
this->m_isArc = isA;
}
bool LineSegment::isArc() {
return m_isArc;
}
void LineSegment::setIsFastTraverse(bool isF) {
this->m_isFastTraverse = isF;
}
bool LineSegment::isFastTraverse() {
return this->m_isFastTraverse;
}
bool LineSegment::contains(QVector3D point)
{
double delta;
QVector3D line = this->getEnd() - this->getStart();
QVector3D pt = point - this->getStart();
delta = (line - pt).length() - (line.length() - pt.length());
return delta < 0.01;
}
bool LineSegment::drawn() const
{
return m_drawn;
}
void LineSegment::setDrawn(bool drawn)
{
m_drawn = drawn;
}
bool LineSegment::isMetric() const
{
return m_isMetric;
}
void LineSegment::setIsMetric(bool isMetric)
{
m_isMetric = isMetric;
}
bool LineSegment::isAbsolute() const
{
return m_isAbsolute;
}
void LineSegment::setIsAbsolute(bool isAbsolute)
{
m_isAbsolute = isAbsolute;
}
bool LineSegment::isHightlight() const
{
return m_isHightlight;
}
void LineSegment::setIsHightlight(bool isHightlight)
{
m_isHightlight = isHightlight;
}
int LineSegment::vertexIndex() const
{
return m_vertexIndex;
}
void LineSegment::setVertexIndex(int vertexIndex)
{
m_vertexIndex = vertexIndex;
}