touch ups mostly to Marco's draw_gerber_screen patch

This commit is contained in:
Dick Hollenbeck 2010-12-11 20:29:33 -06:00
parent adb4ad1a7b
commit 9e8fb76123
4 changed files with 135 additions and 84 deletions

View File

@ -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
// 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++ )
{
if( !GetBoard()->IsLayerVisible( layer ) )
continue;
GERBER_IMAGE* gerber = g_GERBER_List[layer];
if( gerber == NULL ) // Graphic layer not yet used
continue;
/* Draw background negative (i.e. in graphic layer color) for negative images:
* Background is drawn here in GR_OR mode because in COPY mode
* all previous graphics will be erased
* Note: items in background color ("Erased" items) are always drawn in COPY mode
* Some artifacts can happen when more than one gerber file is loaded
*/
// Draw each layer into a bitmap first. Negative Gerber
// layers are drawn in background color.
memoryDC.SetBackground( bgBrush );
memoryDC.Clear();
if( gerber->m_ImageNegative )
{
int color = GetBoard()->GetLayerColor( layer );
GRSetDrawMode( aDC, GR_OR );
// Draw background negative (i.e. in graphic layer color) for negative images.
int color = GetBoard()->GetLayerColor( layer );
GRSetDrawMode( (wxDC*)&memoryDC, GR_COPY ); // GR_COPY is faster than GR_OR
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(),
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 )
dcode_hightlight = gerber->m_Selected_Tool;
BOARD_ITEM* item = GetBoard()->m_Drawings;
for( ; item; item = item->Next() )
dcode_highlight = gerber->m_Selected_Tool;
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->GetLayer()!= layer )
if( gerb_item->GetLayer() != layer )
continue;
int drawMode = aDrawMode;
if( dcode_hightlight == gerb_item->m_DCode )
if( dcode_highlight == gerb_item->m_DCode )
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();

View File

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

View File

@ -57,7 +57,8 @@ D_PAD::~D_PAD()
*/
int D_PAD::GetMaxRadius() const
{
int x, y, radius;
int x, y;
int radius;
switch( m_PadShape & 0x7F )
{
@ -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
radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 );
break;
default:
radius = 0; // quiet compiler
}
return radius;

View File

@ -43,23 +43,26 @@ public:
int PlotPSColorOpt; // True for color Postscript output
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_Valeur;
bool Sel_Texte_Divers;
bool Sel_Texte_Invisible;
bool PlotPadsOnSilkLayer; /* allows pads on silkscreen */
bool PlotPadsOnSilkLayer; ///< allows pads on silkscreen
bool m_SubtractMaskFromSilk;
/* id for plot format (see enum PlotFormat in plot_common.h) */
int PlotFormat;
int PlotOrient;
int PlotScaleOpt;
enum DrillShapeOptT {
/// id for plot format (see enum PlotFormat in plot_common.h)
int PlotFormat;
int PlotOrient;
int PlotScaleOpt;
enum DrillShapeOptT
{
NO_DRILL_SHAPE = 0,
SMALL_DRILL_SHAPE = 1,
FULL_DRILL_SHAPE = 2
};
DrillShapeOptT DrillShapeOpt;
double Scale;
double ScaleAdjX;
@ -70,10 +73,10 @@ private:
public:
PCB_Plot_Options();
void SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; };
wxString GetOutputDirectory() { return outputDirectory; };
void SetSubtractMaskFromSilk( bool aSubtract ) { m_SubtractMaskFromSilk = aSubtract; };
bool GetSubtractMaskFromSilk() { return m_SubtractMaskFromSilk; };
void SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; };
wxString GetOutputDirectory() { return outputDirectory; };
void SetSubtractMaskFromSilk( bool aSubtract ) { m_SubtractMaskFromSilk = aSubtract; };
bool GetSubtractMaskFromSilk() { return m_SubtractMaskFromSilk; };
};
extern PCB_Plot_Options g_pcb_plot_options;