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
45c5a3de
Commit
45c5a3de
authored
Feb 13, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Placing modules with a minor bug.
parent
ba1867fe
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
21 deletions
+100
-21
pcbframe.cpp
pcbnew/pcbframe.cpp
+1
-18
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
+89
-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/pcbframe.cpp
View file @
45c5a3de
...
...
@@ -569,24 +569,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
// Load modules and its additional elements
for
(
MODULE
*
module
=
aBoard
->
m_Modules
;
module
;
module
=
module
->
Next
()
)
{
// Load module's pads
for
(
D_PAD
*
pad
=
module
->
Pads
().
GetFirst
();
pad
;
pad
=
pad
->
Next
()
)
{
view
->
Add
(
pad
);
}
// Load module's drawing (mostly silkscreen)
for
(
BOARD_ITEM
*
drawing
=
module
->
GraphicalItems
().
GetFirst
();
drawing
;
drawing
=
drawing
->
Next
()
)
{
view
->
Add
(
drawing
);
}
// Load module's texts (name and value)
view
->
Add
(
&
module
->
Reference
()
);
view
->
Add
(
&
module
->
Value
()
);
// Add the module itself
module
->
RunOnChildren
(
std
::
bind1st
(
std
::
mem_fun
(
&
KIGFX
::
VIEW
::
Add
),
view
)
);
view
->
Add
(
module
);
}
...
...
pcbnew/tools/common_actions.cpp
View file @
45c5a3de
...
...
@@ -80,3 +80,7 @@ TOOL_ACTION COMMON_ACTIONS::drawDimension( "pcbnew.InteractiveDrawing.dimension"
TOOL_ACTION
COMMON_ACTIONS
::
placeTarget
(
"pcbnew.InteractiveDrawing.placeTarget"
,
AS_GLOBAL
,
'C'
,
"Add layer alignment target"
,
"Add layer alignment target"
);
TOOL_ACTION
COMMON_ACTIONS
::
placeModule
(
"pcbnew.InteractiveDrawing.placeModule"
,
AS_GLOBAL
,
'V'
,
"Add modules"
,
"Add modules"
);
pcbnew/tools/common_actions.h
View file @
45c5a3de
...
...
@@ -74,4 +74,7 @@ public:
/// Activation of the drawing tool (placing a TARGET)
static
TOOL_ACTION
placeTarget
;
/// Activation of the drawing tool (placing a MODULE)
static
TOOL_ACTION
placeModule
;
};
pcbnew/tools/drawing_tool.cpp
View file @
45c5a3de
...
...
@@ -26,16 +26,20 @@
#include "common_actions.h"
#include <wxPcbStruct.h>
#include <confirm.h>
#include <view/view_group.h>
#include <view/view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <tool/tool_manager.h>
#include <class_board.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <class_mire.h>
#include <gal/graphics_abstraction_layer.h>
#include <tool/tool_manager.h>
#include <confirm.h>
#include <class_module.h>
#include <class_netinfo.h> // TODO to be removed if we do not need the flags
DRAWING_TOOL
::
DRAWING_TOOL
()
:
TOOL_INTERACTIVE
(
"pcbnew.InteractiveDrawing"
)
...
...
@@ -570,6 +574,8 @@ int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent )
target
->
SetLayer
(
EDGE_N
);
target
->
SetWidth
(
board
->
GetDesignSettings
().
m_EdgeSegmentWidth
);
target
->
SetSize
(
Millimeter2iu
(
5
)
);
VECTOR2D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
target
->
SetPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
view
);
...
...
@@ -630,6 +636,85 @@ int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent )
}
int
DRAWING_TOOL
::
PlaceModule
(
TOOL_EVENT
&
aEvent
)
{
KIGFX
::
VIEW
*
view
=
getView
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
BOARD
*
board
=
getModel
<
BOARD
>
(
PCB_T
);
PCB_EDIT_FRAME
*
editFrame
=
getEditFrame
<
PCB_EDIT_FRAME
>
();
MODULE
*
module
=
editFrame
->
LoadModuleFromLibrary
(
wxEmptyString
,
editFrame
->
GetFootprintLibraryTable
(),
true
,
NULL
);
if
(
module
==
NULL
)
{
setTransitions
();
return
0
;
}
// Init the new item attributes
VECTOR2D
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
module
->
SetPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
view
);
preview
.
Add
(
module
);
module
->
RunOnChildren
(
std
::
bind1st
(
std
::
mem_fun
(
&
KIGFX
::
VIEW_GROUP
::
Add
),
&
preview
)
);
view
->
Add
(
&
preview
);
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
controls
->
SetSnapping
(
true
);
Activate
();
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
cursorPos
=
view
->
ToWorld
(
controls
->
GetCursorPosition
()
);
if
(
evt
->
IsCancel
()
)
{
board
->
Delete
(
module
);
break
;
}
else
if
(
evt
->
Category
()
==
TC_COMMAND
)
{
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
rotate
)
)
{
module
->
Rotate
(
module
->
GetPosition
(),
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
GetRotationAngle
()
);
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
else
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
flip
)
)
{
module
->
Flip
(
module
->
GetPosition
()
);
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
}
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
module
->
RunOnChildren
(
std
::
bind1st
(
std
::
mem_fun
(
&
KIGFX
::
VIEW
::
Add
),
view
)
);
view
->
Add
(
module
);
module
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
break
;
}
else
if
(
evt
->
IsMotion
()
)
{
module
->
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
()
{
Go
(
&
DRAWING_TOOL
::
DrawLine
,
COMMON_ACTIONS
::
drawLine
.
MakeEvent
()
);
...
...
@@ -638,4 +723,5 @@ void DRAWING_TOOL::setTransitions()
Go
(
&
DRAWING_TOOL
::
DrawText
,
COMMON_ACTIONS
::
drawText
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
DrawDimension
,
COMMON_ACTIONS
::
drawDimension
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
PlaceTarget
,
COMMON_ACTIONS
::
placeTarget
.
MakeEvent
()
);
Go
(
&
DRAWING_TOOL
::
PlaceModule
,
COMMON_ACTIONS
::
placeModule
.
MakeEvent
()
);
}
pcbnew/tools/drawing_tool.h
View file @
45c5a3de
...
...
@@ -61,6 +61,8 @@ public:
int
PlaceTarget
(
TOOL_EVENT
&
aEvent
);
int
PlaceModule
(
TOOL_EVENT
&
aEvent
);
private
:
///> Starts drawing a selected shape.
int
draw
(
STROKE_T
aShape
);
...
...
pcbnew/tools/pcb_tools.cpp
View file @
45c5a3de
...
...
@@ -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
::
placeTarget
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
placeModule
);
// Register tools
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