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
cc72e585
Commit
cc72e585
authored
Mar 10, 2015
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed segfault in arc drawing tool (GAL footprint editor).
parent
143f52eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
37 deletions
+29
-37
drawing_tool.cpp
pcbnew/tools/drawing_tool.cpp
+29
-37
No files found.
pcbnew/tools/drawing_tool.cpp
View file @
cc72e585
...
...
@@ -83,18 +83,17 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
{
m_frame
->
SetToolID
(
ID_MODEDIT_LINE_TOOL
,
wxCURSOR_PENCIL
,
_
(
"Add graphic line"
)
);
MODULE
*
module
=
m_board
->
m_Modules
;
EDGE_MODULE
*
line
=
new
EDGE_MODULE
(
module
);
EDGE_MODULE
*
line
=
new
EDGE_MODULE
(
m_board
->
m_Modules
);
while
(
drawSegment
(
S_SEGMENT
,
reinterpret_cast
<
DRAWSEGMENT
*&>
(
line
),
startingPoint
)
)
{
if
(
line
)
{
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
module
,
UR_MODEDIT
);
m_frame
->
SaveCopyInUndoList
(
m_board
->
m_Modules
,
UR_MODEDIT
);
line
->
SetParent
(
m_board
->
m_Modules
);
line
->
SetLocalCoord
();
line
->
SetParent
(
module
);
module
->
GraphicalItems
().
PushFront
(
line
);
m_board
->
m_Modules
->
GraphicalItems
().
PushFront
(
line
);
startingPoint
=
line
->
GetEnd
();
}
else
...
...
@@ -102,7 +101,7 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
startingPoint
=
boost
::
none
;
}
line
=
new
EDGE_MODULE
(
m
odule
);
line
=
new
EDGE_MODULE
(
m
_board
->
m_Modules
);
}
}
else
...
...
@@ -142,21 +141,20 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
{
m_frame
->
SetToolID
(
ID_MODEDIT_CIRCLE_TOOL
,
wxCURSOR_PENCIL
,
_
(
"Add graphic circle"
)
);
MODULE
*
module
=
m_board
->
m_Modules
;
EDGE_MODULE
*
circle
=
new
EDGE_MODULE
(
module
);
EDGE_MODULE
*
circle
=
new
EDGE_MODULE
(
m_board
->
m_Modules
);
while
(
drawSegment
(
S_CIRCLE
,
reinterpret_cast
<
DRAWSEGMENT
*&>
(
circle
)
)
)
{
if
(
circle
)
{
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
module
,
UR_MODEDIT
);
m_frame
->
SaveCopyInUndoList
(
m_board
->
m_Modules
,
UR_MODEDIT
);
circle
->
SetParent
(
m_board
->
m_Modules
);
circle
->
SetLocalCoord
();
circle
->
SetParent
(
module
);
module
->
GraphicalItems
().
PushFront
(
circle
);
m_board
->
m_Modules
->
GraphicalItems
().
PushFront
(
circle
);
}
circle
=
new
EDGE_MODULE
(
m
odule
);
circle
=
new
EDGE_MODULE
(
m
_board
->
m_Modules
);
}
}
else
...
...
@@ -191,21 +189,20 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
{
m_frame
->
SetToolID
(
ID_MODEDIT_ARC_TOOL
,
wxCURSOR_PENCIL
,
_
(
"Add graphic arc"
)
);
MODULE
*
module
=
m_board
->
m_Modules
;
EDGE_MODULE
*
arc
=
new
EDGE_MODULE
(
module
);
EDGE_MODULE
*
arc
=
new
EDGE_MODULE
(
m_board
->
m_Modules
);
while
(
drawArc
(
reinterpret_cast
<
DRAWSEGMENT
*&>
(
arc
)
)
)
{
if
(
arc
)
{
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
module
,
UR_MODEDIT
);
m_frame
->
SaveCopyInUndoList
(
m_board
->
m_Modules
,
UR_MODEDIT
);
arc
->
SetParent
(
m_board
->
m_Modules
);
arc
->
SetLocalCoord
();
arc
->
SetParent
(
module
);
module
->
GraphicalItems
().
PushFront
(
arc
);
m_board
->
m_Modules
->
GraphicalItems
().
PushFront
(
arc
);
}
arc
=
new
EDGE_MODULE
(
m
odule
);
arc
=
new
EDGE_MODULE
(
m
_board
->
m_Modules
);
}
}
else
...
...
@@ -642,9 +639,8 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
int
dlgResult
=
dlg
.
ShowModal
();
const
std
::
list
<
BOARD_ITEM
*>&
list
=
dlg
.
GetImportedItems
();
MODULE
*
module
=
m_board
->
m_Modules
;
if
(
dlgResult
!=
wxID_OK
||
m
odule
==
NULL
||
list
.
empty
()
)
if
(
dlgResult
!=
wxID_OK
||
m
_board
->
m_Modules
==
NULL
||
list
.
empty
()
)
{
setTransitions
();
...
...
@@ -672,7 +668,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
{
if
(
m_editModules
)
{
converted
=
new
EDGE_MODULE
(
m
odule
);
converted
=
new
EDGE_MODULE
(
m
_board
->
m_Modules
);
*
static_cast
<
DRAWSEGMENT
*>
(
converted
)
=
*
static_cast
<
DRAWSEGMENT
*>
(
item
);
converted
->
Move
(
wxPoint
(
delta
.
x
,
delta
.
y
)
);
preview
.
Add
(
converted
);
...
...
@@ -690,7 +686,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
{
if
(
m_editModules
)
{
converted
=
new
TEXTE_MODULE
(
m
odule
);
converted
=
new
TEXTE_MODULE
(
m
_board
->
m_Modules
);
*
static_cast
<
TEXTE_PCB
*>
(
converted
)
=
*
static_cast
<
TEXTE_PCB
*>
(
item
);
converted
->
Move
(
wxPoint
(
delta
.
x
,
delta
.
y
)
);
preview
.
Add
(
converted
);
...
...
@@ -760,16 +756,15 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
// Place the drawing
if
(
m_editModules
)
{
m_frame
->
SaveCopyInUndoList
(
m
odule
,
UR_MODEDIT
);
m
odule
->
SetLastEditTime
();
m_frame
->
SaveCopyInUndoList
(
m
_board
->
m_Modules
,
UR_MODEDIT
);
m
_board
->
m_Modules
->
SetLastEditTime
();
for
(
KIGFX
::
VIEW_GROUP
::
iter
it
=
preview
.
Begin
(),
end
=
preview
.
End
();
it
!=
end
;
++
it
)
{
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
*
it
);
m
odule
->
Add
(
item
);
m
_board
->
m_Modules
->
Add
(
item
);
switch
(
item
->
Type
()
)
{
...
...
@@ -843,16 +838,14 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
{
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
MODULE
*
module
=
m_board
->
m_Modules
;
m_frame
->
SaveCopyInUndoList
(
module
,
UR_MODEDIT
);
m_frame
->
SaveCopyInUndoList
(
m_board
->
m_Modules
,
UR_MODEDIT
);
// set the new relative internal local coordinates of footprint items
VECTOR2I
cursorPos
=
controls
->
GetCursorPosition
();
wxPoint
moveVector
=
m
odule
->
GetPosition
()
-
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
);
m
odule
->
MoveAnchorPosition
(
moveVector
);
wxPoint
moveVector
=
m
_board
->
m_Modules
->
GetPosition
()
-
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
);
m
_board
->
m_Modules
->
MoveAnchorPosition
(
moveVector
);
m
odule
->
ViewUpdate
();
m
_board
->
m_Modules
->
ViewUpdate
();
// Usually, we do not need to change twice the anchor position,
// so deselect the active tool
...
...
@@ -1435,7 +1428,6 @@ int DRAWING_TOOL::placeTextModule()
{
TEXTE_MODULE
*
text
=
new
TEXTE_MODULE
(
NULL
);
const
BOARD_DESIGN_SETTINGS
&
dsnSettings
=
m_frame
->
GetDesignSettings
();
MODULE
*
module
=
m_board
->
m_Modules
;
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
m_view
);
...
...
@@ -1501,8 +1493,8 @@ int DRAWING_TOOL::placeTextModule()
continue
;
m_controls
->
ShowCursor
(
false
);
text
->
SetParent
(
m
odule
);
// it has to set after the settings dialog
// otherwise the dialog stores it in undo buffer
text
->
SetParent
(
m
_board
->
m_Modules
);
// it has to set after the settings dialog
// otherwise the dialog stores it in undo buffer
preview
.
Add
(
text
);
}
else
...
...
@@ -1514,8 +1506,8 @@ int DRAWING_TOOL::placeTextModule()
text
->
ClearFlags
();
// Module has to be saved before any modification is made
m_frame
->
SaveCopyInUndoList
(
m
odule
,
UR_MODEDIT
);
m
odule
->
GraphicalItems
().
PushFront
(
text
);
m_frame
->
SaveCopyInUndoList
(
m
_board
->
m_Modules
,
UR_MODEDIT
);
m
_board
->
m_Modules
->
GraphicalItems
().
PushFront
(
text
);
m_view
->
Add
(
text
);
text
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
...
...
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