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
common_plotSVG_functions.cpp
confirm.cpp
copy_to_clipboard.cpp
dcsvg.cpp
dialog_shim.cpp
displlst.cpp
dlist.cpp
......
......@@ -152,54 +152,26 @@ void SVG_PLOTTER::setSVGPlotStyle()
switch( m_fillMode )
{
case NO_FILL:
fputs( "fill-opacity:0.0;\n", outputFile );
fputs( "fill-opacity:0.0; ", outputFile );
break;
case FILLED_SHAPE:
fputs( "fill-opacity:1.0;\n", outputFile );
fputs( "fill-opacity:1.0; ", outputFile );
break;
case FILLED_WITH_BG_BODYCOLOR:
fputs( "fill-opacity:0.6;\n", outputFile );
fputs( "fill-opacity:0.6; ", outputFile );
break;
}
// output the pen color (RVB values in hex) and opacity
double pen_opacity = 1.0; // 0.0 (transparent to 1.0 (solid)
fprintf( outputFile, " stroke:#%6.6lX; stroke-opacity:%g;\n",
m_pen_rgb_color, pen_opacity );
// 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 );
double pen_w = userToDeviceSize( GetCurrentLineWidth() );
fprintf( outputFile, "\nstroke:#%6.6lX; stroke-width:%g; stroke-opacity:1; \n",
m_pen_rgb_color, pen_w );
fputs( "stroke-linecap:round; stroke-linejoin:round;\">\n", outputFile );
m_graphics_changed = false;
}
/* Set the current line width (in IUs) for the next plot
*/
void SVG_PLOTTER::SetCurrentLineWidth( int width )
......@@ -487,10 +459,16 @@ bool SVG_PLOTTER::StartPlot( FILE* fout )
// End of header
fprintf( outputFile, " <desc>Picture generated by %s </desc>\n",
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;
}
......
......@@ -118,7 +118,9 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
if( DC->LogicalToDeviceXRel( width ) < 2 )
typeaff = LINE;
radius = m_Size / 4;
radius = m_Size / 3;
if( GetShape() ) // shape X
radius = m_Size / 2;
switch( typeaff )
{
......@@ -142,9 +144,9 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
dx2 = 0;
dy2 = radius;
if( m_Shape ) /* Form X */
if( GetShape() ) // shape X
{
dx1 = dy1 = ( radius * 7 ) / 5;
dx1 = dy1 = radius;
dx2 = dx1;
dy2 = -dy1;
}
......
......@@ -78,7 +78,6 @@ PAD_DRAWINFO::PAD_DRAWINFO()
void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
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
#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,
else
drawInfo.m_ShowPadFilled = false;
EDA_COLOR_T color = ColorFromInt(0); // XXX EVIL (it will be ORed later)
if( m_layerMask & LAYER_FRONT )
{
color = brd->GetVisibleElementColor( PAD_FR_VISIBLE );
......@@ -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 ) );
}
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
int mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS;
......
This diff is collapsed.
......@@ -18,6 +18,10 @@ private:
wxConfig* m_Config;
long m_PrintMaskLayer;
wxCheckBox* m_BoxSelectLayer[32];
bool m_printBW;
// Static member to store options
static bool m_printMirror;
static bool m_oneFileOnly;
public:
DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent );
......@@ -26,11 +30,10 @@ public:
private:
void OnCloseWindow( wxCloseEvent& event );
void initDialog( );
void OnButtonPrintSelectedClick( wxCommandEvent& event );
void OnButtonPrintBoardClick( wxCommandEvent& event );
void OnButtonPlot( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event );
void SetPenWidth();
void PrintSVGDoc( bool aPrintAll );
void ExportSVGFile( bool aOnlyOneFile );
bool PageIsBoardBoundarySize()
{
return m_rbSvgPageSizeOpt->GetSelection() == 2;
......@@ -39,7 +42,7 @@ private:
{
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
m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Default pen size"), wxDefaultPosition, wxDefaultSize, 0 );
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->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
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") );
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") };
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->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->SetValue(true);
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;
bButtonsSizer = new wxBoxSizer( wxVERTICAL );
m_buttonPrintSelected = new wxButton( this, wxID_PRINT_CURRENT, _("Print Selected"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonPrintSelected->SetDefault();
bButtonsSizer->Add( m_buttonPrintSelected, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
wxString m_rbFileOptChoices[] = { _("One file per layer"), _("All in one file") };
int m_rbFileOptNChoices = sizeof( m_rbFileOptChoices ) / sizeof( wxString );
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 );
bButtonsSizer->Add( m_buttonBoard, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonCreateFile = new wxButton( this, wxID_PRINT_BOARD, _("Plot"), wxDefaultPosition, wxDefaultSize, 0 );
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 );
bUpperSizer->Add( bButtonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
bUpperSizer->Add( bButtonsSizer, 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
// Connect Events
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_buttonBoard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this );
m_buttonCreateFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPlot ), 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()
{
// Disconnect Events
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_buttonBoard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this );
m_buttonCreateFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPlot ), NULL, this );
m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this );
}
This diff is collapsed.
......@@ -37,8 +37,7 @@ class DIALOG_SVG_PRINT_base : public wxDialog
protected:
enum
{
wxID_PRINT_CURRENT = 1000,
wxID_PRINT_BOARD
wxID_PRINT_BOARD = 1000
};
wxStaticBoxSizer* m_CopperLayersBoxSizer;
......@@ -48,8 +47,9 @@ class DIALOG_SVG_PRINT_base : public wxDialog
wxRadioBox* m_ModeColorOption;
wxRadioBox* m_rbSvgPageSizeOpt;
wxCheckBox* m_PrintBoardEdgesCtrl;
wxButton* m_buttonPrintSelected;
wxButton* m_buttonBoard;
wxCheckBox* m_printMirrorOpt;
wxRadioBox* m_rbFileOpt;
wxButton* m_buttonCreateFile;
wxButton* m_buttonQuit;
wxStaticText* m_staticText1;
wxTextCtrl* m_FileNameCtrl;
......@@ -58,14 +58,13 @@ class DIALOG_SVG_PRINT_base : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnButtonPrintSelectedClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonPrintBoardClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonPlot( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); }
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();
};
......
......@@ -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)") };
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->SetToolTip( _("Creates a drill map in PS, HPGL or other formats") );
......
......@@ -504,7 +504,7 @@
<property name="gripper">0</property>
<property name="hidden">0</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="max_size"></property>
<property name="maximize_button">0</property>
......
......@@ -216,8 +216,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// Create SVG file
AddMenuItem( filesMenu, ID_GEN_PLOT_SVG,
_( "Print SV&G" ),
_( "Plot board in Scalable Vector Graphics format" ),
_( "Export SV&G" ),
_( "Export a board file in Scalable Vector Graphics format" ),
KiBitmap( plot_svg_xpm ) );
// Plot
......
......@@ -37,6 +37,7 @@
#include <class_board.h>
#include <pcbnew.h>
#include <plotcontroller.h>
#include <pcb_plot_params.h>
#include <wx/ffile.h>
#include <dialog_plot.h>
......
This diff is collapsed.
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