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
b2d07373
Commit
b2d07373
authored
Jul 09, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed continous line drawing.
Outline mode can be set up on any layer.
parent
d7c3c782
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
19 deletions
+54
-19
modedit.cpp
pcbnew/modedit.cpp
+4
-1
pcb_painter.cpp
pcbnew/pcb_painter.cpp
+9
-9
drawing_tool.cpp
pcbnew/tools/drawing_tool.cpp
+38
-8
drawing_tool.h
pcbnew/tools/drawing_tool.h
+3
-1
No files found.
pcbnew/modedit.cpp
View file @
b2d07373
...
...
@@ -295,7 +295,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case
ID_MODEDIT_NEW_MODULE
:
{
if
(
!
Clear_Pcb
(
true
)
)
if
(
!
Clear_Pcb
(
true
)
)
break
;
SetCrossHairPosition
(
wxPoint
(
0
,
0
)
);
...
...
@@ -317,6 +317,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Zoom_Automatique
(
false
);
}
if
(
IsGalCanvasActive
()
)
updateView
();
GetScreen
()
->
ClrModify
();
}
break
;
...
...
pcbnew/pcb_painter.cpp
View file @
b2d07373
...
...
@@ -50,7 +50,7 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
m_displayZoneMode
=
DZ_SHOW_FILLED
;
// By default everything should be displayed as filled
for
(
unsigned
int
i
=
0
;
i
<
END_PCB_VISIBLE_LIS
T
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
TOTAL_LAYER_COUN
T
;
++
i
)
{
m_sketchMode
[
i
]
=
false
;
}
...
...
@@ -102,9 +102,9 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions )
m_padNumbers
=
aOptions
.
DisplayPadNum
;
// Whether to draw tracks, vias & pads filled or as outlines
m_sketchMode
[
PADS_VISIBLE
]
=
!
aOptions
.
DisplayPadFill
;
m_sketchMode
[
VIA_THROUGH_VISIBLE
]
=
!
aOptions
.
DisplayViaFill
;
m_sketchMode
[
TRACKS_VISIBLE
]
=
!
aOptions
.
DisplayPcbTrackFill
;
m_sketchMode
[
ITEM_GAL_LAYER
(
PADS_VISIBLE
)
]
=
!
aOptions
.
DisplayPadFill
;
m_sketchMode
[
ITEM_GAL_LAYER
(
VIA_THROUGH_VISIBLE
)
]
=
!
aOptions
.
DisplayViaFill
;
m_sketchMode
[
ITEM_GAL_LAYER
(
TRACKS_VISIBLE
)
]
=
!
aOptions
.
DisplayPcbTrackFill
;
switch
(
aOptions
.
DisplayNetNamesMode
)
{
...
...
@@ -313,7 +313,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
m_gal
->
SetStrokeColor
(
color
);
m_gal
->
SetIsStroke
(
true
);
if
(
m_pcbSettings
.
m_sketchMode
[
TRACKS_VISIBLE
]
)
if
(
m_pcbSettings
.
m_sketchMode
[
ITEM_GAL_LAYER
(
TRACKS_VISIBLE
)
]
)
{
// Outline mode
m_gal
->
SetLineWidth
(
m_pcbSettings
.
m_outlineWidth
);
...
...
@@ -350,7 +350,7 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
const
COLOR4D
&
color
=
m_pcbSettings
.
GetColor
(
aVia
,
aLayer
);
if
(
m_pcbSettings
.
m_sketchMode
[
VIA_THROUGH_VISIBLE
]
)
if
(
m_pcbSettings
.
m_sketchMode
[
ITEM_GAL_LAYER
(
VIA_THROUGH_VISIBLE
)
]
)
{
// Outline mode
m_gal
->
SetIsFill
(
false
);
...
...
@@ -481,7 +481,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Pad drawing
const
COLOR4D
&
color
=
m_pcbSettings
.
GetColor
(
aPad
,
aLayer
);
if
(
m_pcbSettings
.
m_sketchMode
[
PADS_VISIBLE
]
)
if
(
m_pcbSettings
.
m_sketchMode
[
ITEM_GAL_LAYER
(
PADS_VISIBLE
)
]
)
{
// Outline mode
m_gal
->
SetIsFill
(
false
);
...
...
@@ -544,7 +544,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m
=
(
size
.
y
-
size
.
x
);
n
=
size
.
x
;
if
(
m_pcbSettings
.
m_sketchMode
[
PADS_VISIBLE
]
)
if
(
m_pcbSettings
.
m_sketchMode
[
ITEM_GAL_LAYER
(
PADS_VISIBLE
)
]
)
{
// Outline mode
m_gal
->
DrawArc
(
VECTOR2D
(
0
,
-
m
),
n
,
-
M_PI
,
0
);
...
...
@@ -565,7 +565,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m
=
(
size
.
x
-
size
.
y
);
n
=
size
.
y
;
if
(
m_pcbSettings
.
m_sketchMode
[
PADS_VISIBLE
]
)
if
(
m_pcbSettings
.
m_sketchMode
[
ITEM_GAL_LAYER
(
PADS_VISIBLE
)
]
)
{
// Outline mode
m_gal
->
DrawArc
(
VECTOR2D
(
-
m
,
0
),
n
,
M_PI
/
2
,
3
*
M_PI
/
2
);
...
...
pcbnew/tools/drawing_tool.cpp
View file @
b2d07373
...
...
@@ -76,6 +76,8 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
int
DRAWING_TOOL
::
DrawLine
(
TOOL_EVENT
&
aEvent
)
{
boost
::
optional
<
VECTOR2D
>
startingPoint
;
if
(
m_editModules
)
{
m_frame
->
SetToolID
(
ID_MODEDIT_LINE_TOOL
,
wxCURSOR_PENCIL
,
_
(
"Add graphic line"
)
);
...
...
@@ -83,7 +85,7 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
MODULE
*
module
=
m_board
->
m_Modules
;
EDGE_MODULE
*
line
=
new
EDGE_MODULE
(
module
);
while
(
drawSegment
(
S_SEGMENT
,
reinterpret_cast
<
DRAWSEGMENT
*&>
(
line
)
)
)
while
(
drawSegment
(
S_SEGMENT
,
reinterpret_cast
<
DRAWSEGMENT
*&>
(
line
)
,
startingPoint
)
)
{
if
(
line
)
{
...
...
@@ -92,6 +94,11 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
line
->
SetLocalCoord
();
line
->
SetParent
(
module
);
module
->
GraphicalItems
().
PushFront
(
line
);
startingPoint
=
line
->
GetEnd
();
}
else
{
startingPoint
=
boost
::
none
;
}
line
=
new
EDGE_MODULE
(
module
);
...
...
@@ -103,13 +110,18 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
DRAWSEGMENT
*
line
=
new
DRAWSEGMENT
;
while
(
drawSegment
(
S_SEGMENT
,
line
)
)
while
(
drawSegment
(
S_SEGMENT
,
line
,
startingPoint
)
)
{
if
(
line
)
{
m_board
->
Add
(
line
);
m_frame
->
OnModify
();
m_frame
->
SaveCopyInUndoList
(
line
,
UR_NEW
);
startingPoint
=
line
->
GetEnd
();
}
else
{
startingPoint
=
boost
::
none
;
}
line
=
new
DRAWSEGMENT
;
...
...
@@ -853,7 +865,8 @@ int DRAWING_TOOL::SetAnchor( TOOL_EVENT& aEvent )
}
bool
DRAWING_TOOL
::
drawSegment
(
int
aShape
,
DRAWSEGMENT
*&
aGraphic
)
bool
DRAWING_TOOL
::
drawSegment
(
int
aShape
,
DRAWSEGMENT
*&
aGraphic
,
boost
::
optional
<
VECTOR2D
>
aStartingPoint
)
{
// Only two shapes are currently supported
assert
(
aShape
==
S_SEGMENT
||
aShape
==
S_CIRCLE
);
...
...
@@ -872,12 +885,33 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic )
bool
direction45
=
false
;
// 45 degrees only mode
bool
started
=
false
;
VECTOR2I
cursorPos
=
m_controls
->
GetCursorPosition
();
if
(
aStartingPoint
)
{
LAYER_NUM
layer
=
m_frame
->
GetScreen
()
->
m_Active_Layer
;
// Init the new item attributes
aGraphic
->
SetShape
(
(
STROKE_T
)
aShape
);
aGraphic
->
SetWidth
(
m_board
->
GetDesignSettings
().
m_DrawSegmentWidth
);
aGraphic
->
SetStart
(
wxPoint
(
aStartingPoint
->
x
,
aStartingPoint
->
y
)
);
aGraphic
->
SetEnd
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
aGraphic
->
SetLayer
(
layer
);
if
(
aShape
==
S_SEGMENT
)
line45
=
*
aGraphic
;
// used only for direction 45 mode with lines
preview
.
Add
(
aGraphic
);
m_controls
->
SetAutoPan
(
true
);
started
=
true
;
}
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
bool
updatePreview
=
false
;
// should preview be updated
VECTOR2I
cursorPos
=
m_controls
->
GetCursorPosition
();
cursorPos
=
m_controls
->
GetCursorPosition
();
// Enable 45 degrees lines only mode by holding control
if
(
direction45
!=
evt
->
Modifier
(
MD_CTRL
)
&&
started
&&
aShape
==
S_SEGMENT
)
...
...
@@ -940,10 +974,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic )
aGraphic
->
SetLayer
(
layer
);
if
(
aShape
==
S_SEGMENT
)
{
line45
=
*
aGraphic
;
// used only for direction 45 mode with lines
line45
.
SetLayer
(
layer
);
}
preview
.
Add
(
aGraphic
);
m_controls
->
SetAutoPan
(
true
);
...
...
@@ -965,7 +996,6 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic )
{
// a clear sign that the current drawing is finished
delete
aGraphic
;
// but only if at least one graphic was created
aGraphic
=
NULL
;
// otherwise - force user to draw more or cancel
started
=
false
;
}
preview
.
Clear
();
...
...
pcbnew/tools/drawing_tool.h
View file @
b2d07373
...
...
@@ -26,6 +26,7 @@
#define __DRAWING_TOOL_H
#include <tool/tool_interactive.h>
#include <boost/optional.hpp>
namespace
KIGFX
{
...
...
@@ -150,7 +151,8 @@ 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
,
boost
::
optional
<
VECTOR2D
>
aStartingPoint
=
boost
::
none
);
///> Starts drawing an arc.
///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to
...
...
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