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
a6484f1a
Commit
a6484f1a
authored
Jul 09, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drawing tools used to crash when the drawing tool was interrupted - fixed.
parent
b42091bc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
32 deletions
+53
-32
drawing_tool.cpp
pcbnew/tools/drawing_tool.cpp
+51
-30
drawing_tool.h
pcbnew/tools/drawing_tool.h
+2
-2
No files found.
pcbnew/tools/drawing_tool.cpp
View file @
a6484f1a
...
...
@@ -83,13 +83,16 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
MODULE
*
module
=
m_board
->
m_Modules
;
EDGE_MODULE
*
line
=
new
EDGE_MODULE
(
module
);
while
(
drawSegment
(
S_SEGMENT
,
line
)
)
while
(
drawSegment
(
S_SEGMENT
,
reinterpret_cast
<
DRAWSEGMENT
*&>
(
line
)
)
)
{
if
(
line
)
{
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
module
,
UR_MODEDIT
);
line
->
SetLocalCoord
();
line
->
SetParent
(
module
);
module
->
GraphicalItems
().
PushFront
(
line
);
}
line
=
new
EDGE_MODULE
(
module
);
}
...
...
@@ -101,10 +104,13 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
DRAWSEGMENT
*
line
=
new
DRAWSEGMENT
;
while
(
drawSegment
(
S_SEGMENT
,
line
)
)
{
if
(
line
)
{
m_board
->
Add
(
line
);
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
line
,
UR_NEW
);
}
line
=
new
DRAWSEGMENT
;
}
...
...
@@ -126,13 +132,16 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
MODULE
*
module
=
m_board
->
m_Modules
;
EDGE_MODULE
*
circle
=
new
EDGE_MODULE
(
module
);
while
(
drawSegment
(
S_CIRCLE
,
circle
)
)
while
(
drawSegment
(
S_CIRCLE
,
reinterpret_cast
<
DRAWSEGMENT
*&>
(
circle
)
)
)
{
if
(
circle
)
{
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
module
,
UR_MODEDIT
);
circle
->
SetLocalCoord
();
circle
->
SetParent
(
module
);
module
->
GraphicalItems
().
PushFront
(
circle
);
}
circle
=
new
EDGE_MODULE
(
module
);
}
...
...
@@ -144,10 +153,13 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent )
DRAWSEGMENT
*
circle
=
new
DRAWSEGMENT
;
while
(
drawSegment
(
S_CIRCLE
,
circle
)
)
{
if
(
circle
)
{
m_board
->
Add
(
circle
);
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
circle
,
UR_NEW
);
}
circle
=
new
DRAWSEGMENT
;
}
...
...
@@ -169,13 +181,16 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
MODULE
*
module
=
m_board
->
m_Modules
;
EDGE_MODULE
*
arc
=
new
EDGE_MODULE
(
module
);
while
(
drawArc
(
arc
)
)
while
(
drawArc
(
reinterpret_cast
<
DRAWSEGMENT
*&>
(
arc
)
)
)
{
if
(
arc
)
{
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
module
,
UR_MODEDIT
);
arc
->
SetLocalCoord
();
arc
->
SetParent
(
module
);
module
->
GraphicalItems
().
PushFront
(
arc
);
}
arc
=
new
EDGE_MODULE
(
module
);
}
...
...
@@ -187,10 +202,13 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent )
DRAWSEGMENT
*
arc
=
new
DRAWSEGMENT
;
while
(
drawArc
(
arc
)
)
{
if
(
arc
)
{
m_board
->
Add
(
arc
);
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
arc
,
UR_NEW
);
}
arc
=
new
DRAWSEGMENT
;
}
...
...
@@ -939,7 +957,7 @@ int DRAWING_TOOL::SetAnchor( TOOL_EVENT& aEvent )
}
bool
DRAWING_TOOL
::
drawSegment
(
int
aShape
,
DRAWSEGMENT
*
aGraphic
)
bool
DRAWING_TOOL
::
drawSegment
(
int
aShape
,
DRAWSEGMENT
*
&
aGraphic
)
{
// Only two shapes are currently supported
assert
(
aShape
==
S_SEGMENT
||
aShape
==
S_CIRCLE
);
...
...
@@ -989,6 +1007,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic )
preview
.
Clear
();
updatePreview
=
true
;
delete
aGraphic
;
aGraphic
=
NULL
;
break
;
}
...
...
@@ -1049,7 +1068,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic )
else
// User has clicked twice in the same spot
{
// a clear sign that the current drawing is finished
delete
aGraphic
;
// but only if at least one graphic was created
started
=
false
;
// otherwise - force user to draw more or cancel
aGraphic
=
NULL
;
// otherwise - force user to draw more or cancel
started
=
false
;
}
preview
.
Clear
();
...
...
@@ -1081,7 +1101,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic )
}
bool
DRAWING_TOOL
::
drawArc
(
DRAWSEGMENT
*
aGraphic
)
bool
DRAWING_TOOL
::
drawArc
(
DRAWSEGMENT
*
&
aGraphic
)
{
bool
clockwise
=
true
;
// drawing direction of the arc
double
startAngle
=
0.0
f
;
// angle of the first arc line
...
...
@@ -1121,6 +1141,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT* aGraphic )
preview
.
Clear
();
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
delete
aGraphic
;
aGraphic
=
NULL
;
break
;
}
...
...
pcbnew/tools/drawing_tool.h
View file @
a6484f1a
...
...
@@ -156,14 +156,14 @@ private:
///> be already created. The tool deletes the object if it is not added to a BOARD.
///> @return False if the tool was cancelled before the origin was set or origin and end are
///> the same point.
bool
drawSegment
(
int
aShape
,
DRAWSEGMENT
*
aGraphic
);
bool
drawSegment
(
int
aShape
,
DRAWSEGMENT
*
&
aGraphic
);
///> Starts drawing an arc.
///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to
///> be already created. The tool deletes the object if it is not added to a BOARD.
///> @return False if the tool was cancelled before the origin was set or origin and end are
///> the same point.
bool
drawArc
(
DRAWSEGMENT
*
aGraphic
);
bool
drawArc
(
DRAWSEGMENT
*
&
aGraphic
);
///> Draws a polygon, that is added as a zone or a keepout area.
///> @param aKeepout decides if the drawn polygon is a zone or a keepout area.
...
...
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