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
5383aa2e
Commit
5383aa2e
authored
May 30, 2011
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gerbview: fix bug 788778.
parent
09c038be
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
49 deletions
+107
-49
onrightclick.cpp
eeschema/onrightclick.cpp
+2
-2
draw_gerber_screen.cpp
gerbview/draw_gerber_screen.cpp
+105
-47
No files found.
eeschema/onrightclick.cpp
View file @
5383aa2e
...
@@ -301,8 +301,8 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
...
@@ -301,8 +301,8 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
if
(
!
Component
->
GetFlags
()
)
if
(
!
Component
->
GetFlags
()
)
{
{
ADD_MENUITEM
(
editmenu
,
ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP
,
_
(
"Edit with Lib
edit
"
),
ADD_MENUITEM
(
editmenu
,
ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP
,
_
(
"Edit with Lib
rary Editor
"
),
lib
rary
_xpm
);
lib
edit
_xpm
);
}
}
ADD_MENUITEM_WITH_SUBMENU
(
PopMenu
,
editmenu
,
ID_POPUP_SCH_GENERIC_EDIT_CMP
,
ADD_MENUITEM_WITH_SUBMENU
(
PopMenu
,
editmenu
,
ID_POPUP_SCH_GENERIC_EDIT_CMP
,
...
...
gerbview/draw_gerber_screen.cpp
View file @
5383aa2e
...
@@ -69,7 +69,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
...
@@ -69,7 +69,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
int
drawMode
=
-
1
;
int
drawMode
=
-
1
;
switch
(
GetDisplayMode
()
)
switch
(
GetDisplayMode
()
)
{
{
default
:
default
:
case
0
:
case
0
:
...
@@ -115,6 +115,10 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -115,6 +115,10 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
{
{
// Because Images can be negative (i.e with background filled in color) items are drawn
// Because Images can be negative (i.e with background filled in color) items are drawn
// graphic layer per graphic layer, after the background is filled
// graphic layer per graphic layer, after the background is filled
// to a temporary biumap
// at least when aDrawMode = GR_COPY or aDrawMode = GR_OR
// If aDrawMode = -1, items are drawn to the main screen, and therefore
// arfefacts can happen with negative items or negative images
wxColour
bgColor
=
MakeColour
(
g_DrawBgColor
);
wxColour
bgColor
=
MakeColour
(
g_DrawBgColor
);
wxBrush
bgBrush
(
bgColor
,
wxSOLID
);
wxBrush
bgBrush
(
bgColor
,
wxSOLID
);
...
@@ -129,23 +133,41 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -129,23 +133,41 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
wxMemoryDC
layerDC
;
// used sequentially for each gerber layer
wxMemoryDC
layerDC
;
// used sequentially for each gerber layer
wxMemoryDC
screenDC
;
wxMemoryDC
screenDC
;
if
(
aDrawMode
!=
-
1
)
// When each image must be drawn using GR_OR (transparency mode)
// or GR_COPY (stacked mode) we must use a temporary bitmap
// to draw gerber images.
// this is due to negative objects (drawn using background color) that create artefacct
// on other images when drawn on screen
bool
useBufferBitmap
=
false
;
if
(
(
aDrawMode
==
GR_COPY
)
||
(
aDrawMode
==
GR_OR
)
)
useBufferBitmap
=
true
;
// these parameters are saved here, because they are modified
// and restored later
EDA_RECT
drawBox
=
aPanel
->
m_ClipBox
;
double
scale
;
aDC
->
GetUserScale
(
&
scale
,
&
scale
);
wxPoint
dev_org
=
aDC
->
GetDeviceOrigin
();
wxPoint
logical_org
=
aDC
->
GetLogicalOrigin
(
);
if
(
useBufferBitmap
)
{
{
layerBitmap
=
new
wxBitmap
(
bitmapWidth
,
bitmapHeight
);
layerBitmap
=
new
wxBitmap
(
bitmapWidth
,
bitmapHeight
);
screenBitmap
=
new
wxBitmap
(
bitmapWidth
,
bitmapHeight
);
screenBitmap
=
new
wxBitmap
(
bitmapWidth
,
bitmapHeight
);
layerDC
.
SelectObject
(
*
layerBitmap
);
layerDC
.
SelectObject
(
*
layerBitmap
);
EDA_RECT
tmpRect
=
aPanel
->
m_ClipBox
;
aPanel
->
DoPrepareDC
(
layerDC
);
aPanel
->
DoPrepareDC
(
layerDC
);
aPanel
->
m_ClipBox
=
tmpRect
;
aPanel
->
m_ClipBox
=
drawBox
;
layerDC
.
SetBackground
(
bgBrush
);
layerDC
.
SetBackground
(
bgBrush
);
layerDC
.
SetBackgroundMode
(
wxSOLID
);
layerDC
.
SetBackgroundMode
(
wxSOLID
);
layerDC
.
Clear
();
layerDC
.
Clear
();
aPanel
->
DrawBackGround
(
&
layerDC
);
screenDC
.
SelectObject
(
*
screenBitmap
);
screenDC
.
SelectObject
(
*
screenBitmap
);
screenDC
.
SetBackground
(
bgBrush
);
screenDC
.
SetBackground
(
bgBrush
);
screenDC
.
SetBackgroundMode
(
wxSOLID
);
screenDC
.
SetBackgroundMode
(
wxSOLID
);
screenDC
.
Clear
();
screenDC
.
Clear
();
plotDC
=
&
layerDC
;
}
}
bool
doBlit
=
false
;
// this flag requests an image transfert to actual screen when true.
bool
doBlit
=
false
;
// this flag requests an image transfert to actual screen when true.
...
@@ -153,7 +175,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -153,7 +175,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
bool
end
=
false
;
bool
end
=
false
;
for
(
int
layer
=
0
;
!
end
;
layer
++
)
for
(
int
layer
=
0
;
!
end
;
layer
++
)
{
{
int
active_layer
=
(
(
GERBVIEW_FRAME
*
)
m_PcbFrame
)
->
getActiveLayer
();
int
active_layer
=
(
(
GERBVIEW_FRAME
*
)
m_PcbFrame
)
->
getActiveLayer
();
if
(
layer
==
active_layer
)
// active layer will be drawn after other layers
if
(
layer
==
active_layer
)
// active layer will be drawn after other layers
continue
;
continue
;
...
@@ -171,12 +193,18 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -171,12 +193,18 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
if
(
gerber
==
NULL
)
// Graphic layer not yet used
if
(
gerber
==
NULL
)
// Graphic layer not yet used
continue
;
continue
;
if
(
aDrawMode
!=
-
1
)
if
(
useBufferBitmap
)
{
{
// Draw each layer into a bitmap first. Negative Gerber
// Draw each layer into a bitmap first. Negative Gerber
// layers are drawn in background color.
// layers are drawn in background color.
if
(
gerber
->
HasNegativeItems
()
&&
doBlit
)
if
(
gerber
->
HasNegativeItems
()
&&
doBlit
)
{
{
// Set Device orgin, logical origin and scale to default values
// This is needed by Blit function when using a mask.
// Beside, for Blit call, both layerDC and screenDc must have the same settings
layerDC
.
SetDeviceOrigin
(
0
,
0
);
layerDC
.
SetLogicalOrigin
(
0
,
0
);
layerDC
.
SetUserScale
(
1
,
1
);
if
(
aDrawMode
==
GR_COPY
)
if
(
aDrawMode
==
GR_COPY
)
{
{
// Use the layer bitmap itself as a mask when blitting. The bitmap
// Use the layer bitmap itself as a mask when blitting. The bitmap
...
@@ -184,7 +212,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -184,7 +212,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
layerDC
.
SelectObject
(
wxNullBitmap
);
layerDC
.
SelectObject
(
wxNullBitmap
);
layerBitmap
->
SetMask
(
new
wxMask
(
*
layerBitmap
,
bgColor
)
);
layerBitmap
->
SetMask
(
new
wxMask
(
*
layerBitmap
,
bgColor
)
);
layerDC
.
SelectObject
(
*
layerBitmap
);
layerDC
.
SelectObject
(
*
layerBitmap
);
screenDC
.
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
layerDC
,
0
,
0
,
wxCOPY
,
true
);
screenDC
.
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
layerDC
,
0
,
0
,
wxCOPY
,
true
);
}
}
else
if
(
aDrawMode
==
GR_OR
)
else
if
(
aDrawMode
==
GR_OR
)
{
{
...
@@ -195,10 +224,16 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -195,10 +224,16 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
// the cpu cycles needed to create the monochromatic bitmap above, and
// the cpu cycles needed to create the monochromatic bitmap above, and
// the extra time needed to do bit indexing into the monochromatic bitmap
// the extra time needed to do bit indexing into the monochromatic bitmap
// on the blit above.
// on the blit above.
screenDC
.
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
layerDC
,
0
,
0
,
wxOR
);
screenDC
.
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
layerDC
,
0
,
0
,
wxOR
);
}
}
}
}
// Restore actual values for drawing
layerDC
.
SetDeviceOrigin
(
dev_org
.
x
,
dev_org
.
y
);
layerDC
.
SetLogicalOrigin
(
logical_org
.
x
,
logical_org
.
y
);
layerDC
.
SetUserScale
(
scale
,
scale
);
doBlit
=
false
;
doBlit
=
false
;
layerDC
.
Clear
();
layerDC
.
Clear
();
}
}
...
@@ -209,11 +244,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -209,11 +244,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
int
color
=
GetBoard
()
->
GetLayerColor
(
layer
);
int
color
=
GetBoard
()
->
GetLayerColor
(
layer
);
GRSetDrawMode
(
&
layerDC
,
GR_COPY
);
GRSetDrawMode
(
&
layerDC
,
GR_COPY
);
GRFilledRect
(
&
drawBox
,
plotDC
,
drawBox
.
GetX
(),
drawBox
.
GetY
(),
EDA_RECT
*
cbox
=
&
aPanel
->
m_ClipBox
;
drawBox
.
GetRight
(),
drawBox
.
GetBottom
(),
GRSFilledRect
(
cbox
,
plotDC
,
cbox
->
GetX
(),
cbox
->
GetY
(),
cbox
->
GetRight
(),
cbox
->
GetBottom
(),
0
,
color
,
color
);
0
,
color
,
color
);
GRSetDrawMode
(
plotDC
,
GR_COPY
);
GRSetDrawMode
(
plotDC
,
GR_COPY
);
...
@@ -222,7 +254,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -222,7 +254,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
int
dcode_highlight
=
0
;
int
dcode_highlight
=
0
;
if
(
layer
==
(
(
GERBVIEW_FRAME
*
)
m_PcbFrame
)
->
getActiveLayer
()
)
if
(
layer
==
(
(
GERBVIEW_FRAME
*
)
m_PcbFrame
)
->
getActiveLayer
()
)
dcode_highlight
=
gerber
->
m_Selected_Tool
;
dcode_highlight
=
gerber
->
m_Selected_Tool
;
int
layerdrawMode
=
GR_COPY
;
int
layerdrawMode
=
GR_COPY
;
...
@@ -230,6 +262,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -230,6 +262,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
if
(
aDrawMode
==
GR_OR
&&
!
gerber
->
HasNegativeItems
()
)
if
(
aDrawMode
==
GR_OR
&&
!
gerber
->
HasNegativeItems
()
)
layerdrawMode
=
GR_OR
;
layerdrawMode
=
GR_OR
;
// Now we can draw the current layer to the bitmap buffer
// When needed, the previous bitmap is already copied to the screen buffer.
for
(
BOARD_ITEM
*
item
=
GetBoard
()
->
m_Drawings
;
item
;
item
=
item
->
Next
()
)
for
(
BOARD_ITEM
*
item
=
GetBoard
()
->
m_Drawings
;
item
;
item
=
item
->
Next
()
)
{
{
GERBER_DRAW_ITEM
*
gerb_item
=
(
GERBER_DRAW_ITEM
*
)
item
;
GERBER_DRAW_ITEM
*
gerb_item
=
(
GERBER_DRAW_ITEM
*
)
item
;
...
@@ -241,14 +275,19 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -241,14 +275,19 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
if
(
dcode_highlight
&&
dcode_highlight
==
gerb_item
->
m_DCode
)
if
(
dcode_highlight
&&
dcode_highlight
==
gerb_item
->
m_DCode
)
drawMode
|=
GR_SURBRILL
;
drawMode
|=
GR_SURBRILL
;
gerb_item
->
Draw
(
aPanel
,
plotDC
,
drawMode
);
gerb_item
->
Draw
(
aPanel
,
plotDC
,
drawMode
);
doBlit
=
true
;
doBlit
=
true
;
}
}
}
}
if
(
doBlit
&&
aDrawMode
!=
-
1
)
// Blit is used only if aDrawMode >= 0
if
(
doBlit
&&
useBufferBitmap
)
// Blit is used only if aDrawMode >= 0
{
{
// For this Blit call, layerDC and screenDC must have the same settings
// So we set device orgin, logical origin and scale to default values
// in layerDC
layerDC
.
SetDeviceOrigin
(
0
,
0
);
layerDC
.
SetLogicalOrigin
(
0
,
0
);
layerDC
.
SetUserScale
(
1
,
1
);
// this is the last transfert to screenDC. If there are no negative items, this is
// this is the last transfert to screenDC. If there are no negative items, this is
// the only one
// the only one
if
(
aDrawMode
==
GR_COPY
)
if
(
aDrawMode
==
GR_COPY
)
...
@@ -256,17 +295,34 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -256,17 +295,34 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
layerDC
.
SelectObject
(
wxNullBitmap
);
layerDC
.
SelectObject
(
wxNullBitmap
);
layerBitmap
->
SetMask
(
new
wxMask
(
*
layerBitmap
,
bgColor
)
);
layerBitmap
->
SetMask
(
new
wxMask
(
*
layerBitmap
,
bgColor
)
);
layerDC
.
SelectObject
(
*
layerBitmap
);
layerDC
.
SelectObject
(
*
layerBitmap
);
screenDC
.
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
layerDC
,
0
,
0
,
wxCOPY
,
true
);
screenDC
.
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
layerDC
,
0
,
0
,
wxCOPY
,
true
);
}
}
else
if
(
aDrawMode
==
GR_OR
)
else
if
(
aDrawMode
==
GR_OR
)
{
{
screenDC
.
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
layerDC
,
0
,
0
,
wxOR
,
false
);
screenDC
.
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
layerDC
,
0
,
0
,
wxOR
);
}
}
}
}
if
(
aDrawMode
!=
-
1
)
if
(
useBufferBitmap
)
{
{
aDC
->
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
screenDC
,
0
,
0
,
wxCOPY
);
// For this Blit call, aDC and screenDC must have the same settings
// So we set device orgin, logical origin and scale to default values
// in aDC
aDC
->
SetDeviceOrigin
(
0
,
0
);
aDC
->
SetLogicalOrigin
(
0
,
0
);
aDC
->
SetUserScale
(
1
,
1
);
aDC
->
Blit
(
0
,
0
,
bitmapWidth
,
bitmapHeight
,
&
screenDC
,
0
,
0
,
wxCOPY
);
// Restore aDC values
aDC
->
SetDeviceOrigin
(
dev_org
.
x
,
dev_org
.
y
);
aDC
->
SetLogicalOrigin
(
logical_org
.
x
,
logical_org
.
y
);
aDC
->
SetUserScale
(
scale
,
scale
);
layerDC
.
SelectObject
(
wxNullBitmap
);
layerDC
.
SelectObject
(
wxNullBitmap
);
screenDC
.
SelectObject
(
wxNullBitmap
);
screenDC
.
SelectObject
(
wxNullBitmap
);
delete
layerBitmap
;
delete
layerBitmap
;
...
@@ -274,6 +330,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
...
@@ -274,6 +330,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
}
}
}
}
/* Function DrawItemsDCodeID
/* Function DrawItemsDCodeID
* Draw the DCode value (if exists) corresponding to gerber item
* Draw the DCode value (if exists) corresponding to gerber item
* Polygons do not have a DCode
* Polygons do not have a DCode
...
@@ -327,6 +384,7 @@ void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
...
@@ -327,6 +384,7 @@ void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
if
(
abs
(
delta
.
x
)
<
abs
(
delta
.
y
)
)
if
(
abs
(
delta
.
x
)
<
abs
(
delta
.
y
)
)
orient
=
TEXT_ORIENT_VERT
;
orient
=
TEXT_ORIENT_VERT
;
// A reasonnable size for text is width/2 because text needs margin below and above it.
// A reasonnable size for text is width/2 because text needs margin below and above it.
// a margin = width/4 seems good
// a margin = width/4 seems good
width
/=
2
;
width
/=
2
;
...
@@ -351,6 +409,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
...
@@ -351,6 +409,7 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
{
{
}
}
/* dummy_functions
/* dummy_functions
*
*
* These functions are used in some classes.
* These functions are used in some classes.
...
@@ -367,4 +426,3 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
...
@@ -367,4 +426,3 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
{
{
return
NULL
;
return
NULL
;
}
}
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