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
3927c667
Commit
3927c667
authored
Mar 07, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added documentation. Moved some functions from .h to .cpp files.
parent
88a0311a
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
321 additions
and
113 deletions
+321
-113
edit_points.cpp
pcbnew/tools/edit_points.cpp
+96
-0
edit_points.h
pcbnew/tools/edit_points.h
+223
-111
point_editor.cpp
pcbnew/tools/point_editor.cpp
+2
-1
point_editor.h
pcbnew/tools/point_editor.h
+0
-1
No files found.
pcbnew/tools/edit_points.cpp
View file @
3927c667
...
...
@@ -29,6 +29,17 @@
#include <class_drawsegment.h>
bool
EDIT_POINT
::
WithinPoint
(
const
VECTOR2I
&
aPoint
,
unsigned
int
aSize
)
const
{
// Corners of the square
VECTOR2I
topLeft
=
GetPosition
()
-
aSize
;
VECTOR2I
bottomRight
=
GetPosition
()
+
aSize
;
return
(
aPoint
.
x
>
topLeft
.
x
&&
aPoint
.
y
>
topLeft
.
y
&&
aPoint
.
x
<
bottomRight
.
x
&&
aPoint
.
y
<
bottomRight
.
y
);
}
EDIT_POINTS
::
EDIT_POINTS
(
EDA_ITEM
*
aParent
)
:
EDA_ITEM
(
NOT_USED
),
m_parent
(
aParent
)
{
...
...
@@ -61,6 +72,62 @@ EDIT_POINT* EDIT_POINTS::FindPoint( const VECTOR2I& aLocation )
}
EDIT_POINT
*
EDIT_POINTS
::
Previous
(
const
EDIT_POINT
&
aPoint
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_points
.
size
();
++
i
)
{
if
(
m_points
[
i
]
==
aPoint
)
{
if
(
i
==
0
)
return
&
m_points
[
m_points
.
size
()
-
1
];
else
return
&
m_points
[
i
-
1
];
}
}
for
(
unsigned
int
i
=
0
;
i
<
m_lines
.
size
();
++
i
)
{
if
(
m_lines
[
i
]
==
aPoint
)
{
if
(
i
==
0
)
return
&
m_lines
[
m_lines
.
size
()
-
1
];
else
return
&
m_lines
[
i
-
1
];
}
}
return
NULL
;
}
EDIT_POINT
*
EDIT_POINTS
::
Next
(
const
EDIT_POINT
&
aPoint
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_points
.
size
();
++
i
)
{
if
(
m_points
[
i
]
==
aPoint
)
{
if
(
i
==
m_points
.
size
()
-
1
)
return
&
m_points
[
0
];
else
return
&
m_points
[
i
+
1
];
}
}
for
(
unsigned
int
i
=
0
;
i
<
m_lines
.
size
();
++
i
)
{
if
(
m_lines
[
i
]
==
aPoint
)
{
if
(
i
==
m_lines
.
size
()
-
1
)
return
&
m_lines
[
0
];
else
return
&
m_lines
[
i
+
1
];
}
}
return
NULL
;
}
void
EDIT_POINTS
::
ViewDraw
(
int
aLayer
,
KIGFX
::
GAL
*
aGal
)
const
{
aGal
->
SetFillColor
(
KIGFX
::
COLOR4D
(
1.0
,
1.0
,
1.0
,
1.0
)
);
...
...
@@ -79,3 +146,32 @@ void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
aGal
->
PopDepth
();
}
void
EPC_45DEGREE
::
Apply
()
{
// Current line vector
VECTOR2I
lineVector
(
m_constrained
.
GetPosition
()
-
m_constrainer
.
GetPosition
()
);
double
angle
=
lineVector
.
Angle
();
// Find the closest angle, which is a multiple of 45 degrees
double
newAngle
=
round
(
angle
/
(
M_PI
/
4.0
)
)
*
M_PI
/
4.0
;
VECTOR2I
newLineVector
=
lineVector
.
Rotate
(
newAngle
-
angle
);
m_constrained
.
SetPosition
(
m_constrainer
.
GetPosition
()
+
newLineVector
);
}
void
EPC_CIRCLE
::
Apply
()
{
VECTOR2I
centerToEnd
=
m_end
.
GetPosition
()
-
m_center
.
GetPosition
();
VECTOR2I
centerToPoint
=
m_constrained
.
GetPosition
()
-
m_center
.
GetPosition
();
int
radius
=
centerToEnd
.
EuclideanNorm
();
double
angle
=
centerToPoint
.
Angle
();
VECTOR2I
newLine
(
radius
,
0
);
newLine
=
newLine
.
Rotate
(
angle
);
m_constrained
.
SetPosition
(
m_center
.
GetPosition
()
+
newLine
);
}
pcbnew/tools/edit_points.h
View file @
3927c667
This diff is collapsed.
Click to expand it.
pcbnew/tools/point_editor.cpp
View file @
3927c667
...
...
@@ -159,6 +159,7 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
KIGFX
::
VIEW
*
view
=
getView
();
PCB_EDIT_FRAME
*
editFrame
=
getEditFrame
<
PCB_EDIT_FRAME
>
();
EDA_ITEM
*
item
=
selection
.
items
.
GetPickedItem
(
0
);
EDIT_POINT
constrainer
(
VECTOR2I
(
0
,
0
)
);
m_editPoints
=
EDIT_POINTS_FACTORY
::
Make
(
item
);
if
(
!
m_editPoints
)
...
...
@@ -220,7 +221,7 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
if
(
!
m_dragPoint
->
IsConstrained
()
)
{
// Find a proper constraining point for 45 degrees mode
EDIT_POINT
constrainer
=
get45DegConstrainer
();
constrainer
=
get45DegConstrainer
();
m_dragPoint
->
SetConstraint
(
new
EPC_45DEGREE
(
*
m_dragPoint
,
constrainer
)
);
}
}
...
...
pcbnew/tools/point_editor.h
View file @
3927c667
...
...
@@ -37,7 +37,6 @@ class SELECTION_TOOL;
*
* Tool that displays edit points allowing to modify items by dragging the points.
*/
class
POINT_EDITOR
:
public
TOOL_INTERACTIVE
{
public
:
...
...
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