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
87d3458e
Commit
87d3458e
authored
Feb 11, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added PCB_TARGET placing tool.
parent
e43b5f7c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
2 deletions
+87
-2
target_edit.cpp
pcbnew/target_edit.cpp
+4
-2
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
+73
-0
drawing_tool.h
pcbnew/tools/drawing_tool.h
+2
-0
pcb_tools.cpp
pcbnew/tools/pcb_tools.cpp
+1
-0
No files found.
pcbnew/target_edit.cpp
View file @
87d3458e
...
@@ -127,6 +127,7 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& event )
...
@@ -127,6 +127,7 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& event )
*/
*/
void
TARGET_PROPERTIES_DIALOG_EDITOR
::
OnOkClick
(
wxCommandEvent
&
event
)
void
TARGET_PROPERTIES_DIALOG_EDITOR
::
OnOkClick
(
wxCommandEvent
&
event
)
{
{
if
(
m_DC
)
m_Target
->
Draw
(
m_Parent
->
GetCanvas
(),
m_DC
,
GR_XOR
);
m_Target
->
Draw
(
m_Parent
->
GetCanvas
(),
m_DC
,
GR_XOR
);
// Save old item in undo list, if is is not currently edited (will be later if so)
// Save old item in undo list, if is is not currently edited (will be later if so)
...
@@ -145,6 +146,7 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event )
...
@@ -145,6 +146,7 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event )
m_Target
->
SetShape
(
m_TargetShape
->
GetSelection
()
?
1
:
0
);
m_Target
->
SetShape
(
m_TargetShape
->
GetSelection
()
?
1
:
0
);
if
(
m_DC
)
m_Target
->
Draw
(
m_Parent
->
GetCanvas
(),
m_DC
,
(
m_Target
->
IsMoving
()
)
?
GR_XOR
:
GR_OR
);
m_Target
->
Draw
(
m_Parent
->
GetCanvas
(),
m_DC
,
(
m_Target
->
IsMoving
()
)
?
GR_XOR
:
GR_OR
);
m_Parent
->
OnModify
();
m_Parent
->
OnModify
();
...
...
pcbnew/tools/common_actions.cpp
View file @
87d3458e
...
@@ -76,3 +76,7 @@ TOOL_ACTION COMMON_ACTIONS::drawText( "pcbnew.InteractiveDrawing.text",
...
@@ -76,3 +76,7 @@ TOOL_ACTION COMMON_ACTIONS::drawText( "pcbnew.InteractiveDrawing.text",
TOOL_ACTION
COMMON_ACTIONS
::
drawDimension
(
"pcbnew.InteractiveDrawing.dimension"
,
TOOL_ACTION
COMMON_ACTIONS
::
drawDimension
(
"pcbnew.InteractiveDrawing.dimension"
,
AS_GLOBAL
,
'X'
,
AS_GLOBAL
,
'X'
,
"Add a dimension"
,
"Add a dimension"
);
"Add a dimension"
,
"Add a dimension"
);
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 @
87d3458e
...
@@ -71,4 +71,7 @@ public:
...
@@ -71,4 +71,7 @@ public:
/// Activation of the drawing tool (dimension)
/// Activation of the drawing tool (dimension)
static
TOOL_ACTION
drawDimension
;
static
TOOL_ACTION
drawDimension
;
/// Activation of the drawing tool (placing a TARGET)
static
TOOL_ACTION
placeTarget
;
};
};
pcbnew/tools/drawing_tool.cpp
View file @
87d3458e
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include <class_drawsegment.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <class_dimension.h>
#include <class_mire.h>
#include <gal/graphics_abstraction_layer.h>
#include <gal/graphics_abstraction_layer.h>
#include <tool/tool_manager.h>
#include <tool/tool_manager.h>
#include <confirm.h>
#include <confirm.h>
...
@@ -558,6 +559,77 @@ int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent )
...
@@ -558,6 +559,77 @@ int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent )
}
}
int
DRAWING_TOOL
::
PlaceTarget
(
TOOL_EVENT
&
aEvent
)
{
KIGFX
::
VIEW
*
view
=
getView
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
BOARD
*
board
=
getModel
<
BOARD
>
(
PCB_T
);
PCB_TARGET
*
target
=
new
PCB_TARGET
(
board
);
// Init the new item attributes
target
->
SetLayer
(
EDGE_N
);
target
->
SetWidth
(
board
->
GetDesignSettings
().
m_EdgeSegmentWidth
);
target
->
SetSize
(
Millimeter2iu
(
5
)
);
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
view
);
preview
.
Add
(
target
);
view
->
Add
(
&
preview
);
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
controls
->
SetSnapping
(
true
);
Activate
();
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
VECTOR2D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
if
(
evt
->
IsCancel
()
)
{
delete
target
;
break
;
}
else
if
(
evt
->
IsKeyUp
()
)
{
int
width
=
target
->
GetWidth
();
// Modify the new item width
if
(
evt
->
KeyCode
()
==
'-'
&&
width
>
WIDTH_STEP
)
target
->
SetWidth
(
width
-
WIDTH_STEP
);
else
if
(
evt
->
KeyCode
()
==
'='
)
target
->
SetWidth
(
width
+
WIDTH_STEP
);
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
view
->
Add
(
target
);
board
->
Add
(
target
);
target
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
break
;
}
else
if
(
evt
->
IsMotion
()
)
{
target
->
SetPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
}
controls
->
SetSnapping
(
false
);
controls
->
SetAutoPan
(
false
);
view
->
Remove
(
&
preview
);
setTransitions
();
return
0
;
}
void
DRAWING_TOOL
::
setTransitions
()
void
DRAWING_TOOL
::
setTransitions
()
{
{
Go
(
&
DRAWING_TOOL
::
DrawLine
,
COMMON_ACTIONS
::
drawLine
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawLine
,
COMMON_ACTIONS
::
drawLine
.
MakeEvent
()
);
...
@@ -565,4 +637,5 @@ void DRAWING_TOOL::setTransitions()
...
@@ -565,4 +637,5 @@ void DRAWING_TOOL::setTransitions()
Go
(
&
DRAWING_TOOL
::
DrawArc
,
COMMON_ACTIONS
::
drawArc
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawArc
,
COMMON_ACTIONS
::
drawArc
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawText
,
COMMON_ACTIONS
::
drawText
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawText
,
COMMON_ACTIONS
::
drawText
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawDimension
,
COMMON_ACTIONS
::
drawDimension
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawDimension
,
COMMON_ACTIONS
::
drawDimension
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
PlaceTarget
,
COMMON_ACTIONS
::
placeTarget
.
MakeEvent
()
);
}
}
pcbnew/tools/drawing_tool.h
View file @
87d3458e
...
@@ -59,6 +59,8 @@ public:
...
@@ -59,6 +59,8 @@ public:
int
DrawDimension
(
TOOL_EVENT
&
aEvent
);
int
DrawDimension
(
TOOL_EVENT
&
aEvent
);
int
PlaceTarget
(
TOOL_EVENT
&
aEvent
);
private
:
private
:
///> Starts drawing a selected shape.
///> Starts drawing a selected shape.
int
draw
(
STROKE_T
aShape
);
int
draw
(
STROKE_T
aShape
);
...
...
pcbnew/tools/pcb_tools.cpp
View file @
87d3458e
...
@@ -60,6 +60,7 @@ void PCB_EDIT_FRAME::setupTools()
...
@@ -60,6 +60,7 @@ void PCB_EDIT_FRAME::setupTools()
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawArc
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawArc
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawText
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawText
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawDimension
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
drawDimension
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
placeTarget
);
// Register tools
// Register tools
m_toolManager
->
RegisterTool
(
new
SELECTION_TOOL
);
m_toolManager
->
RegisterTool
(
new
SELECTION_TOOL
);
...
...
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