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
3106d253
Commit
3106d253
authored
Feb 13, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added keepout areas drawing tool.
parent
fce753ba
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
155 additions
and
3 deletions
+155
-3
common_actions.cpp
pcbnew/tools/common_actions.cpp
+4
-0
common_actions.h
pcbnew/tools/common_actions.h
+3
-0
drawing_tool.cpp
pcbnew/tools/drawing_tool.cpp
+145
-3
drawing_tool.h
pcbnew/tools/drawing_tool.h
+2
-0
pcb_tools.cpp
pcbnew/tools/pcb_tools.cpp
+1
-0
No files found.
pcbnew/tools/common_actions.cpp
View file @
3106d253
...
...
@@ -81,6 +81,10 @@ TOOL_ACTION COMMON_ACTIONS::drawZone( "pcbnew.InteractiveDrawing.zone",
AS_GLOBAL
,
'B'
,
"Add a filled zone"
,
"Add a filled zone"
);
TOOL_ACTION
COMMON_ACTIONS
::
drawKeepout
(
"pcbnew.InteractiveDrawing.keepout"
,
AS_GLOBAL
,
'N'
,
"Add a keepout area"
,
"Add a keepout area"
);
TOOL_ACTION
COMMON_ACTIONS
::
placeTarget
(
"pcbnew.InteractiveDrawing.placeTarget"
,
AS_GLOBAL
,
'C'
,
"Add layer alignment target"
,
"Add layer alignment target"
);
...
...
pcbnew/tools/common_actions.h
View file @
3106d253
...
...
@@ -75,6 +75,9 @@ public:
/// Activation of the drawing tool (drawing a ZONE)
static
TOOL_ACTION
drawZone
;
/// Activation of the drawing tool (drawing a keepout area)
static
TOOL_ACTION
drawKeepout
;
/// Activation of the drawing tool (placing a TARGET)
static
TOOL_ACTION
placeTarget
;
...
...
pcbnew/tools/drawing_tool.cpp
View file @
3106d253
...
...
@@ -598,7 +598,6 @@ int DRAWING_TOOL::DrawZone( TOOL_EVENT& aEvent )
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
view
);
// preview.Add( zone );
view
->
Add
(
&
preview
);
controls
->
ShowCursor
(
true
);
...
...
@@ -705,8 +704,150 @@ int DRAWING_TOOL::DrawZone( TOOL_EVENT& aEvent )
controls
->
SetAutoPan
(
false
);
view
->
Remove
(
&
preview
);
// remove helper lines only
// preview.Remove( zone );
// delete helper lines
preview
.
FreeItems
();
setTransitions
();
return
0
;
}
int
DRAWING_TOOL
::
DrawKeepout
(
TOOL_EVENT
&
aEvent
)
{
KIGFX
::
VIEW
*
view
=
getView
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
BOARD
*
board
=
getModel
<
BOARD
>
(
PCB_T
);
ZONE_CONTAINER
*
keepout
=
new
ZONE_CONTAINER
(
board
);
PCB_EDIT_FRAME
*
editFrame
=
getEditFrame
<
PCB_EDIT_FRAME
>
();
// Get the current, default settings for zones
ZONE_SETTINGS
zoneInfo
=
editFrame
->
GetZoneSettings
();
ZONE_EDIT_T
dialogResult
=
InvokeKeepoutAreaEditor
(
editFrame
,
&
zoneInfo
);
if
(
dialogResult
==
ZONE_ABORT
)
{
delete
keepout
;
setTransitions
();
return
0
;
}
zoneInfo
.
ExportSetting
(
*
keepout
);
editFrame
->
SetTopLayer
(
zoneInfo
.
m_CurrentZone_Layer
);
DRAWSEGMENT
*
helperLine
=
new
DRAWSEGMENT
;
helperLine
->
SetShape
(
S_SEGMENT
);
helperLine
->
SetLayer
(
zoneInfo
.
m_CurrentZone_Layer
);
helperLine
->
SetWidth
(
1
);
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
view
);
view
->
Add
(
&
preview
);
controls
->
ShowCursor
(
true
);
controls
->
SetSnapping
(
true
);
controls
->
SetAutoPan
(
true
);
Activate
();
VECTOR2D
lastCursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
// Enable 45 degrees lines only mode by holding shift
bool
linesAngle45
=
evt
->
Modifier
(
MD_SHIFT
);
VECTOR2D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
if
(
evt
->
IsCancel
()
)
{
delete
keepout
;
break
;
}
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
if
(
lastCursorPos
==
cursorPos
||
(
keepout
->
GetNumCorners
()
>
0
&&
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
==
keepout
->
Outline
()
->
GetPos
(
0
)
)
)
// TODO better conditions
{
if
(
keepout
->
GetNumCorners
()
>
2
)
{
// Finish the zone
keepout
->
Outline
()
->
CloseLastContour
();
keepout
->
Outline
()
->
RemoveNullSegments
();
board
->
Add
(
keepout
);
view
->
Add
(
keepout
);
keepout
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
else
{
// That is not a valid zone
delete
keepout
;
}
break
;
}
else
{
if
(
keepout
->
GetNumCorners
()
==
0
)
{
keepout
->
Outline
()
->
Start
(
zoneInfo
.
m_CurrentZone_Layer
,
cursorPos
.
x
,
cursorPos
.
y
,
keepout
->
GetHatchStyle
()
);
helperLine
->
SetStart
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
preview
.
Add
(
helperLine
);
}
else
{
keepout
->
AppendCorner
(
helperLine
->
GetEnd
()
);
helperLine
=
new
DRAWSEGMENT
(
*
helperLine
);
preview
.
Add
(
helperLine
);
helperLine
->
SetStart
(
helperLine
->
GetEnd
()
);
}
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
lastCursorPos
=
cursorPos
;
}
else
if
(
evt
->
IsMotion
()
)
{
helperLine
->
SetEnd
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
// 45 degree lines
if
(
linesAngle45
)
{
VECTOR2D
lineVector
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
-
helperLine
->
GetStart
()
);
double
angle
=
lineVector
.
Angle
();
double
newAngle
=
round
(
angle
/
(
M_PI
/
4.0
)
)
*
M_PI
/
4.0
;
VECTOR2D
newLineVector
=
lineVector
.
Rotate
(
newAngle
-
angle
);
// Snap the new line to the grid // TODO fix it, does not work good..
VECTOR2D
newLineEnd
=
VECTOR2D
(
helperLine
->
GetStart
()
)
+
newLineVector
;
VECTOR2D
snapped
=
view
->
GetGAL
()
->
GetGridPoint
(
newLineEnd
);
helperLine
->
SetEnd
(
wxPoint
(
snapped
.
x
,
snapped
.
y
)
);
}
else
{
helperLine
->
SetEnd
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
}
// Show a preview of the item
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
}
controls
->
ShowCursor
(
false
);
controls
->
SetSnapping
(
false
);
controls
->
SetAutoPan
(
false
);
view
->
Remove
(
&
preview
);
// delete helper lines
preview
.
FreeItems
();
setTransitions
();
...
...
@@ -875,6 +1016,7 @@ void DRAWING_TOOL::setTransitions()
Go
(
&
DRAWING_TOOL
::
DrawText
,
COMMON_ACTIONS
::
drawText
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawDimension
,
COMMON_ACTIONS
::
drawDimension
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawZone
,
COMMON_ACTIONS
::
drawZone
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawKeepout
,
COMMON_ACTIONS
::
drawKeepout
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
PlaceTarget
,
COMMON_ACTIONS
::
placeTarget
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
PlaceModule
,
COMMON_ACTIONS
::
placeModule
.
MakeEvent
()
);
}
pcbnew/tools/drawing_tool.h
View file @
3106d253
...
...
@@ -61,6 +61,8 @@ public:
int
DrawZone
(
TOOL_EVENT
&
aEvent
);
int
DrawKeepout
(
TOOL_EVENT
&
aEvent
);
int
PlaceTarget
(
TOOL_EVENT
&
aEvent
);
int
PlaceModule
(
TOOL_EVENT
&
aEvent
);
...
...
pcbnew/tools/pcb_tools.cpp
View file @
3106d253
...
...
@@ -61,6 +61,7 @@ void PCB_EDIT_FRAME::setupTools()
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawText
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawDimension
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawZone
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawKeepout
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
placeTarget
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
placeModule
);
...
...
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