Commit 9e8fb761 authored by Dick Hollenbeck's avatar Dick Hollenbeck

touch ups mostly to Marco's draw_gerber_screen patch

parent adb4ad1a
...@@ -103,45 +103,84 @@ void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, const wxPo ...@@ -103,45 +103,84 @@ void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, const wxPo
{ {
// 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
int bitmapWidth, bitmapHeight;
aPanel->GetClientSize( &bitmapWidth, &bitmapHeight );
wxBitmap layerBitmap( bitmapWidth, bitmapHeight );
wxMemoryDC memoryDC;
memoryDC.SelectObject( layerBitmap );
wxColour bgColor = MakeColour( g_DrawBgColor );
wxBrush bgBrush( bgColor, wxSOLID );
for( int layer = 0; layer < 32; layer++ ) for( int layer = 0; layer < 32; layer++ )
{ {
if( !GetBoard()->IsLayerVisible( layer ) ) if( !GetBoard()->IsLayerVisible( layer ) )
continue; continue;
GERBER_IMAGE* gerber = g_GERBER_List[layer]; GERBER_IMAGE* gerber = g_GERBER_List[layer];
if( gerber == NULL ) // Graphic layer not yet used if( gerber == NULL ) // Graphic layer not yet used
continue; continue;
/* Draw background negative (i.e. in graphic layer color) for negative images: // Draw each layer into a bitmap first. Negative Gerber
* Background is drawn here in GR_OR mode because in COPY mode // layers are drawn in background color.
* all previous graphics will be erased memoryDC.SetBackground( bgBrush );
* Note: items in background color ("Erased" items) are always drawn in COPY mode memoryDC.Clear();
* Some artifacts can happen when more than one gerber file is loaded
*/
if( gerber->m_ImageNegative ) if( gerber->m_ImageNegative )
{ {
int color = GetBoard()->GetLayerColor( layer ); // Draw background negative (i.e. in graphic layer color) for negative images.
GRSetDrawMode( aDC, GR_OR );
int color = GetBoard()->GetLayerColor( layer );
GRSetDrawMode( (wxDC*)&memoryDC, GR_COPY ); // GR_COPY is faster than GR_OR
EDA_Rect* cbox = &aPanel->m_ClipBox; EDA_Rect* cbox = &aPanel->m_ClipBox;
GRSFilledRect( cbox, aDC, cbox->GetX(), cbox->GetY(),
GRSFilledRect( cbox, (wxDC*)&memoryDC, cbox->GetX(), cbox->GetY(),
cbox->GetRight(), cbox->GetBottom(), cbox->GetRight(), cbox->GetBottom(),
0, color, color ); 0, color, color );
GRSetDrawMode( aDC, aDrawMode );
GRSetDrawMode( (wxDC*)&memoryDC, aDrawMode );
} }
int dcode_hightlight = 0; int dcode_highlight = 0;
if( layer == m_PcbFrame->GetScreen()->m_Active_Layer ) if( layer == m_PcbFrame->GetScreen()->m_Active_Layer )
dcode_hightlight = gerber->m_Selected_Tool; dcode_highlight = gerber->m_Selected_Tool;
BOARD_ITEM* item = GetBoard()->m_Drawings;
for( ; 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;
if( gerb_item->GetLayer()!= layer ) if( gerb_item->GetLayer() != layer )
continue; continue;
int drawMode = aDrawMode; int drawMode = aDrawMode;
if( dcode_hightlight == gerb_item->m_DCode ) if( dcode_highlight == gerb_item->m_DCode )
drawMode |= GR_SURBRILL; drawMode |= GR_SURBRILL;
gerb_item->Draw( aPanel, aDC, drawMode );
gerb_item->Draw( aPanel, (wxDC*)&memoryDC, drawMode );
} }
#if 0
// Use the layer bitmap itself as a mask when blitting.
// The bitmap cannot be referenced by a device context
// when setting the mask.
memoryDC.SelectObject( wxNullBitmap );
layerBitmap.SetMask( new wxMask( layerBitmap, bgColor ) );
memoryDC.SelectObject( layerBitmap );
aDC->Blit( 0, 0, bitmapWidth, bitmapHeight,
(wxDC*)&memoryDC, 0, 0, wxCOPY, true );
#else // Dick: seems a little faster, crisper
aDC->Blit( 0, 0, bitmapWidth, bitmapHeight,
(wxDC*)&memoryDC, 0, 0, wxOR, false );
#endif
} }
m_PcbFrame->GetScreen()->ClrRefreshReq(); m_PcbFrame->GetScreen()->ClrRefreshReq();
......
This diff is collapsed.
...@@ -57,7 +57,8 @@ D_PAD::~D_PAD() ...@@ -57,7 +57,8 @@ D_PAD::~D_PAD()
*/ */
int D_PAD::GetMaxRadius() const int D_PAD::GetMaxRadius() const
{ {
int x, y, radius; int x, y;
int radius;
switch( m_PadShape & 0x7F ) switch( m_PadShape & 0x7F )
{ {
...@@ -79,6 +80,9 @@ int D_PAD::GetMaxRadius() const ...@@ -79,6 +80,9 @@ int D_PAD::GetMaxRadius() const
y = m_Size.y + ABS( m_DeltaSize.x ); // Remember: m_DeltaSize.x is the m_Size.y change y = m_Size.y + ABS( m_DeltaSize.x ); // Remember: m_DeltaSize.x is the m_Size.y change
radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 ); radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 );
break; break;
default:
radius = 0; // quiet compiler
} }
return radius; return radius;
......
...@@ -43,23 +43,26 @@ public: ...@@ -43,23 +43,26 @@ public:
int PlotPSColorOpt; // True for color Postscript output int PlotPSColorOpt; // True for color Postscript output
bool Plot_PS_Negative; // True to create a negative board ps plot bool Plot_PS_Negative; // True to create a negative board ps plot
/* Flags to enable or disable ploting of various PCB elements. */ /// Flags to enable or disable ploting of various PCB elements.
bool Sel_Texte_Reference; bool Sel_Texte_Reference;
bool Sel_Texte_Valeur; bool Sel_Texte_Valeur;
bool Sel_Texte_Divers; bool Sel_Texte_Divers;
bool Sel_Texte_Invisible; bool Sel_Texte_Invisible;
bool PlotPadsOnSilkLayer; /* allows pads on silkscreen */ bool PlotPadsOnSilkLayer; ///< allows pads on silkscreen
bool m_SubtractMaskFromSilk; bool m_SubtractMaskFromSilk;
/* id for plot format (see enum PlotFormat in plot_common.h) */ /// id for plot format (see enum PlotFormat in plot_common.h)
int PlotFormat; int PlotFormat;
int PlotOrient; int PlotOrient;
int PlotScaleOpt; int PlotScaleOpt;
enum DrillShapeOptT {
enum DrillShapeOptT
{
NO_DRILL_SHAPE = 0, NO_DRILL_SHAPE = 0,
SMALL_DRILL_SHAPE = 1, SMALL_DRILL_SHAPE = 1,
FULL_DRILL_SHAPE = 2 FULL_DRILL_SHAPE = 2
}; };
DrillShapeOptT DrillShapeOpt; DrillShapeOptT DrillShapeOpt;
double Scale; double Scale;
double ScaleAdjX; double ScaleAdjX;
...@@ -70,10 +73,10 @@ private: ...@@ -70,10 +73,10 @@ private:
public: public:
PCB_Plot_Options(); PCB_Plot_Options();
void SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; }; void SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; };
wxString GetOutputDirectory() { return outputDirectory; }; wxString GetOutputDirectory() { return outputDirectory; };
void SetSubtractMaskFromSilk( bool aSubtract ) { m_SubtractMaskFromSilk = aSubtract; }; void SetSubtractMaskFromSilk( bool aSubtract ) { m_SubtractMaskFromSilk = aSubtract; };
bool GetSubtractMaskFromSilk() { return m_SubtractMaskFromSilk; }; bool GetSubtractMaskFromSilk() { return m_SubtractMaskFromSilk; };
}; };
extern PCB_Plot_Options g_pcb_plot_options; extern PCB_Plot_Options g_pcb_plot_options;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment