Commit 9e096061 authored by jean-pierre charras's avatar jean-pierre charras

dcsvg (and therefore KicadSVGFileDC) is now unused. Use SVG plotter only to...

dcsvg (and therefore KicadSVGFileDC)  is now unused. Use SVG plotter only to export a board SVG file.
SVG export does not use no more wxWidgets wxDC.
In pcbnew SVG files can be created by plot menu (in B&W) or export SVG menu (B&W or Color).
Export SVG menu is more suitable to create a view of a board, and plot menu is better to create a B&W document of silkscreen layers.
(In the future, the 2 menus could be merged, because they are not very different).
Note: pcbnew plot code is cleaned, mainly in dialog files, but still needs more cleanup.
parent 436c17f6
...@@ -49,7 +49,6 @@ set(COMMON_SRCS ...@@ -49,7 +49,6 @@ set(COMMON_SRCS
common_plotSVG_functions.cpp common_plotSVG_functions.cpp
confirm.cpp confirm.cpp
copy_to_clipboard.cpp copy_to_clipboard.cpp
dcsvg.cpp
dialog_shim.cpp dialog_shim.cpp
displlst.cpp displlst.cpp
dlist.cpp dlist.cpp
......
...@@ -152,54 +152,26 @@ void SVG_PLOTTER::setSVGPlotStyle() ...@@ -152,54 +152,26 @@ void SVG_PLOTTER::setSVGPlotStyle()
switch( m_fillMode ) switch( m_fillMode )
{ {
case NO_FILL: case NO_FILL:
fputs( "fill-opacity:0.0;\n", outputFile ); fputs( "fill-opacity:0.0; ", outputFile );
break; break;
case FILLED_SHAPE: case FILLED_SHAPE:
fputs( "fill-opacity:1.0;\n", outputFile ); fputs( "fill-opacity:1.0; ", outputFile );
break; break;
case FILLED_WITH_BG_BODYCOLOR: case FILLED_WITH_BG_BODYCOLOR:
fputs( "fill-opacity:0.6;\n", outputFile ); fputs( "fill-opacity:0.6; ", outputFile );
break; break;
} }
// output the pen color (RVB values in hex) and opacity double pen_w = userToDeviceSize( GetCurrentLineWidth() );
double pen_opacity = 1.0; // 0.0 (transparent to 1.0 (solid) fprintf( outputFile, "\nstroke:#%6.6lX; stroke-width:%g; stroke-opacity:1; \n",
fprintf( outputFile, " stroke:#%6.6lX; stroke-opacity:%g;\n", m_pen_rgb_color, pen_w );
m_pen_rgb_color, pen_opacity ); fputs( "stroke-linecap:round; stroke-linejoin:round;\">\n", outputFile );
// output the pen cap
int pen_cap = 0; // round, square, butt (currenly not used)
switch( pen_cap )
{
case 1:
fputs( "stroke-linecap:square; ", outputFile );
break;
case 2:
fputs( "stroke-linecap:butt; ", outputFile );
break;
case 0:
default:
fputs( "stroke-linecap:round; ", outputFile );
}
fputs( "stroke-linejoin:round; ", outputFile );
int pen_w = (int) userToDeviceSize( GetCurrentLineWidth() );
fprintf( outputFile,
"stroke-width:%d\" \n transform=\"translate(%.2g %.2g) scale(%.2g %.2g)\">\n",
pen_w,
userToDeviceSize( plotOffset.x ), userToDeviceSize( plotOffset.y ),
plotScale, plotScale );
m_graphics_changed = false; m_graphics_changed = false;
} }
/* Set the current line width (in IUs) for the next plot /* Set the current line width (in IUs) for the next plot
*/ */
void SVG_PLOTTER::SetCurrentLineWidth( int width ) void SVG_PLOTTER::SetCurrentLineWidth( int width )
...@@ -487,10 +459,16 @@ bool SVG_PLOTTER::StartPlot( FILE* fout ) ...@@ -487,10 +459,16 @@ bool SVG_PLOTTER::StartPlot( FILE* fout )
// End of header // End of header
fprintf( outputFile, " <desc>Picture generated by %s </desc>\n", fprintf( outputFile, " <desc>Picture generated by %s </desc>\n",
TO_UTF8( creator ) ); TO_UTF8( creator ) );
fputs( "<g style=\"fill:black; stroke:black; stroke-width:1\">\n",
outputFile );
setSVGPlotStyle();
// output the pen and brush color (RVB values in hex) and opacity
double opacity = 1.0; // 0.0 (transparent to 1.0 (solid)
fprintf( outputFile,
"<g style=\"fill:#%6.6lX; fill-opacity:%g;stroke:#%6.6lX; stroke-opacity:%g;\n",
m_brush_rgb_color, opacity, m_pen_rgb_color, opacity );
// output the pen cap and line joint
fputs( "stroke-linecap:round; stroke-linejoin:round; \"\n", outputFile );
fputs( " transform=\"translate(0 0) scale(1 1)\">\n", outputFile );
return true; return true;
} }
......
...@@ -118,7 +118,9 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, ...@@ -118,7 +118,9 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
if( DC->LogicalToDeviceXRel( width ) < 2 ) if( DC->LogicalToDeviceXRel( width ) < 2 )
typeaff = LINE; typeaff = LINE;
radius = m_Size / 4; radius = m_Size / 3;
if( GetShape() ) // shape X
radius = m_Size / 2;
switch( typeaff ) switch( typeaff )
{ {
...@@ -142,9 +144,9 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, ...@@ -142,9 +144,9 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
dx2 = 0; dx2 = 0;
dy2 = radius; dy2 = radius;
if( m_Shape ) /* Form X */ if( GetShape() ) // shape X
{ {
dx1 = dy1 = ( radius * 7 ) / 5; dx1 = dy1 = radius;
dx2 = dx1; dx2 = dx1;
dy2 = -dy1; dy2 = -dy1;
} }
......
...@@ -78,7 +78,6 @@ PAD_DRAWINFO::PAD_DRAWINFO() ...@@ -78,7 +78,6 @@ PAD_DRAWINFO::PAD_DRAWINFO()
void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
const wxPoint& aOffset ) const wxPoint& aOffset )
{ {
EDA_COLOR_T color = ColorFromInt(0); // XXX EVIL (it will be ORed later)
wxSize mask_margin; // margin (clearance) used for some non copper layers wxSize mask_margin; // margin (clearance) used for some non copper layers
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
...@@ -143,6 +142,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, ...@@ -143,6 +142,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
else else
drawInfo.m_ShowPadFilled = false; drawInfo.m_ShowPadFilled = false;
EDA_COLOR_T color = ColorFromInt(0); // XXX EVIL (it will be ORed later)
if( m_layerMask & LAYER_FRONT ) if( m_layerMask & LAYER_FRONT )
{ {
color = brd->GetVisibleElementColor( PAD_FR_VISIBLE ); color = brd->GetVisibleElementColor( PAD_FR_VISIBLE );
...@@ -154,7 +154,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode, ...@@ -154,7 +154,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
color = ColorFromInt( color | brd->GetVisibleElementColor( PAD_BK_VISIBLE ) ); color = ColorFromInt( color | brd->GetVisibleElementColor( PAD_BK_VISIBLE ) );
} }
if( color == 0 ) // Not on copper layer XXX EVIL check if( color == 0 ) // Not on a visible copper layer XXX EVIL check
{ {
// If the pad in on only one tech layer, use the layer color else use DARKGRAY // If the pad in on only one tech layer, use the layer color else use DARKGRAY
int mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS; int mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS;
......
...@@ -35,27 +35,24 @@ ...@@ -35,27 +35,24 @@
#include <wxBasePcbFrame.h> #include <wxBasePcbFrame.h>
#include <class_pcb_screen.h> #include <class_pcb_screen.h>
#include <base_units.h> #include <base_units.h>
#include <convert_from_iu.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <pcbplot.h> #include <pcbplot.h>
#include <printout_controler.h> #include <printout_controler.h>
#include <class_board.h> #include <class_board.h>
#include <dialog_SVG_print.h> #include <dialog_SVG_print.h>
// Keys for configuration // Keys for configuration
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" ) #define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
#define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" ) #define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" )
#define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" ) #define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" )
// reasonnable values for default pen width // reasonnable values for default pen width
#define WIDTH_MAX_VALUE (2 *IU_PER_MM) #define WIDTH_MAX_VALUE (2 * IU_PER_MM)
#define WIDTH_MIN_VALUE (0.05 *IU_PER_MM) #define WIDTH_MIN_VALUE (0.05 * IU_PER_MM)
// Local variables: // Local variables:
static PRINT_PARAMETERS s_Parameters;
static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT | static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT |
SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK; SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK;
...@@ -66,42 +63,45 @@ static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT | ...@@ -66,42 +63,45 @@ static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT |
DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ) : DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ) :
DIALOG_SVG_PRINT_base( parent ) DIALOG_SVG_PRINT_base( parent )
{ {
m_Parent = (PCB_BASE_FRAME*) parent; m_Parent = (PCB_BASE_FRAME*) parent;
m_Config = wxGetApp().GetSettings(); m_Config = wxGetApp().GetSettings();
initDialog(); initDialog();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
Centre(); Centre();
m_buttonBoard->SetDefault();
} }
bool DIALOG_SVG_PRINT::m_printMirror = false;
bool DIALOG_SVG_PRINT::m_oneFileOnly = false;
void DIALOG_SVG_PRINT::initDialog( ) void DIALOG_SVG_PRINT::initDialog()
{ {
SetFocus(); // Make ESC key working
if( m_Config ) if( m_Config )
{ {
m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_Parameters.m_Print_Black_and_White ); m_Config->Read( PLOTSVGMODECOLOR_KEY, &m_printBW, false );
long ltmp; long ltmp;
m_Config->Read( PLOTSVGPAGESIZEOPT_KEY, &ltmp, 0 ); m_Config->Read( PLOTSVGPAGESIZEOPT_KEY, &ltmp, 0 );
m_rbSvgPageSizeOpt->SetSelection( ltmp ); m_rbSvgPageSizeOpt->SetSelection( ltmp );
m_Config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, &ltmp, 1 ); m_Config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, &ltmp, 1 );
m_PrintBoardEdgesCtrl->SetValue(ltmp ); m_PrintBoardEdgesCtrl->SetValue( ltmp );
} }
if( s_Parameters.m_Print_Black_and_White ) if( m_printBW )
m_ModeColorOption->SetSelection( 1 ); m_ModeColorOption->SetSelection( 1 );
else else
m_ModeColorOption->SetSelection( 0 ); m_ModeColorOption->SetSelection( 0 );
s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness; m_printMirrorOpt->SetValue( m_printMirror );
m_rbFileOpt->SetSelection( m_oneFileOnly ? 1 : 0 );
AddUnitSymbol( *m_TextPenWidth, g_UserUnit ); AddUnitSymbol( *m_TextPenWidth, g_UserUnit );
m_DialogDefaultPenSize->SetValue( m_DialogDefaultPenSize->SetValue(
ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) ); ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) );
// Create layers list // Create layers list
BOARD* board = m_Parent->GetBoard(); BOARD* board = m_Parent->GetBoard();
int layer; int layer;
for( layer = 0; layer < NB_LAYERS; ++layer ) for( layer = 0; layer < NB_LAYERS; ++layer )
{ {
if( !board->IsLayerEnabled( layer ) ) if( !board->IsLayerEnabled( layer ) )
...@@ -110,20 +110,23 @@ void DIALOG_SVG_PRINT::initDialog( ) ...@@ -110,20 +110,23 @@ void DIALOG_SVG_PRINT::initDialog( )
m_BoxSelectLayer[layer] = m_BoxSelectLayer[layer] =
new wxCheckBox( this, -1, board->GetLayerName( layer ) ); new wxCheckBox( this, -1, board->GetLayerName( layer ) );
} }
// Add wxCheckBoxes in layers lists dialog // Add wxCheckBoxes in layers lists dialog
// List layers in same order than in setup layers dialog // List layers in same order than in setup layers dialog
// (Front or Top to Back or Bottom) // (Front or Top to Back or Bottom)
DECLARE_LAYERS_ORDER_LIST(layersOrder); DECLARE_LAYERS_ORDER_LIST( layersOrder );
for( int layer_idx = 0; layer_idx < NB_LAYERS; ++layer_idx ) for( int layer_idx = 0; layer_idx < NB_LAYERS; ++layer_idx )
{ {
layer = layersOrder[layer_idx]; layer = layersOrder[layer_idx];
wxASSERT(layer < NB_LAYERS); wxASSERT( layer < NB_LAYERS );
if( m_BoxSelectLayer[layer] == NULL ) if( m_BoxSelectLayer[layer] == NULL )
continue; continue;
long mask = 1 << layer; long mask = 1 << layer;
if( mask & s_SelectedLayers ) if( mask & s_SelectedLayers )
m_BoxSelectLayer[layer]->SetValue( true ); m_BoxSelectLayer[layer]->SetValue( true );
...@@ -143,11 +146,13 @@ void DIALOG_SVG_PRINT::initDialog( ) ...@@ -143,11 +146,13 @@ void DIALOG_SVG_PRINT::initDialog( )
{ {
wxString layerKey; wxString layerKey;
for( int layer = 0; layer<NB_LAYERS; ++layer ) for( int layer = 0; layer<NB_LAYERS; ++layer )
{ {
bool option; bool option;
if ( m_BoxSelectLayer[layer] == NULL )
if( m_BoxSelectLayer[layer] == NULL )
continue; continue;
layerKey.Printf( OPTKEY_LAYERBASE, layer ); layerKey.Printf( OPTKEY_LAYERBASE, layer );
if( m_Config->Read( layerKey, &option ) ) if( m_Config->Read( layerKey, &option ) )
...@@ -159,82 +164,77 @@ void DIALOG_SVG_PRINT::initDialog( ) ...@@ -159,82 +164,77 @@ void DIALOG_SVG_PRINT::initDialog( )
void DIALOG_SVG_PRINT::SetPenWidth() void DIALOG_SVG_PRINT::SetPenWidth()
{ {
s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogDefaultPenSize ); int pensize = ReturnValueFromTextCtrl( *m_DialogDefaultPenSize );
if( s_Parameters.m_PenDefaultSize > WIDTH_MAX_VALUE ) if( pensize > WIDTH_MAX_VALUE )
{ {
s_Parameters.m_PenDefaultSize = WIDTH_MAX_VALUE; pensize = WIDTH_MAX_VALUE;
} }
if( s_Parameters.m_PenDefaultSize < WIDTH_MIN_VALUE ) if( pensize < WIDTH_MIN_VALUE )
{ {
s_Parameters.m_PenDefaultSize = WIDTH_MIN_VALUE; pensize = WIDTH_MIN_VALUE;
} }
g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize; g_DrawDefaultLineThickness = pensize;
m_DialogDefaultPenSize->SetValue( m_DialogDefaultPenSize->SetValue( ReturnStringFromValue( g_UserUnit, pensize ) );
ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) );
} }
void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll )
{ {
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection(); m_printMirror = m_printMirrorOpt->GetValue();
m_printBW = m_ModeColorOption->GetSelection();
SetPenWidth(); SetPenWidth();
PCB_SCREEN* screen = m_Parent->GetScreen(); // Build layers mask
int printMaskLayer = 0;
if( aPrintAll )
m_PrintMaskLayer = 0xFFFFFFFF;
else
m_PrintMaskLayer = 0;
if( m_PrintBoardEdgesCtrl->IsChecked() )
m_PrintMaskLayer |= EDGE_LAYER;
else
m_PrintMaskLayer &= ~EDGE_LAYER;
for( int layer = 0; layer<NB_LAYERS; layer++ ) for( int layer = 0; layer<NB_LAYERS; layer++ )
{ {
if ( m_BoxSelectLayer[layer] == NULL ) if( m_BoxSelectLayer[layer] && m_BoxSelectLayer[layer]->GetValue() )
continue; printMaskLayer |= 1 << layer;
}
if( !aPrintAll && !m_BoxSelectLayer[layer]->GetValue() ) for( int layer = 0; layer<NB_LAYERS; layer++ )
{
int currlayer_mask = 1 << layer;
if( (printMaskLayer & currlayer_mask ) == 0 )
continue; continue;
fn = m_FileNameCtrl->GetValue(); fn = m_FileNameCtrl->GetValue();
if( !fn.IsOk() ) if( !fn.IsOk() )
{
fn = m_Parent->GetBoard()->GetFileName(); fn = m_Parent->GetBoard()->GetFileName();
}
if( aPrintAll ) if( aOnlyOneFile )
{
m_PrintMaskLayer = printMaskLayer;
fn.SetName( fn.GetName() + wxT( "-brd" ) ); fn.SetName( fn.GetName() + wxT( "-brd" ) );
}
else else
{ {
wxString extraname = m_Parent->GetBoard()->GetLayerName( layer, false ); m_PrintMaskLayer = currlayer_mask;
extraname.Trim(); // remove leading and trailing spaces if any wxString suffix = m_Parent->GetBoard()->GetLayerName( layer, false );
extraname.Trim(false); suffix.Trim(); // remove leading and trailing spaces if any
fn.SetName( fn.GetName() + wxT( "-" ) + extraname ); suffix.Trim( false );
fn.SetName( fn.GetName() + wxT( "-" ) + suffix );
m_PrintMaskLayer = 1 << layer;
if( m_PrintBoardEdgesCtrl->IsChecked() )
m_PrintMaskLayer |= EDGE_LAYER;
} }
fn.SetExt( wxT( "svg" ) ); fn.SetExt( wxT( "svg" ) );
bool success = DrawPage( fn.GetFullPath(), screen ); if( m_PrintBoardEdgesCtrl->IsChecked() )
msg = _( "Create file " ) + fn.GetFullPath(); m_PrintMaskLayer |= EDGE_LAYER;
if( !success )
msg += _( " error" ); if( CreateSVGFile( fn.GetFullPath() ) )
msg += wxT( "\n" ); msg.Printf( _( "Plot: %s OK\n" ), GetChars( fn.GetFullPath() ) );
else // Error
msg.Printf( _( "** Unable to create %s **\n" ), GetChars( fn.GetFullPath() ) );
m_MessagesBox->AppendText( msg ); m_MessagesBox->AppendText( msg );
if( aPrintAll ) if( aOnlyOneFile )
break; break;
} }
} }
...@@ -243,83 +243,61 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll ) ...@@ -243,83 +243,61 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll )
/* /*
* Actual print function. * Actual print function.
*/ */
bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
BASE_SCREEN* screen )
{ {
LOCALE_IO toggle; BOARD* brd = m_Parent->GetBoard();
int tmpzoom;
wxPoint tmp_startvisu;
wxPoint old_org;
bool success = true;
// Change frames and local settings
tmp_startvisu = screen->m_StartVisu;
tmpzoom = screen->GetZoom();
old_org = screen->m_DrawOrg;
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
screen->SetScalingFactor( 1.0 ); PCB_PLOT_PARAMS m_plotOpts;
double dpi = IU_PER_MILS * 1000.0; m_plotOpts.SetPlotFrameRef( PrintPageRef() );
m_plotOpts.SetDrillMarksType( PCB_PLOT_PARAMS::FULL_DRILL_SHAPE );
m_plotOpts.SetMirror( m_printMirror );
m_plotOpts.SetFormat( PLOT_FORMAT_SVG );
EDA_COLOR_T color = BLACK;
m_plotOpts.SetReferenceColor( color );
m_plotOpts.SetValueColor( color );
EDA_DRAW_PANEL* panel = m_Parent->GetCanvas(); PAGE_INFO pageInfo = brd->GetPageSettings();
wxPoint axisorigin = brd->GetOriginAxisPosition();
// paper pageSize is in internal units, either nanometers or deci-mils
EDA_RECT rect;
rect.SetSize( m_Parent->GetPageSizeIU() );
if( PageIsBoardBoundarySize() ) if( PageIsBoardBoundarySize() )
{ {
rect = m_Parent->GetBoard()->ComputeBoundingBox(); EDA_RECT bbox = brd->ComputeBoundingBox();
PAGE_INFO currpageInfo = brd->GetPageSettings();
currpageInfo.SetWidthMils( bbox.GetWidth() / IU_PER_MILS );
currpageInfo.SetHeightMils( bbox.GetHeight() / IU_PER_MILS );
brd->SetPageSettings( currpageInfo );
m_plotOpts.SetUseAuxOrigin( true );
wxPoint origin = bbox.GetOrigin();
brd->SetOriginAxisPosition( origin );
} }
KicadSVGFileDC dc( FullFileName, rect.GetOrigin(), rect.GetSize(), dpi ); LOCALE_IO toggle;
SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( brd,
EDA_RECT tmp = *panel->GetClipBox(); &m_plotOpts, aFullFileName,
GRResetPenAndBrush( &dc ); wxEmptyString );
GRForceBlackPen( s_Parameters.m_Print_Black_and_White );
s_Parameters.m_DrillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE;
// Set clip box to the max size
#define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer
// and that allows calculations without overflow
panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) );
screen->m_IsPrinting = true;
EDA_COLOR_T bg_color = g_DrawBgColor;
g_DrawBgColor = WHITE;
if( PrintPageRef() )
m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize,
IU_PER_MILS, wxT( "" ) );
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color;
screen->m_IsPrinting = false; if( plotter )
panel->SetClipBox( tmp ); {
plotter->SetColorMode( m_ModeColorOption->GetSelection() == 0 );
GRForceBlackPen( false ); PlotStandardLayer( brd, plotter, m_PrintMaskLayer, m_plotOpts, true, false );
// Adding drill marks, if required and if the plotter is able to plot them:
screen->m_StartVisu = tmp_startvisu; if( m_plotOpts.GetDrillMarksType() != PCB_PLOT_PARAMS::NO_DRILL_SHAPE )
screen->m_DrawOrg = old_org; PlotDrillMarks( brd, plotter, m_plotOpts );
screen->SetZoom( tmpzoom ); }
return success;
}
plotter->EndPlot();
delete plotter;
brd->SetOriginAxisPosition( axisorigin );
brd->SetPageSettings( pageInfo );
void DIALOG_SVG_PRINT::OnButtonPrintBoardClick( wxCommandEvent& event ) return true;
{
PrintSVGDoc( true );
} }
void DIALOG_SVG_PRINT::OnButtonPlot( wxCommandEvent& event )
void DIALOG_SVG_PRINT::OnButtonPrintSelectedClick( wxCommandEvent& event )
{ {
PrintSVGDoc( false ); m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;
ExportSVGFile( m_oneFileOnly );
} }
...@@ -332,21 +310,26 @@ void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event ) ...@@ -332,21 +310,26 @@ void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event )
void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
{ {
SetPenWidth(); SetPenWidth();
s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection(); m_printBW = m_ModeColorOption->GetSelection();
m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;
if( m_Config ) if( m_Config )
{ {
m_Config->Write( PLOTSVGMODECOLOR_KEY, s_Parameters.m_Print_Black_and_White ); m_Config->Write( PLOTSVGMODECOLOR_KEY, m_printBW );
m_Config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() ); m_Config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() );
m_Config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() ); m_Config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() );
wxString layerKey; wxString layerKey;
for( int layer = 0; layer<NB_LAYERS; ++layer )
for( int layer = 0; layer<NB_LAYERS; ++layer )
{ {
if( m_BoxSelectLayer[layer] == NULL ) if( m_BoxSelectLayer[layer] == NULL )
continue; continue;
layerKey.Printf( OPTKEY_LAYERBASE, layer ); layerKey.Printf( OPTKEY_LAYERBASE, layer );
m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() ); m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
} }
} }
EndModal( 0 ); EndModal( 0 );
} }
...@@ -18,6 +18,10 @@ private: ...@@ -18,6 +18,10 @@ private:
wxConfig* m_Config; wxConfig* m_Config;
long m_PrintMaskLayer; long m_PrintMaskLayer;
wxCheckBox* m_BoxSelectLayer[32]; wxCheckBox* m_BoxSelectLayer[32];
bool m_printBW;
// Static member to store options
static bool m_printMirror;
static bool m_oneFileOnly;
public: public:
DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ); DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent );
...@@ -26,11 +30,10 @@ public: ...@@ -26,11 +30,10 @@ public:
private: private:
void OnCloseWindow( wxCloseEvent& event ); void OnCloseWindow( wxCloseEvent& event );
void initDialog( ); void initDialog( );
void OnButtonPrintSelectedClick( wxCommandEvent& event ); void OnButtonPlot( wxCommandEvent& event );
void OnButtonPrintBoardClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event ); void OnButtonCancelClick( wxCommandEvent& event );
void SetPenWidth(); void SetPenWidth();
void PrintSVGDoc( bool aPrintAll ); void ExportSVGFile( bool aOnlyOneFile );
bool PageIsBoardBoundarySize() bool PageIsBoardBoundarySize()
{ {
return m_rbSvgPageSizeOpt->GetSelection() == 2; return m_rbSvgPageSizeOpt->GetSelection() == 2;
...@@ -39,7 +42,7 @@ private: ...@@ -39,7 +42,7 @@ private:
{ {
return m_rbSvgPageSizeOpt->GetSelection() == 0; return m_rbSvgPageSizeOpt->GetSelection() == 0;
} }
bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen ); bool CreateSVGFile( const wxString& FullFileName );
}; };
......
...@@ -40,7 +40,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -40,7 +40,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Default pen size"), wxDefaultPosition, wxDefaultSize, 0 ); m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Default pen size"), wxDefaultPosition, wxDefaultSize, 0 );
m_TextPenWidth->Wrap( -1 ); m_TextPenWidth->Wrap( -1 );
sbOptionsSizer->Add( m_TextPenWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); sbOptionsSizer->Add( m_TextPenWidth, 0, wxRIGHT|wxLEFT, 5 );
m_DialogDefaultPenSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_DialogDefaultPenSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DialogDefaultPenSize->SetToolTip( _("Selection of the pen size used to draw items which have no pen size speicfied.") ); m_DialogDefaultPenSize->SetToolTip( _("Selection of the pen size used to draw items which have no pen size speicfied.") );
...@@ -53,37 +53,43 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -53,37 +53,43 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
m_ModeColorOption->SetSelection( 1 ); m_ModeColorOption->SetSelection( 1 );
m_ModeColorOption->SetToolTip( _("Choose if you want to draw the sheet like it appears on screen,\nor in black and white mode, better to print it when using black and white printers") ); m_ModeColorOption->SetToolTip( _("Choose if you want to draw the sheet like it appears on screen,\nor in black and white mode, better to print it when using black and white printers") );
sbOptionsSizer->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 ); sbOptionsSizer->Add( m_ModeColorOption, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxString m_rbSvgPageSizeOptChoices[] = { _("Full page with frame ref"), _("Current page size"), _("Board area only") }; wxString m_rbSvgPageSizeOptChoices[] = { _("Full page with frame ref"), _("Current page size"), _("Board area only") };
int m_rbSvgPageSizeOptNChoices = sizeof( m_rbSvgPageSizeOptChoices ) / sizeof( wxString ); int m_rbSvgPageSizeOptNChoices = sizeof( m_rbSvgPageSizeOptChoices ) / sizeof( wxString );
m_rbSvgPageSizeOpt = new wxRadioBox( this, wxID_ANY, _("SVG Page Size"), wxDefaultPosition, wxDefaultSize, m_rbSvgPageSizeOptNChoices, m_rbSvgPageSizeOptChoices, 1, wxRA_SPECIFY_COLS ); m_rbSvgPageSizeOpt = new wxRadioBox( this, wxID_ANY, _("SVG Page Size"), wxDefaultPosition, wxDefaultSize, m_rbSvgPageSizeOptNChoices, m_rbSvgPageSizeOptChoices, 1, wxRA_SPECIFY_COLS );
m_rbSvgPageSizeOpt->SetSelection( 0 ); m_rbSvgPageSizeOpt->SetSelection( 0 );
sbOptionsSizer->Add( m_rbSvgPageSizeOpt, 0, wxALL|wxEXPAND, 5 ); sbOptionsSizer->Add( m_rbSvgPageSizeOpt, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_PrintBoardEdgesCtrl = new wxCheckBox( this, wxID_ANY, _("Print board edges"), wxDefaultPosition, wxDefaultSize, 0 ); m_PrintBoardEdgesCtrl = new wxCheckBox( this, wxID_ANY, _("Print board edges"), wxDefaultPosition, wxDefaultSize, 0 );
m_PrintBoardEdgesCtrl->SetValue(true);
m_PrintBoardEdgesCtrl->SetToolTip( _("Print (or not) the edges layer on others layers") ); m_PrintBoardEdgesCtrl->SetToolTip( _("Print (or not) the edges layer on others layers") );
sbOptionsSizer->Add( m_PrintBoardEdgesCtrl, 0, wxALL, 5 ); sbOptionsSizer->Add( m_PrintBoardEdgesCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_printMirrorOpt = new wxCheckBox( this, wxID_ANY, _("Print mirror"), wxDefaultPosition, wxDefaultSize, 0 );
sbOptionsSizer->Add( m_printMirrorOpt, 0, wxRIGHT|wxLEFT, 5 );
bUpperSizer->Add( sbOptionsSizer, 1, wxEXPAND, 5 );
bUpperSizer->Add( sbOptionsSizer, 0, wxEXPAND, 5 );
wxBoxSizer* bButtonsSizer; wxBoxSizer* bButtonsSizer;
bButtonsSizer = new wxBoxSizer( wxVERTICAL ); bButtonsSizer = new wxBoxSizer( wxVERTICAL );
m_buttonPrintSelected = new wxButton( this, wxID_PRINT_CURRENT, _("Print Selected"), wxDefaultPosition, wxDefaultSize, 0 ); wxString m_rbFileOptChoices[] = { _("One file per layer"), _("All in one file") };
m_buttonPrintSelected->SetDefault(); int m_rbFileOptNChoices = sizeof( m_rbFileOptChoices ) / sizeof( wxString );
bButtonsSizer->Add( m_buttonPrintSelected, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); m_rbFileOpt = new wxRadioBox( this, wxID_ANY, _("wxRadioBox"), wxDefaultPosition, wxDefaultSize, m_rbFileOptNChoices, m_rbFileOptChoices, 1, wxRA_SPECIFY_COLS );
m_rbFileOpt->SetSelection( 0 );
bButtonsSizer->Add( m_rbFileOpt, 0, wxALL, 5 );
m_buttonBoard = new wxButton( this, wxID_PRINT_BOARD, _("Print Board"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonCreateFile = new wxButton( this, wxID_PRINT_BOARD, _("Plot"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_buttonBoard, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); bButtonsSizer->Add( m_buttonCreateFile, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Quit"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
bButtonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); bButtonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
bUpperSizer->Add( bButtonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); bUpperSizer->Add( bButtonsSizer, 0, wxEXPAND, 5 );
bMainSizer->Add( bUpperSizer, 0, wxEXPAND, 5 ); bMainSizer->Add( bUpperSizer, 0, wxEXPAND, 5 );
...@@ -113,8 +119,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -113,8 +119,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) );
m_buttonPrintSelected->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintSelectedClick ), NULL, this ); m_buttonCreateFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPlot ), NULL, this );
m_buttonBoard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this );
m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this ); m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this );
} }
...@@ -122,8 +127,7 @@ DIALOG_SVG_PRINT_base::~DIALOG_SVG_PRINT_base() ...@@ -122,8 +127,7 @@ DIALOG_SVG_PRINT_base::~DIALOG_SVG_PRINT_base()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) );
m_buttonPrintSelected->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintSelectedClick ), NULL, this ); m_buttonCreateFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPlot ), NULL, this );
m_buttonBoard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this );
m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this ); m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this );
} }
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<property name="minimum_size">-1,350</property> <property name="minimum_size">-1,350</property>
<property name="name">DIALOG_SVG_PRINT_base</property> <property name="name">DIALOG_SVG_PRINT_base</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">507,375</property> <property name="size">507,420</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="title">Create SVG file</property> <property name="title">Create SVG file</property>
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="1"> <object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Print SVG options:</property> <property name="label">Print SVG options:</property>
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property> <property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticText" expanded="1"> <object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
...@@ -330,7 +330,7 @@ ...@@ -330,7 +330,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxRadioBox" expanded="1"> <object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
...@@ -420,7 +420,7 @@ ...@@ -420,7 +420,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxRadioBox" expanded="1"> <object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
...@@ -510,7 +510,7 @@ ...@@ -510,7 +510,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="1"> <object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
...@@ -526,7 +526,7 @@ ...@@ -526,7 +526,7 @@
<property name="caption"></property> <property name="caption"></property>
<property name="caption_visible">1</property> <property name="caption_visible">1</property>
<property name="center_pane">0</property> <property name="center_pane">0</property>
<property name="checked">0</property> <property name="checked">1</property>
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
...@@ -596,11 +596,99 @@ ...@@ -596,11 +596,99 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Print mirror</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_printMirrorOpt</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property> <property name="flag">wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
...@@ -609,9 +697,9 @@ ...@@ -609,9 +697,9 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property> <property name="flag">wxALL</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxButton" expanded="1"> <object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
...@@ -625,10 +713,10 @@ ...@@ -625,10 +713,10 @@
<property name="caption"></property> <property name="caption"></property>
<property name="caption_visible">1</property> <property name="caption_visible">1</property>
<property name="center_pane">0</property> <property name="center_pane">0</property>
<property name="choices">&quot;One file per layer&quot; &quot;All in one file&quot;</property>
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default">1</property>
<property name="default_pane">0</property> <property name="default_pane">0</property>
<property name="dock">Dock</property> <property name="dock">Dock</property>
<property name="dock_fixed">0</property> <property name="dock_fixed">0</property>
...@@ -639,8 +727,9 @@ ...@@ -639,8 +727,9 @@
<property name="font"></property> <property name="font"></property>
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_PRINT_CURRENT</property> <property name="id">wxID_ANY</property>
<property name="label">Print Selected</property> <property name="label">wxRadioBox</property>
<property name="majorDimension">1</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
...@@ -648,7 +737,7 @@ ...@@ -648,7 +737,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_buttonPrintSelected</property> <property name="name">m_rbFileOpt</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
...@@ -656,9 +745,10 @@ ...@@ -656,9 +745,10 @@
<property name="pin_button">1</property> <property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style"></property> <property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
...@@ -669,7 +759,6 @@ ...@@ -669,7 +759,6 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnButtonClick">OnButtonPrintSelectedClick</event>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
...@@ -687,6 +776,7 @@ ...@@ -687,6 +776,7 @@
<event name="OnMouseEvents"></event> <event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event> <event name="OnMouseWheel"></event>
<event name="OnPaint"></event> <event name="OnPaint"></event>
<event name="OnRadioBox"></event>
<event name="OnRightDClick"></event> <event name="OnRightDClick"></event>
<event name="OnRightDown"></event> <event name="OnRightDown"></event>
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
...@@ -728,7 +818,7 @@ ...@@ -728,7 +818,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_PRINT_BOARD</property> <property name="id">wxID_PRINT_BOARD</property>
<property name="label">Print Board</property> <property name="label">Plot</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
...@@ -736,7 +826,7 @@ ...@@ -736,7 +826,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_buttonBoard</property> <property name="name">m_buttonCreateFile</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
...@@ -757,7 +847,7 @@ ...@@ -757,7 +847,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnButtonClick">OnButtonPrintBoardClick</event> <event name="OnButtonClick">OnButtonPlot</event>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
...@@ -816,7 +906,7 @@ ...@@ -816,7 +906,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_CANCEL</property> <property name="id">wxID_CANCEL</property>
<property name="label">Quit</property> <property name="label">Close</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
......
...@@ -37,8 +37,7 @@ class DIALOG_SVG_PRINT_base : public wxDialog ...@@ -37,8 +37,7 @@ class DIALOG_SVG_PRINT_base : public wxDialog
protected: protected:
enum enum
{ {
wxID_PRINT_CURRENT = 1000, wxID_PRINT_BOARD = 1000
wxID_PRINT_BOARD
}; };
wxStaticBoxSizer* m_CopperLayersBoxSizer; wxStaticBoxSizer* m_CopperLayersBoxSizer;
...@@ -48,8 +47,9 @@ class DIALOG_SVG_PRINT_base : public wxDialog ...@@ -48,8 +47,9 @@ class DIALOG_SVG_PRINT_base : public wxDialog
wxRadioBox* m_ModeColorOption; wxRadioBox* m_ModeColorOption;
wxRadioBox* m_rbSvgPageSizeOpt; wxRadioBox* m_rbSvgPageSizeOpt;
wxCheckBox* m_PrintBoardEdgesCtrl; wxCheckBox* m_PrintBoardEdgesCtrl;
wxButton* m_buttonPrintSelected; wxCheckBox* m_printMirrorOpt;
wxButton* m_buttonBoard; wxRadioBox* m_rbFileOpt;
wxButton* m_buttonCreateFile;
wxButton* m_buttonQuit; wxButton* m_buttonQuit;
wxStaticText* m_staticText1; wxStaticText* m_staticText1;
wxTextCtrl* m_FileNameCtrl; wxTextCtrl* m_FileNameCtrl;
...@@ -58,14 +58,13 @@ class DIALOG_SVG_PRINT_base : public wxDialog ...@@ -58,14 +58,13 @@ class DIALOG_SVG_PRINT_base : public wxDialog
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnButtonPrintSelectedClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonPlot( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonPrintBoardClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); }
public: public:
DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Create SVG file"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 507,375 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Create SVG file"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 507,420 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_SVG_PRINT_base(); ~DIALOG_SVG_PRINT_base();
}; };
......
...@@ -57,7 +57,7 @@ DIALOG_GENDRILL_BASE::DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id, con ...@@ -57,7 +57,7 @@ DIALOG_GENDRILL_BASE::DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id, con
wxString m_Choice_Drill_MapChoices[] = { _("None"), _("Drill map (HPGL)"), _("Drill map (PostScript)"), _("Drill map (Gerber)"), _("Drill map (DXF)"), _("Drill map (SVG)") }; wxString m_Choice_Drill_MapChoices[] = { _("None"), _("Drill map (HPGL)"), _("Drill map (PostScript)"), _("Drill map (Gerber)"), _("Drill map (DXF)"), _("Drill map (SVG)") };
int m_Choice_Drill_MapNChoices = sizeof( m_Choice_Drill_MapChoices ) / sizeof( wxString ); int m_Choice_Drill_MapNChoices = sizeof( m_Choice_Drill_MapChoices ) / sizeof( wxString );
m_Choice_Drill_Map = new wxRadioBox( this, wxID_ANY, _("Drill Sheet:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapNChoices, m_Choice_Drill_MapChoices, 1, wxRA_SPECIFY_COLS ); m_Choice_Drill_Map = new wxRadioBox( this, wxID_ANY, _("Drill Map:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapNChoices, m_Choice_Drill_MapChoices, 1, wxRA_SPECIFY_COLS );
m_Choice_Drill_Map->SetSelection( 0 ); m_Choice_Drill_Map->SetSelection( 0 );
m_Choice_Drill_Map->SetToolTip( _("Creates a drill map in PS, HPGL or other formats") ); m_Choice_Drill_Map->SetToolTip( _("Creates a drill map in PS, HPGL or other formats") );
......
...@@ -504,7 +504,7 @@ ...@@ -504,7 +504,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Drill Sheet:</property> <property name="label">Drill Map:</property>
<property name="majorDimension">1</property> <property name="majorDimension">1</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
......
...@@ -216,8 +216,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() ...@@ -216,8 +216,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// Create SVG file // Create SVG file
AddMenuItem( filesMenu, ID_GEN_PLOT_SVG, AddMenuItem( filesMenu, ID_GEN_PLOT_SVG,
_( "Print SV&G" ), _( "Export SV&G" ),
_( "Plot board in Scalable Vector Graphics format" ), _( "Export a board file in Scalable Vector Graphics format" ),
KiBitmap( plot_svg_xpm ) ); KiBitmap( plot_svg_xpm ) );
// Plot // Plot
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <class_board.h> #include <class_board.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <plotcontroller.h> #include <plotcontroller.h>
#include <pcb_plot_params.h>
#include <wx/ffile.h> #include <wx/ffile.h>
#include <dialog_plot.h> #include <dialog_plot.h>
......
...@@ -34,18 +34,87 @@ static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte, ...@@ -34,18 +34,87 @@ static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte,
EDA_DRAW_MODE_T trace_mode, EDA_COLOR_T aColor ); EDA_DRAW_MODE_T trace_mode, EDA_COLOR_T aColor );
static bool PlotAllTextsModule( PLOTTER* aPlotter, BOARD* aBoard,
long aLayerMask, MODULE* aModule,
const PCB_PLOT_PARAMS& aPlotOpt )
{
TEXTE_MODULE* pt_texte;
EDA_DRAW_MODE_T trace_mode = aPlotOpt.GetMode();
// see if we want to plot VALUE and REF fields
bool trace_val = aPlotOpt.GetPlotValue();
bool trace_ref = aPlotOpt.GetPlotReference();
TEXTE_MODULE* text = aModule->m_Reference;
unsigned textLayer = text->GetLayer();
if( textLayer >= 32 )
return false;
if( ( ( 1 << textLayer ) & aLayerMask ) == 0 )
trace_ref = false;
if( !text->IsVisible() && !aPlotOpt.GetPlotInvisibleText() )
trace_ref = false;
text = aModule->m_Value;
textLayer = text->GetLayer();
if( textLayer > 32 )
return false;
if( ( (1 << textLayer) & aLayerMask ) == 0 )
trace_val = false;
if( !text->IsVisible() && !aPlotOpt.GetPlotInvisibleText() )
trace_val = false;
// Plot text fields, if allowed
if( trace_ref )
PlotTextModule( aPlotter, aModule->m_Reference,
trace_mode, aPlotOpt.GetReferenceColor() );
if( trace_val )
PlotTextModule( aPlotter, aModule->m_Value,
trace_mode, aPlotOpt.GetValueColor() );
for( pt_texte = (TEXTE_MODULE*) aModule->m_Drawings.GetFirst();
pt_texte != NULL; pt_texte = pt_texte->Next() )
{
if( pt_texte->Type() != PCB_MODULE_TEXT_T )
continue;
if( !aPlotOpt.GetPlotOtherText() )
continue;
if( !pt_texte->IsVisible() && !aPlotOpt.GetPlotInvisibleText() )
continue;
textLayer = pt_texte->GetLayer();
if( textLayer >= 32 )
return false;
if( !( ( 1 << textLayer ) & aLayerMask ) )
continue;
EDA_COLOR_T color = aBoard->GetLayerColor( textLayer );
PlotTextModule( aPlotter, pt_texte, trace_mode, color );
}
return true;
}
/* Creates the plot for silkscreen layers /* Creates the plot for silkscreen layers
*/ */
void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
const PCB_PLOT_PARAMS& aPlotOpt ) const PCB_PLOT_PARAMS& aPlotOpt )
{ {
TEXTE_MODULE* pt_texte;
EDA_DRAW_MODE_T trace_mode = aPlotOpt.GetMode(); EDA_DRAW_MODE_T trace_mode = aPlotOpt.GetMode();
// Plot edge layer and graphic items // Plot edge layer and graphic items
for( EDA_ITEM* item = aBoard->m_Drawings; item; item = item->Next() ) for( EDA_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
...@@ -91,11 +160,23 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, ...@@ -91,11 +160,23 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
for( D_PAD * pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) for( D_PAD * pad = Module->m_Pads; pad != NULL; pad = pad->Next() )
{ {
// See if the pad is on this layer // See if the pad is on this layer
if( (pad->GetLayerMask() & layersmask_plotpads) == 0 ) int masklayer = pad->GetLayerMask();
if( (masklayer & layersmask_plotpads) == 0 )
continue; continue;
wxPoint shape_pos = pad->ReturnShapePos(); wxPoint shape_pos = pad->ReturnShapePos();
EDA_COLOR_T color = ColorFromInt(0);
if( (layersmask_plotpads & SILKSCREEN_LAYER_BACK) )
color = aBoard->GetLayerColor( SILKSCREEN_N_BACK );
if((layersmask_plotpads & SILKSCREEN_LAYER_FRONT ) )
color = ColorFromInt( color | aBoard->GetLayerColor( SILKSCREEN_N_FRONT ) );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
switch( pad->GetShape() ) switch( pad->GetShape() )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
...@@ -129,91 +210,10 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, ...@@ -129,91 +210,10 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
// Plot footprints fields (ref, value ...) // Plot footprints fields (ref, value ...)
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{ {
// see if we want to plot VALUE and REF fields if( ! PlotAllTextsModule( aPlotter, aBoard, aLayerMask, module, aPlotOpt ) )
bool trace_val = aPlotOpt.GetPlotValue();
bool trace_ref = aPlotOpt.GetPlotReference();
TEXTE_MODULE* text = module->m_Reference;
unsigned textLayer = text->GetLayer();
if( textLayer >= 32 )
{
wxString errMsg;
errMsg.Printf( _( "Your BOARD has a bad layer number of %u for \
module\n %s's \"reference\" text." ),
textLayer, GetChars( module->GetReference() ) );
DisplayError( NULL, errMsg );
return;
}
if( ( ( 1 << textLayer ) & aLayerMask ) == 0 )
trace_ref = false;
if( !text->IsVisible() && !aPlotOpt.GetPlotInvisibleText() )
trace_ref = false;
text = module->m_Value;
textLayer = text->GetLayer();
if( textLayer > 32 )
{
wxString errMsg;
errMsg.Printf( _( "Your BOARD has a bad layer number of %u for \
module\n %s's \"value\" text." ),
textLayer, GetChars( module->GetReference() ) );
DisplayError( NULL, errMsg );
return;
}
if( ( (1 << textLayer) & aLayerMask ) == 0 )
trace_val = false;
if( !text->IsVisible() && !aPlotOpt.GetPlotInvisibleText() )
trace_val = false;
// Plot text fields, if allowed
if( trace_ref )
PlotTextModule( aPlotter, module->m_Reference,
trace_mode, aPlotOpt.GetReferenceColor() );
if( trace_val )
PlotTextModule( aPlotter, module->m_Value,
trace_mode, aPlotOpt.GetValueColor() );
for( pt_texte = (TEXTE_MODULE*) module->m_Drawings.GetFirst();
pt_texte != NULL;
pt_texte = pt_texte->Next() )
{ {
if( pt_texte->Type() != PCB_MODULE_TEXT_T ) wxLogMessage( _( "Your BOARD has a bad layer number for module %s" ),
continue; GetChars( module->GetReference() ) );
if( !aPlotOpt.GetPlotOtherText() )
continue;
if( !pt_texte->IsVisible() && !aPlotOpt.GetPlotInvisibleText() )
continue;
textLayer = pt_texte->GetLayer();
if( textLayer >= 32 )
{
wxString errMsg;
errMsg.Printf( _( "Your BOARD has a bad layer number of %u \
for module\n %s's \"module text\" text of %s." ),
textLayer, GetChars( module->GetReference() ),
GetChars( pt_texte->m_Text ) );
DisplayError( NULL, errMsg );
return;
}
if( !( ( 1 << textLayer ) & aLayerMask ) )
continue;
PlotTextModule( aPlotter, pt_texte,
trace_mode, aPlotOpt.GetColor() );
} }
} }
...@@ -247,6 +247,8 @@ static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte, ...@@ -247,6 +247,8 @@ static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte,
wxPoint pos; wxPoint pos;
int orient, thickness; int orient, thickness;
aPlotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
// calculate some text parameters : // calculate some text parameters :
size = pt_texte->m_Size; size = pt_texte->m_Size;
pos = pt_texte->m_Pos; pos = pt_texte->m_Pos;
...@@ -287,6 +289,11 @@ void PlotDimension( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ...@@ -287,6 +289,11 @@ void PlotDimension( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
draw.SetWidth( (trace_mode==LINE) ? -1 : aDim->GetWidth() ); draw.SetWidth( (trace_mode==LINE) ? -1 : aDim->GetWidth() );
draw.SetLayer( aDim->GetLayer() ); draw.SetLayer( aDim->GetLayer() );
EDA_COLOR_T color = aDim->GetBoard()->GetLayerColor( aDim->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
PlotTextePcb( aPlotter, aPlotOpts, &aDim->m_Text, aLayerMask, trace_mode ); PlotTextePcb( aPlotter, aPlotOpts, &aDim->m_Text, aLayerMask, trace_mode );
draw.SetStart( wxPoint( aDim->m_crossBarOx, aDim->m_crossBarOy )); draw.SetStart( wxPoint( aDim->m_crossBarOx, aDim->m_crossBarOy ));
...@@ -328,14 +335,21 @@ void PlotPcbTarget( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ...@@ -328,14 +335,21 @@ void PlotPcbTarget( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
if( (GetLayerMask( aMire->GetLayer() ) & aLayerMask) == 0 ) if( (GetLayerMask( aMire->GetLayer() ) & aLayerMask) == 0 )
return; return;
EDA_COLOR_T color = aMire->GetBoard()->GetLayerColor( aMire->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
DRAWSEGMENT draw; DRAWSEGMENT draw;
draw.SetShape( S_CIRCLE ); draw.SetShape( S_CIRCLE );
draw.SetWidth( ( trace_mode == LINE ) ? -1 : aMire->GetWidth() ); draw.SetWidth( ( trace_mode == LINE ) ? -1 : aMire->GetWidth() );
draw.SetLayer( aMire->GetLayer() ); draw.SetLayer( aMire->GetLayer() );
draw.SetStart( aMire->GetPosition() ); draw.SetStart( aMire->GetPosition() );
draw.SetEnd( wxPoint( draw.GetStart().x + ( aMire->GetSize() / 4 ), draw.GetStart().y )); radius = aMire->GetSize() / 3;
if( aMire->GetShape() ) // shape X
radius = aMire->GetSize() / 2;
draw.SetEnd( wxPoint( draw.GetStart().x + radius, draw.GetStart().y ));
PlotDrawSegment( aPlotter, aPlotOpts, &draw, aLayerMask, trace_mode ); PlotDrawSegment( aPlotter, aPlotOpts, &draw, aLayerMask, trace_mode );
draw.SetShape( S_SEGMENT ); draw.SetShape( S_SEGMENT );
...@@ -348,7 +362,7 @@ void PlotPcbTarget( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ...@@ -348,7 +362,7 @@ void PlotPcbTarget( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
if( aMire->GetShape() ) // Shape X if( aMire->GetShape() ) // Shape X
{ {
dx1 = dy1 = ( radius * 7 ) / 5; dx1 = dy1 = radius;
dx2 = dx1; dx2 = dx1;
dy2 = -dy1; dy2 = -dy1;
} }
...@@ -400,6 +414,11 @@ void Plot_1_EdgeModule( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ...@@ -400,6 +414,11 @@ void Plot_1_EdgeModule( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
if( aEdge->Type() != PCB_MODULE_EDGE_T ) if( aEdge->Type() != PCB_MODULE_EDGE_T )
return; return;
EDA_COLOR_T color = aEdge->GetBoard( )->GetLayerColor( aEdge->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
type_trace = aEdge->GetShape(); type_trace = aEdge->GetShape();
thickness = aEdge->GetWidth(); thickness = aEdge->GetWidth();
...@@ -486,6 +505,11 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC ...@@ -486,6 +505,11 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC
if( ( GetLayerMask( pt_texte->GetLayer() ) & aLayerMask ) == 0 ) if( ( GetLayerMask( pt_texte->GetLayer() ) & aLayerMask ) == 0 )
return; return;
EDA_COLOR_T color = pt_texte->GetBoard( )->GetLayerColor( pt_texte->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
size = pt_texte->m_Size; size = pt_texte->m_Size;
pos = pt_texte->m_Pos; pos = pt_texte->m_Pos;
orient = pt_texte->m_Orient; orient = pt_texte->m_Orient;
...@@ -543,6 +567,11 @@ void PlotFilledAreas( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_ ...@@ -543,6 +567,11 @@ void PlotFilledAreas( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_
static std::vector< wxPoint > cornerList; static std::vector< wxPoint > cornerList;
cornerList.clear(); cornerList.clear();
EDA_COLOR_T color = aZone->GetBoard( )->GetLayerColor( aZone->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
/* Plot all filled areas: filled areas have a filled area and a thick /* Plot all filled areas: filled areas have a filled area and a thick
* outline we must plot the filled area itself ( as a filled polygon * outline we must plot the filled area itself ( as a filled polygon
* OR a set of segments ) and plot the thick outline itself * OR a set of segments ) and plot the thick outline itself
...@@ -622,6 +651,14 @@ void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ...@@ -622,6 +651,14 @@ void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
else else
thickness = aSeg->GetWidth(); thickness = aSeg->GetWidth();
if( aSeg->GetBoard() ) // temporary created segments in plot functions return NULL
{
EDA_COLOR_T color = aSeg->GetBoard()->GetLayerColor( aSeg->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
}
wxPoint start( aSeg->GetStart() ); wxPoint start( aSeg->GetStart() );
wxPoint end( aSeg->GetEnd() ); wxPoint end( aSeg->GetEnd() );
...@@ -664,7 +701,7 @@ void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ...@@ -664,7 +701,7 @@ void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
void PlotBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int aLayer, void PlotBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int aLayer,
const PCB_PLOT_PARAMS& aPlotOpt ) const PCB_PLOT_PARAMS& aPlotOpt )
{ {
// Set the color and the text mode for this layer // Set a default color and the text mode for this layer
aPlotter->SetColor( aPlotOpt.GetColor() ); aPlotter->SetColor( aPlotOpt.GetColor() );
aPlotter->SetTextMode( aPlotOpt.GetTextMode() ); aPlotter->SetTextMode( aPlotOpt.GetTextMode() );
...@@ -779,22 +816,36 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, ...@@ -779,22 +816,36 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
break; break;
default: default:
DisplayError( NULL, wxT( "Plot_Standard_Layer() error : Unexpected Draw Type" ) ); wxLogMessage( wxT( "Plot_Standard_Layer() error : Unexpected Draw Type" ) );
break; break;
} }
} }
// Draw footprint shapes without pads (pads will plotted later) // Draw footprint shapes without pads (pads will plotted later)
// We plot here module texts, but they are usually on silkscreen layer,
// so they are not plot here but plot by PlotSilkScreen()
// Plot footprints fields (ref, value ...)
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{
if( ! PlotAllTextsModule( aPlotter, aBoard, aLayerMask, module, aPlotOpt ) )
{
wxLogMessage( _( "Your BOARD has a bad layer number for module %s" ),
GetChars( module->GetReference() ) );
}
}
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{ {
for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() )
{ {
if( ! (aLayerMask & GetLayerMask( item->GetLayer() ) ) )
continue;
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_MODULE_EDGE_T: case PCB_MODULE_EDGE_T:
if( aLayerMask & GetLayerMask( item->GetLayer() ) ) Plot_1_EdgeModule( aPlotter, aPlotOpt, (EDGE_MODULE*) item,
Plot_1_EdgeModule( aPlotter, aPlotOpt, (EDGE_MODULE*) item, aPlotMode, aLayerMask ); aPlotMode, aLayerMask );
break; break;
default: default:
...@@ -848,6 +899,18 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, ...@@ -848,6 +899,18 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
if( size.x <= 0 || size.y <= 0 ) if( size.x <= 0 || size.y <= 0 )
continue; continue;
EDA_COLOR_T color = ColorFromInt(0);
if( (pad->GetLayerMask() & LAYER_BACK) )
color = aBoard->GetVisibleElementColor( PAD_BK_VISIBLE );
if((pad->GetLayerMask() & LAYER_FRONT ) )
color = ColorFromInt( color | aBoard->GetVisibleElementColor( PAD_FR_VISIBLE ) );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
switch( pad->GetShape() ) switch( pad->GetShape() )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
...@@ -917,9 +980,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, ...@@ -917,9 +980,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
via_margin = aBoard->GetDesignSettings().m_SolderMaskMargin; via_margin = aBoard->GetDesignSettings().m_SolderMaskMargin;
if( aLayerMask & ALL_CU_LAYERS ) if( aLayerMask & ALL_CU_LAYERS )
{
width_adj = aPlotter->GetPlotWidthAdj(); width_adj = aPlotter->GetPlotWidthAdj();
}
pos = Via->m_Start; pos = Via->m_Start;
size.x = size.y = Via->m_Width + 2 * via_margin + width_adj; size.x = size.y = Via->m_Width + 2 * via_margin + width_adj;
...@@ -928,6 +989,11 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, ...@@ -928,6 +989,11 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
if( size.x <= 0 ) if( size.x <= 0 )
continue; continue;
EDA_COLOR_T color = aBoard->GetVisibleElementColor(VIAS_VISIBLE + Via->m_Shape);
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
aPlotter->FlashPadCircle( pos, size.x, aPlotMode ); aPlotter->FlashPadCircle( pos, size.x, aPlotMode );
} }
} }
...@@ -947,6 +1013,11 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, ...@@ -947,6 +1013,11 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
pos = track->m_Start; pos = track->m_Start;
end = track->m_End; end = track->m_End;
EDA_COLOR_T color = aBoard->GetLayerColor( track->GetLayer() );
// Set plot color (change WHITE to LIGHTGRAY because
// the white items are not seen on a white paper or screen
aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
aPlotter->ThickSegment( pos, end, size.x, aPlotMode ); aPlotter->ThickSegment( pos, end, size.x, aPlotMode );
} }
...@@ -1021,7 +1092,7 @@ void PlotDrillMarks( BOARD *aBoard, PLOTTER* aPlotter, ...@@ -1021,7 +1092,7 @@ void PlotDrillMarks( BOARD *aBoard, PLOTTER* aPlotter,
/* In the filled trace mode drill marks are drawn white-on-black to scrape /* In the filled trace mode drill marks are drawn white-on-black to scrape
the underlying pad. This works only for drivers supporting color change, the underlying pad. This works only for drivers supporting color change,
obviously... it means that: obviously... it means that:
- PS and PDF output is correct (i.e. you have a 'donut' pad) - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
- In HPGL you can't see them - In HPGL you can't see them
- In gerbers you can't see them, too. This is arguably the right thing to - In gerbers you can't see them, too. This is arguably the right thing to
do since having drill marks and high speed drill stations is a sure do since having drill marks and high speed drill stations is a sure
...@@ -1149,7 +1220,7 @@ static void PlotSetupPlotter( PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlotOpts, ...@@ -1149,7 +1220,7 @@ static void PlotSetupPlotter( PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlotOpts,
aPlotOpts->GetMirror() ); aPlotOpts->GetMirror() );
aPlotter->SetDefaultLineWidth( aPlotOpts->GetLineWidth() ); aPlotter->SetDefaultLineWidth( aPlotOpts->GetLineWidth() );
aPlotter->SetCreator( wxT( "PCBNEW" ) ); aPlotter->SetCreator( wxT( "PCBNEW" ) );
aPlotter->SetColorMode( true ); aPlotter->SetColorMode( false ); // default is plot in Black and White.
aPlotter->SetFilename( aFilename ); aPlotter->SetFilename( aFilename );
aPlotter->SetTextMode( aPlotOpts->GetTextMode() ); aPlotter->SetTextMode( aPlotOpts->GetTextMode() );
} }
...@@ -1158,7 +1229,7 @@ static void PlotSetupPlotter( PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlotOpts, ...@@ -1158,7 +1229,7 @@ static void PlotSetupPlotter( PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlotOpts,
* negative plot */ * negative plot */
static void FillNegativeKnockout(PLOTTER *aPlotter, const EDA_RECT &aBbbox ) static void FillNegativeKnockout(PLOTTER *aPlotter, const EDA_RECT &aBbbox )
{ {
static const int margin = 500; // Add a 0.5 inch margin around the board static const int margin = 5 * IU_PER_MM; // Add a 5 mm margin around the board
aPlotter->SetNegative( true ); aPlotter->SetNegative( true );
aPlotter->SetColor( WHITE ); // Which will be plotted as black aPlotter->SetColor( WHITE ); // Which will be plotted as black
aPlotter->Rect( wxPoint( aBbbox.GetX() - margin, aBbbox.GetY() - margin ), aPlotter->Rect( wxPoint( aBbbox.GetX() - margin, aBbbox.GetY() - margin ),
...@@ -1200,8 +1271,7 @@ static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, ...@@ -1200,8 +1271,7 @@ static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter,
* Return the plotter object if OK, NULL if the file is not created * Return the plotter object if OK, NULL if the file is not created
* (or has a problem) * (or has a problem)
*/ */
PLOTTER *StartPlotBoard( BOARD *aBoard, PLOTTER *StartPlotBoard( BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts,
PCB_PLOT_PARAMS *aPlotOpts,
const wxString& aFullFileName, const wxString& aFullFileName,
const wxString& aSheetDesc ) const wxString& aSheetDesc )
{ {
...@@ -1266,7 +1336,7 @@ PLOTTER *StartPlotBoard( BOARD *aBoard, ...@@ -1266,7 +1336,7 @@ PLOTTER *StartPlotBoard( BOARD *aBoard,
{ {
/* When plotting a negative board: draw a black rectangle /* When plotting a negative board: draw a black rectangle
* (background for plot board in white) and switch the current * (background for plot board in white) and switch the current
* color to WHITE; note the the color inversion is actually done * color to WHITE; note the color inversion is actually done
* in the driver (if supported) */ * in the driver (if supported) */
if( aPlotOpts->GetNegative() ) if( aPlotOpts->GetNegative() )
FillNegativeKnockout( the_plotter, bbbox ); FillNegativeKnockout( the_plotter, bbbox );
......
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