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();
......
...@@ -17,7 +17,8 @@ class Ki_PageDescr; ...@@ -17,7 +17,8 @@ class Ki_PageDescr;
/** /**
* Enum PlotFormat * Enum PlotFormat
* must be kept in order of the radio buttons in the plot panel/window. * is the set of supported output plot formats. They should be kept in order
* of the radio buttons in the plot panel/windows.
*/ */
enum PlotFormat { enum PlotFormat {
PLOT_FORMAT_HPGL, PLOT_FORMAT_HPGL,
...@@ -37,7 +38,7 @@ public: ...@@ -37,7 +38,7 @@ public:
virtual ~PLOTTER() virtual ~PLOTTER()
{ {
/* Emergency cleanup */ // Emergency cleanup
if( output_file ) if( output_file )
{ {
fclose( output_file ); fclose( output_file );
...@@ -94,7 +95,7 @@ public: ...@@ -94,7 +95,7 @@ public:
virtual void set_viewport( wxPoint offset, virtual void set_viewport( wxPoint offset,
double scale, int orient ) = 0; double scale, int orient ) = 0;
/* Standard primitives */ // Standard primitives
virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill,
int width = -1 ) = 0; int width = -1 ) = 0;
virtual void circle( wxPoint pos, int diametre, FILL_T fill, virtual void circle( wxPoint pos, int diametre, FILL_T fill,
...@@ -113,7 +114,7 @@ public: ...@@ -113,7 +114,7 @@ public:
GRTraceMode tracemode ); GRTraceMode tracemode );
virtual void pen_to( wxPoint pos, char plume ) = 0; virtual void pen_to( wxPoint pos, char plume ) = 0;
/* Flash primitives */ // Flash primitives
virtual void flash_pad_circle( wxPoint pos, int diametre, virtual void flash_pad_circle( wxPoint pos, int diametre,
GRTraceMode trace_mode ) = 0; GRTraceMode trace_mode ) = 0;
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient, virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
...@@ -130,7 +131,7 @@ public: ...@@ -130,7 +131,7 @@ public:
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4], virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
int aPadOrient, GRTraceMode aTrace_Mode ) = 0; int aPadOrient, GRTraceMode aTrace_Mode ) = 0;
/* Convenience functions */ // Convenience functions
void move_to( wxPoint pos ) void move_to( wxPoint pos )
{ {
pen_to( pos, 'U' ); pen_to( pos, 'U' );
...@@ -152,7 +153,7 @@ public: ...@@ -152,7 +153,7 @@ public:
void pen_finish() void pen_finish()
{ {
/* Shortcut */ // Shortcut
pen_to( wxPoint( 0, 0 ), 'Z' ); pen_to( wxPoint( 0, 0 ), 'Z' );
} }
...@@ -173,16 +174,16 @@ public: ...@@ -173,16 +174,16 @@ public:
* Function SetLayerPolarity * Function SetLayerPolarity
* sets current Gerber layer polarity to positive or negative * sets current Gerber layer polarity to positive or negative
* by writing \%LPD*\% or \%LPC*\% to the Gerber file, respectively. * by writing \%LPD*\% or \%LPC*\% to the Gerber file, respectively.
* param @aPositive = layer polarity, true for positive * @param aPositive is the layer polarity and true for positive.
*/ */
virtual void SetLayerPolarity( bool aPositive ) = 0; virtual void SetLayerPolarity( bool aPositive ) = 0;
protected: protected:
/* These are marker subcomponents */ // These are marker subcomponents
void center_square( const wxPoint& position, int diametre, FILL_T fill ); void center_square( const wxPoint& position, int diametre, FILL_T fill );
void center_lozenge( const wxPoint& position, int diametre, FILL_T fill ); void center_lozenge( const wxPoint& position, int diametre, FILL_T fill );
/* Helper function for sketched filler segment */ // Helper function for sketched filler segment
void segment_as_oval( wxPoint start, wxPoint end, int width, void segment_as_oval( wxPoint start, wxPoint end, int width,
GRTraceMode tracemode ); GRTraceMode tracemode );
void sketch_oval( wxPoint pos, wxSize size, int orient, int width ); void sketch_oval( wxPoint pos, wxSize size, int orient, int width );
...@@ -191,22 +192,22 @@ protected: ...@@ -191,22 +192,22 @@ protected:
virtual void user_to_device_size( wxSize& size ); virtual void user_to_device_size( wxSize& size );
virtual double user_to_device_size( double size ); virtual double user_to_device_size( double size );
/* Plot scale */ // Plot scale
double plot_scale; double plot_scale;
/* Device scale (from decimils to device units) */ // Device scale (from decimils to device units)
double device_scale; double device_scale;
/* Plot offset (in decimils) */ // Plot offset (in decimils)
wxPoint plot_offset; wxPoint plot_offset;
/* Output file */ // Output file
FILE* output_file; FILE* output_file;
/* Pen handling */ // Pen handling
bool color_mode, negative_mode; bool color_mode, negative_mode;
int default_pen_width; int default_pen_width;
int current_pen_width; int current_pen_width;
char pen_state; char pen_state;
wxPoint pen_lastpos; wxPoint pen_lastpos;
/* Other stuff */ // Other stuff
int plot_orient_options; /* For now, mirror plot */ int plot_orient_options; // For now, mirror plot
wxString creator; wxString creator;
wxString filename; wxString filename;
Ki_PageDescr* sheet; Ki_PageDescr* sheet;
...@@ -223,10 +224,10 @@ public: ...@@ -223,10 +224,10 @@ public:
virtual bool start_plot( FILE* fout ); virtual bool start_plot( FILE* fout );
virtual bool end_plot(); virtual bool end_plot();
/* HPGL doesn't handle line thickness or color */ // HPGL doesn't handle line thickness or color
virtual void set_current_line_width( int width ) virtual void set_current_line_width( int width )
{ {
/* Handy override */ // Handy override
current_pen_width = wxRound( pen_diameter ); current_pen_width = wxRound( pen_diameter );
}; };
virtual void set_default_line_width( int width ) {}; virtual void set_default_line_width( int width ) {};
...@@ -280,7 +281,7 @@ public: ...@@ -280,7 +281,7 @@ public:
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4], virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
int aPadOrient, GRTraceMode aTrace_Mode ); int aPadOrient, GRTraceMode aTrace_Mode );
virtual void SetLayerPolarity( bool aPositive ) {}; virtual void SetLayerPolarity( bool aPositive ) {}
protected: protected:
void pen_control( int plume ); void pen_control( int plume );
...@@ -291,6 +292,7 @@ protected: ...@@ -291,6 +292,7 @@ protected:
double pen_overlap; double pen_overlap;
}; };
class PS_PLOTTER : public PLOTTER class PS_PLOTTER : public PLOTTER
{ {
public: public:
...@@ -331,7 +333,7 @@ public: ...@@ -331,7 +333,7 @@ public:
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4], virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
int aPadOrient, GRTraceMode aTrace_Mode ); int aPadOrient, GRTraceMode aTrace_Mode );
virtual void SetLayerPolarity( bool aPositive ) {}; virtual void SetLayerPolarity( bool aPositive ) {}
protected: protected:
double plot_scale_adjX, plot_scale_adjY; double plot_scale_adjX, plot_scale_adjY;
...@@ -349,14 +351,15 @@ struct APERTURE ...@@ -349,14 +351,15 @@ struct APERTURE
Oval = 4 Oval = 4
}; };
wxSize size; /* horiz and Vert size*/ wxSize size; // horiz and Vert size
Aperture_Type type; /* Type ( Line, rect , circulaire , ovale .. ) */ Aperture_Type type; // Type ( Line, rect , circulaire , ovale .. )
int D_code; /* code number ( >= 10 ); */ int D_code; // code number ( >= 10 );
/* Trivia question: WHY Gerber decided to use D instead of the usual T for /* Trivia question: WHY Gerber decided to use D instead of the usual T for
* tool change? */ * tool change? */
}; };
class GERBER_PLOTTER : public PLOTTER class GERBER_PLOTTER : public PLOTTER
{ {
public: public:
...@@ -368,37 +371,37 @@ public: ...@@ -368,37 +371,37 @@ public:
} }
virtual bool start_plot( FILE* fout ); virtual bool start_plot( FILE* fout );
virtual bool end_plot(); virtual bool end_plot();
virtual void set_current_line_width( int width ); virtual void set_current_line_width( int width );
virtual void set_default_line_width( int width ); virtual void set_default_line_width( int width );
/* RS274X has no dashing, nor colours */ // RS274X has no dashing, nor colours
virtual void set_dash( bool dashed ) {}; virtual void set_dash( bool dashed ) {}
virtual void set_color( int color ) {}; virtual void set_color( int color ) {}
virtual void set_viewport( wxPoint offset, virtual void set_viewport( wxPoint offset,
double scale, int orient ); double scale, int orient );
virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 ); virtual void rect( wxPoint p1, wxPoint p2, FILL_T fill, int width = -1 );
virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 ); virtual void circle( wxPoint pos, int diametre, FILL_T fill, int width = -1 );
virtual void poly( int nb_segm, int* coord, FILL_T fill, int width = -1 ); virtual void poly( int nb_segm, int* coord, FILL_T fill, int width = -1 );
virtual void pen_to( wxPoint pos, char plume ); virtual void pen_to( wxPoint pos, char plume );
virtual void flash_pad_circle( wxPoint pos, int diametre, virtual void flash_pad_circle( wxPoint pos, int diametre,
GRTraceMode trace_mode ); GRTraceMode trace_mode );
virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient, virtual void flash_pad_oval( wxPoint pos, wxSize size, int orient,
GRTraceMode trace_mode ); GRTraceMode trace_mode );
virtual void flash_pad_rect( wxPoint pos, wxSize size, virtual void flash_pad_rect( wxPoint pos, wxSize size,
int orient, GRTraceMode trace_mode ); int orient, GRTraceMode trace_mode );
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4], virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
int aPadOrient, GRTraceMode aTrace_Mode ); int aPadOrient, GRTraceMode aTrace_Mode );
virtual void SetLayerPolarity( bool aPositive ); virtual void SetLayerPolarity( bool aPositive );
protected: protected:
void select_aperture( const wxSize& size, void select_aperture( const wxSize& size,
APERTURE::Aperture_Type type ); APERTURE::Aperture_Type type );
std::vector<APERTURE>::iterator get_aperture( const wxSize& size, std::vector<APERTURE>::iterator
APERTURE::Aperture_Type type ); get_aperture( const wxSize& size, APERTURE::Aperture_Type type );
FILE* work_file, * final_file; FILE* work_file, * final_file;
wxString m_workFilename; wxString m_workFilename;
...@@ -419,17 +422,19 @@ public: ...@@ -419,17 +422,19 @@ public:
virtual bool start_plot( FILE* fout ); virtual bool start_plot( FILE* fout );
virtual bool end_plot(); virtual bool end_plot();
/* For now we don't use 'thick' primitives, so no line width */ // For now we don't use 'thick' primitives, so no line width
virtual void set_current_line_width( int width ) virtual void set_current_line_width( int width )
{ {
/* Handy override */ // Handy override
current_pen_width = 0; current_pen_width = 0;
}; }
virtual void set_default_line_width( int width ) virtual void set_default_line_width( int width )
{ {
/* DXF lines are infinitesimal */ // DXF lines are infinitesimal
default_pen_width = 0; default_pen_width = 0;
}; }
virtual void set_dash( bool dashed ); virtual void set_dash( bool dashed );
virtual void set_color( int color ); virtual void set_color( int color );
...@@ -453,10 +458,10 @@ public: ...@@ -453,10 +458,10 @@ public:
virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4], virtual void flash_pad_trapez( wxPoint aPadPos, wxPoint aCorners[4],
int aPadOrient, GRTraceMode aTrace_Mode ); int aPadOrient, GRTraceMode aTrace_Mode );
virtual void SetLayerPolarity( bool aPositive ) {}; virtual void SetLayerPolarity( bool aPositive ) {}
protected: protected:
int current_color; int current_color;
}; };
#endif /* __INCLUDE__PLOT_COMMON_H__ */ #endif // __INCLUDE__PLOT_COMMON_H__
...@@ -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