Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
342fd6e1
Commit
342fd6e1
authored
Mar 18, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EC_CONVERGING handles colinear lines properly.
parent
4d6f628a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
13 deletions
+35
-13
seg.h
include/geometry/seg.h
+8
-8
edit_points.cpp
pcbnew/tools/edit_points.cpp
+23
-5
edit_points.h
pcbnew/tools/edit_points.h
+4
-0
No files found.
include/geometry/seg.h
View file @
342fd6e1
...
@@ -244,14 +244,14 @@ public:
...
@@ -244,14 +244,14 @@ public:
*/
*/
bool
Collinear
(
const
SEG
&
aSeg
)
const
bool
Collinear
(
const
SEG
&
aSeg
)
const
{
{
ecoord
qa
1
=
A
.
y
-
B
.
y
;
ecoord
qa
=
A
.
y
-
B
.
y
;
ecoord
qb
1
=
B
.
x
-
A
.
x
;
ecoord
qb
=
B
.
x
-
A
.
x
;
ecoord
qc
1
=
-
qa1
*
A
.
x
-
qb1
*
A
.
y
;
ecoord
qc
=
-
qa
*
A
.
x
-
qb
*
A
.
y
;
ecoord
qa2
=
aSeg
.
A
.
y
-
aSeg
.
B
.
y
;
ecoord
qb2
=
aSeg
.
B
.
x
-
aSeg
.
A
.
x
;
ecoord
d1
=
std
::
abs
(
aSeg
.
A
.
x
*
qa
+
aSeg
.
A
.
y
*
qb
+
qc
)
;
ecoord
qc2
=
-
qa2
*
aSeg
.
A
.
x
-
qb2
*
aSeg
.
A
.
y
;
ecoord
d2
=
std
::
abs
(
aSeg
.
B
.
x
*
qa
+
aSeg
.
B
.
y
*
qb
+
qc
)
;
return
(
qa1
==
qa2
)
&&
(
qb1
==
qb2
)
&&
(
qc1
==
qc2
);
return
(
d1
<=
1
&&
d2
<=
1
);
}
}
/**
/**
...
...
pcbnew/tools/edit_points.cpp
View file @
342fd6e1
...
@@ -194,7 +194,8 @@ void EC_CIRCLE::Apply( EDIT_POINT& aHandle )
...
@@ -194,7 +194,8 @@ void EC_CIRCLE::Apply( EDIT_POINT& aHandle )
EC_CONVERGING
::
EC_CONVERGING
(
EDIT_LINE
&
aLine
,
EDIT_POINTS
&
aPoints
)
:
EC_CONVERGING
::
EC_CONVERGING
(
EDIT_LINE
&
aLine
,
EDIT_POINTS
&
aPoints
)
:
EDIT_CONSTRAINT
<
EDIT_POINT
>
(
aLine
.
GetOrigin
()
),
m_line
(
aLine
),
m_editPoints
(
aPoints
)
EDIT_CONSTRAINT
<
EDIT_POINT
>
(
aLine
.
GetOrigin
()
),
m_colinearConstraint
(
NULL
),
m_line
(
aLine
),
m_editPoints
(
aPoints
)
{
{
// Dragged segment endings
// Dragged segment endings
EDIT_POINT
&
origin
=
aLine
.
GetOrigin
();
EDIT_POINT
&
origin
=
aLine
.
GetOrigin
();
...
@@ -209,7 +210,17 @@ EC_CONVERGING::EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ) :
...
@@ -209,7 +210,17 @@ EC_CONVERGING::EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ) :
m_endSideConstraint
=
new
EC_LINE
(
end
,
nextEnd
);
m_endSideConstraint
=
new
EC_LINE
(
end
,
nextEnd
);
// Store the current vector of the line
// Store the current vector of the line
m_draggedVector
=
end
.
GetPosition
()
-
origin
.
GetPosition
()
;
m_draggedVector
=
end
.
GetPosition
()
-
origin
.
GetPosition
();
// Check for colinearity
SEG
originSide
(
origin
.
GetPosition
(),
prevOrigin
.
GetPosition
()
);
SEG
endSide
(
end
.
GetPosition
(),
nextEnd
.
GetPosition
()
);
SEG
dragged
(
origin
.
GetPosition
(),
end
.
GetPosition
()
);
if
(
dragged
.
Collinear
(
originSide
)
)
m_colinearConstraint
=
m_originSideConstraint
;
else
if
(
dragged
.
Collinear
(
endSide
)
)
m_colinearConstraint
=
m_endSideConstraint
;
}
}
...
@@ -217,18 +228,25 @@ EC_CONVERGING::~EC_CONVERGING()
...
@@ -217,18 +228,25 @@ EC_CONVERGING::~EC_CONVERGING()
{
{
delete
m_originSideConstraint
;
delete
m_originSideConstraint
;
delete
m_endSideConstraint
;
delete
m_endSideConstraint
;
// m_colinearConstraint should not be freed, it is a pointer to one of the above
}
}
void
EC_CONVERGING
::
Apply
(
EDIT_POINT
&
aHandle
)
void
EC_CONVERGING
::
Apply
(
EDIT_POINT
&
aHandle
)
{
{
// The dragged segment
SEG
dragged
(
m_line
.
GetPosition
(),
m_line
.
GetPosition
()
+
m_draggedVector
);
// The dragged segment endpoints
// The dragged segment endpoints
EDIT_POINT
&
origin
=
m_line
.
GetOrigin
();
EDIT_POINT
&
origin
=
m_line
.
GetOrigin
();
EDIT_POINT
&
end
=
m_line
.
GetEnd
();
EDIT_POINT
&
end
=
m_line
.
GetEnd
();
if
(
m_colinearConstraint
)
{
m_colinearConstraint
->
Apply
(
origin
);
m_colinearConstraint
->
Apply
(
end
);
}
// The dragged segment
SEG
dragged
(
origin
.
GetPosition
(),
origin
.
GetPosition
()
+
m_draggedVector
);
// Do not allow points on the adjacent segments move freely
// Do not allow points on the adjacent segments move freely
m_originSideConstraint
->
Apply
();
m_originSideConstraint
->
Apply
();
m_endSideConstraint
->
Apply
();
m_endSideConstraint
->
Apply
();
...
...
pcbnew/tools/edit_points.h
View file @
342fd6e1
...
@@ -622,6 +622,10 @@ private:
...
@@ -622,6 +622,10 @@ private:
///> Constraint for end side segment.
///> Constraint for end side segment.
EDIT_CONSTRAINT
<
EDIT_POINT
>*
m_endSideConstraint
;
EDIT_CONSTRAINT
<
EDIT_POINT
>*
m_endSideConstraint
;
///> Additional constriant, applied when at least two points are collinear. It is a pointer to
///> m_[origin/end]SideConstraint, so it should not be freed.
EDIT_CONSTRAINT
<
EDIT_POINT
>*
m_colinearConstraint
;
///> Dragged segment.
///> Dragged segment.
EDIT_LINE
&
m_line
;
EDIT_LINE
&
m_line
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment