From 3b423cb12dd3fd917efe5cdb18fb30774aed1a66 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 18 Jun 2013 19:27:47 +0200 Subject: [PATCH] Pcbnew fix Bug #1192203 (I hope ...) Bitmap2component: add export for .kicad_mod new footprint file format, and export polygon descr for page layout description (.kicad_wks file) --- bitmap2component/bitmap2cmp_gui.cpp | 146 +- bitmap2component/bitmap2cmp_gui_base.cpp | 55 +- bitmap2component/bitmap2cmp_gui_base.fbp | 2469 +++++++++++++--------- bitmap2component/bitmap2cmp_gui_base.h | 21 +- bitmap2component/bitmap2component.cpp | 151 +- pcbnew/class_zone.cpp | 5 +- 6 files changed, 1819 insertions(+), 1028 deletions(-) diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 9c7335e712..70bf62d408 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -46,6 +46,7 @@ #define KEYWORD_FRAME_SIZEY wxT( "Bmconverter_Size_y" ) #define KEYWORD_LAST_INPUT_FILE wxT( "Last_input" ) #define KEYWORD_LAST_OUTPUT_FILE wxT( "Last_output" ) +#define KEYWORD_LAST_FORMAT wxT( "Last_format" ) #define KEYWORD_BINARY_THRESHOLD wxT( "Threshold" ) #define KEYWORD_BW_NEGATIVE wxT( "Negative_choice" ) @@ -79,8 +80,32 @@ private: void OnPaint( wxPaintEvent& event ); void OnLoadFile( wxCommandEvent& event ); bool LoadFile( wxString& aFullFileName ); - void OnExportEeschema( wxCommandEvent& event ); - void OnExportPcbnew( wxCommandEvent& event ); + void OnExport( wxCommandEvent& event ); + + /** + * Generate a schematic library which comtains one component: + * the logo + */ + void OnExportEeschema(); + + /** + * Depending on the option: + * Legacy format: generate a module library which comtains one component + * New kicad_mod format: generate a module in S expr format + */ + void OnExportPcbnew( bool aLegacyFormat ); + + /** + * Generate a postscript file + */ + void OnExportPostScript(); + + /** + * Generate a file suitable to be copied into a page layout + * description file (.kicad_wks file + */ + void OnExportLogo(); + void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level) void OnOptionsSelection( wxCommandEvent& event ); void OnThresholdChange( wxScrollEvent& event ); @@ -104,6 +129,9 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL ) if( m_Config->Read( KEYWORD_BW_NEGATIVE, &tmp ) ) m_rbOptions->SetSelection( tmp ? 1 : 0 ); + m_Config->Read( KEYWORD_LAST_FORMAT, &tmp ); + m_radioBoxFormat->SetSelection( tmp ); + // Give an icon wxIcon icon; @@ -114,8 +142,7 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL ) SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - m_buttonExportEeschema->Enable( false ); - m_buttonExportPcbnew->Enable( false ); + m_buttonExport->Enable( false ); if ( m_FramePos == wxDefaultPosition ) Centre(); @@ -138,6 +165,7 @@ BM2CMP_FRAME::~BM2CMP_FRAME() m_Config->Write( KEYWORD_LAST_OUTPUT_FILE, m_ConvertedFileName ); m_Config->Write( KEYWORD_BINARY_THRESHOLD, m_sliderThreshold->GetValue() ); m_Config->Write( KEYWORD_BW_NEGATIVE, m_rbOptions->GetSelection() ); + m_Config->Write( KEYWORD_LAST_FORMAT, m_radioBoxFormat->GetSelection() ); delete m_Config; @@ -198,8 +226,7 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) if( ! LoadFile( fullFilename ) ) return; - m_buttonExportEeschema->Enable( true ); - m_buttonExportPcbnew->Enable( true ); + m_buttonExport->Enable( true ); SetStatusText( fullFilename ); Refresh(); } @@ -300,8 +327,103 @@ void BM2CMP_FRAME::OnThresholdChange( wxScrollEvent& event ) Refresh(); } +void BM2CMP_FRAME::OnExport( wxCommandEvent& event ) +{ + int sel = m_radioBoxFormat->GetSelection(); -void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event ) + switch( sel ) + { + case 0: + OnExportEeschema(); + break; + + case 1: + OnExportPcbnew( true ); + break; + + case 2: + OnExportPcbnew( false ); + break; + + case 3: + OnExportPostScript(); + break; + + case 4: + OnExportLogo(); + break; + } +} + +void BM2CMP_FRAME::OnExportLogo() +{ + wxFileName fn(m_ConvertedFileName); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists(path) ) + path = ::wxGetCwd(); + + wxString msg = _( "Logo file (*.kicad_wks)|*.kicad_wks" ); + wxFileDialog FileDlg( this, _( "Create a logo file" ), path, wxEmptyString, + msg, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + int diag = FileDlg.ShowModal(); + + if( diag != wxID_OK ) + return; + + m_ConvertedFileName = FileDlg.GetPath(); + + FILE* outfile; + outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); + + if( outfile == NULL ) + { + wxString msg; + msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() ); + wxMessageBox( msg ); + return; + } + + ExportFile( outfile, 4 ); + fclose( outfile ); +} + +void BM2CMP_FRAME::OnExportPostScript() +{ + wxFileName fn(m_ConvertedFileName); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists(path) ) + path = ::wxGetCwd(); + + wxString msg = _( "Postscript file (*.ps)|*.ps" ); + wxFileDialog FileDlg( this, _( "Create a Postscript file" ), path, wxEmptyString, + msg, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + int diag = FileDlg.ShowModal(); + + if( diag != wxID_OK ) + return; + + m_ConvertedFileName = FileDlg.GetPath(); + + FILE* outfile; + outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); + + if( outfile == NULL ) + { + wxString msg; + msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() ); + wxMessageBox( msg ); + return; + } + + ExportFile( outfile, 3 ); + fclose( outfile ); +} + +void BM2CMP_FRAME::OnExportEeschema() { wxFileName fn(m_ConvertedFileName); wxString path = fn.GetPath(); @@ -331,12 +453,12 @@ void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event ) return; } - ExportFile( outfile, 1 ); + ExportFile( outfile, 2 ); fclose( outfile ); } -void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) +void BM2CMP_FRAME::OnExportPcbnew( bool aLegacyFormat ) { wxFileName fn(m_ConvertedFileName); wxString path = fn.GetPath(); @@ -344,7 +466,9 @@ void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) if( path.IsEmpty() || !wxDirExists(path) ) path = ::wxGetCwd(); - wxString msg = _( "Footprint file (*.mod;*.emp)|*.mod;*.emp" ); + wxString msg = aLegacyFormat ? + _( "Footprint file (*.emp)|*.emp" ) : + _( "Footprint file (*.kicad_mod)|*.kicad_mod" ); wxFileDialog FileDlg( this, _( "Create a footprint file for PcbNew" ), path, wxEmptyString, msg, @@ -368,7 +492,7 @@ void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) return; } - ExportFile( outfile, 0 ); + ExportFile( outfile, aLegacyFormat ? 0 : 1 ); fclose( outfile ); } diff --git a/bitmap2component/bitmap2cmp_gui_base.cpp b/bitmap2component/bitmap2cmp_gui_base.cpp index 079a3ef482..92315a9545 100644 --- a/bitmap2component/bitmap2cmp_gui_base.cpp +++ b/bitmap2component/bitmap2cmp_gui_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -47,77 +47,82 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS m_staticTextSizeX = new wxStaticText( m_panelRight, wxID_ANY, _("Size X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSizeX->Wrap( -1 ); - fgSizerInfo->Add( m_staticTextSizeX, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_staticTextSizeX, 0, wxALIGN_RIGHT|wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_SizeXValue = new wxStaticText( m_panelRight, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeXValue->Wrap( -1 ); - fgSizerInfo->Add( m_SizeXValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_SizeXValue, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_SizeXunits = new wxStaticText( m_panelRight, wxID_ANY, _("pixels"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeXunits->Wrap( -1 ); - fgSizerInfo->Add( m_SizeXunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_SizeXunits, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_staticTextSizeY = new wxStaticText( m_panelRight, wxID_ANY, _("Size Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSizeY->Wrap( -1 ); - fgSizerInfo->Add( m_staticTextSizeY, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_staticTextSizeY, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_SizeYValue = new wxStaticText( m_panelRight, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeYValue->Wrap( -1 ); - fgSizerInfo->Add( m_SizeYValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_SizeYValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_SizeYunits = new wxStaticText( m_panelRight, wxID_ANY, _("pixels"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeYunits->Wrap( -1 ); - fgSizerInfo->Add( m_SizeYunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_SizeYunits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_staticTextBPP = new wxStaticText( m_panelRight, wxID_ANY, _("BPP:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextBPP->Wrap( -1 ); - fgSizerInfo->Add( m_staticTextBPP, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_staticTextBPP, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_BPPValue = new wxStaticText( m_panelRight, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 ); m_BPPValue->Wrap( -1 ); - fgSizerInfo->Add( m_BPPValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_BPPValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_BPPunits = new wxStaticText( m_panelRight, wxID_ANY, _("bits"), wxDefaultPosition, wxDefaultSize, 0 ); m_BPPunits->Wrap( -1 ); - fgSizerInfo->Add( m_BPPunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_BPPunits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + sbSizerInfo->Add( fgSizerInfo, 0, wxEXPAND|wxBOTTOM, 5 ); - brightSizer->Add( sbSizerInfo, 0, wxEXPAND|wxALL, 5 ); + + brightSizer->Add( sbSizerInfo, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_buttonLoad = new wxButton( m_panelRight, wxID_ANY, _("Load Bitmap"), wxDefaultPosition, wxDefaultSize, 0 ); - brightSizer->Add( m_buttonLoad, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + brightSizer->Add( m_buttonLoad, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_buttonExportEeschema = new wxButton( m_panelRight, wxID_ANY, _("Export to Eeschema"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonExportEeschema->SetToolTip( _("Create a library file for Eeschema\nThis library contains only one component: logo") ); + m_buttonExport = new wxButton( m_panelRight, wxID_ANY, _("Export"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonExport->SetToolTip( _("Create a library file for Eeschema\nThis library contains only one component: logo") ); - brightSizer->Add( m_buttonExportEeschema, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + brightSizer->Add( m_buttonExport, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_buttonExportPcbnew = new wxButton( m_panelRight, wxID_ANY, _("Export to Pcbnew"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonExportPcbnew->SetToolTip( _("Create a footprint file for PcbNew\nThis footprint contains only one footprint: logo") ); - - brightSizer->Add( m_buttonExportPcbnew, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + wxString m_radioBoxFormatChoices[] = { _("Eeschema"), _("Pcbnew old fmt (.emp)"), _("Pcbnew kicad_mod"), _("Postscript"), _("Logo for title block") }; + int m_radioBoxFormatNChoices = sizeof( m_radioBoxFormatChoices ) / sizeof( wxString ); + m_radioBoxFormat = new wxRadioBox( m_panelRight, wxID_ANY, _("Format"), wxDefaultPosition, wxDefaultSize, m_radioBoxFormatNChoices, m_radioBoxFormatChoices, 1, wxRA_SPECIFY_COLS ); + m_radioBoxFormat->SetSelection( 4 ); + brightSizer->Add( m_radioBoxFormat, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); wxString m_rbOptionsChoices[] = { _("Normal"), _("Negative") }; int m_rbOptionsNChoices = sizeof( m_rbOptionsChoices ) / sizeof( wxString ); m_rbOptions = new wxRadioBox( m_panelRight, wxID_ANY, _("Options"), wxDefaultPosition, wxDefaultSize, m_rbOptionsNChoices, m_rbOptionsChoices, 1, wxRA_SPECIFY_COLS ); m_rbOptions->SetSelection( 0 ); - brightSizer->Add( m_rbOptions, 0, wxALL|wxEXPAND, 5 ); + brightSizer->Add( m_rbOptions, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_ThresholdText = new wxStaticText( m_panelRight, wxID_ANY, _("Threshold Value:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ThresholdText->Wrap( -1 ); - brightSizer->Add( m_ThresholdText, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + brightSizer->Add( m_ThresholdText, 0, wxRIGHT|wxLEFT, 5 ); - m_sliderThreshold = new wxSlider( m_panelRight, wxID_ANY, 25, 0, 50, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_TOP ); + m_sliderThreshold = new wxSlider( m_panelRight, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS ); m_sliderThreshold->SetToolTip( _("Adjust the level to convert the greyscale picture to a black and white picture.") ); brightSizer->Add( m_sliderThreshold, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_panelRight->SetSizer( brightSizer ); m_panelRight->Layout(); brightSizer->Fit( m_panelRight ); bMainSizer->Add( m_panelRight, 0, wxEXPAND, 0 ); + this->SetSizer( bMainSizer ); this->Layout(); m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY ); @@ -127,8 +132,7 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS m_GreyscalePicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this ); m_BNPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this ); m_buttonLoad->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this ); - m_buttonExportEeschema->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportEeschema ), NULL, this ); - m_buttonExportPcbnew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportPcbnew ), NULL, this ); + m_buttonExport->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExport ), NULL, this ); m_rbOptions->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnOptionsSelection ), NULL, this ); m_sliderThreshold->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this ); } @@ -140,8 +144,7 @@ BM2CMP_FRAME_BASE::~BM2CMP_FRAME_BASE() m_GreyscalePicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this ); m_BNPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this ); m_buttonLoad->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this ); - m_buttonExportEeschema->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportEeschema ), NULL, this ); - m_buttonExportPcbnew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportPcbnew ), NULL, this ); + m_buttonExport->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExport ), NULL, this ); m_rbOptions->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnOptionsSelection ), NULL, this ); m_sliderThreshold->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this ); diff --git a/bitmap2component/bitmap2cmp_gui_base.fbp b/bitmap2component/bitmap2cmp_gui_base.fbp index d8f45dc4d0..d848aa0d8c 100644 --- a/bitmap2component/bitmap2cmp_gui_base.fbp +++ b/bitmap2component/bitmap2cmp_gui_base.fbp @@ -2,11 +2,13 @@ - + C++ 1 source_name + 0 0 + res UTF-8 connect bitmap2cmp_gui_base @@ -14,73 +16,78 @@ none 1 bitmap2cmp_gui - + . - + 1 + 1 1 0 0 - - - + 0 + wxAUI_MGR_DEFAULT + + + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + BM2CMP_FRAME_BASE - - 500,419 + + 527,470 wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER - + Bitmap to Component Converter - - - wxFILTER_NONE - wxDefaultValidator - - - + + + wxTAB_TRAVERSAL 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + bMainSizer wxHORIZONTAL none @@ -89,219 +96,327 @@ wxEXPAND 1 - - - + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - - + + 0 + + + 0 + + 1 m_notebook1 + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1 + + Resizable + 1 + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Original Picture 1 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY + + 0 -1,-1 + + 0 400,300 + 1 m_InitialPicturePanel + 1 + + protected - + 1 + + Resizable 5 5 - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + + 0 + + + wxHSCROLL|wxVSCROLL - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + OnPaint - - - - - - + + + + + + - + Greyscale Picture 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY + + 0 -1,-1 + + 0 400,300 + 1 m_GreyscalePicturePanel + 1 + + protected - + 1 + + Resizable 5 5 - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + + 0 + + + wxHSCROLL|wxVSCROLL - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + OnPaint - - - - - - + + + + + + - + Black&&White Picture 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - - + + 0 + + + 0 + + 1 m_BNPicturePanel + 1 + + protected - + 1 + + Resizable 5 5 - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + + 0 + + + wxHSCROLL|wxVSCROLL - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + OnPaint - - - - - - + + + + + + @@ -311,69 +426,96 @@ wxEXPAND 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - - + + 0 + + + 0 + + 1 m_panelRight + 1 + + protected - - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + Resizable + 1 + + + 0 + + + wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + brightSizer wxVERTICAL none 5 - wxEXPAND|wxALL + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 wxID_ANY Bitmap Info: - + sbSizerInfo wxVERTICAL none - + 5 wxEXPAND|wxBOTTOM @@ -381,10 +523,10 @@ 3 wxBOTH - - + + 0 - + fgSizerInfo wxFLEX_GROWMODE_SPECIFIED none @@ -392,506 +534,749 @@ 0 5 - wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT + wxALIGN_RIGHT|wxALL|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY Size X: - - + + 0 + + + 0 + + 1 m_staticTextSizeX + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxALL|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY 0000 - - + + 0 + + + 0 + + 1 m_SizeXValue + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxALL|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY pixels - - + + 0 + + + 0 + + 1 m_SizeXunits + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT + wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY Size Y: - - + + 0 + + + 0 + + 1 m_staticTextSizeY + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY 0000 - - + + 0 + + + 0 + + 1 m_SizeYValue + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY pixels - - + + 0 + + + 0 + + 1 m_SizeYunits + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT + wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY BPP: - - + + 0 + + + 0 + + 1 m_staticTextBPP + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY 0000 - - + + 0 + + + 0 + + 1 m_BPPValue + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY bits - - + + 0 + + + 0 + + 1 m_BPPunits + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -900,288 +1285,441 @@ 5 - wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL + wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 0 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY Load Bitmap - - + + 0 + + + 0 + + 1 m_buttonLoad + 1 + + protected - - - - - - + 1 + + Resizable + 1 + + + + 0 + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnLoadFile - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL + wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 0 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - Export to Eeschema - - - m_buttonExportEeschema + Export + + 0 + + + 0 + + 1 + m_buttonExport + 1 + + protected - - - - + 1 + + Resizable + 1 + + + + 0 Create a library file for Eeschema This library contains only one component: logo - + wxFILTER_NONE wxDefaultValidator - - - - - OnExportEeschema - - - - - - - - - - - - - - - - - - - - - - - + + + + + OnExport + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL - 0 - - - - 1 - 0 - 1 - - - 0 - wxID_ANY - Export to Pcbnew - - - m_buttonExportPcbnew - protected - - - - - Create a footprint file for PcbNew This footprint contains only one footprint: logo - - wxFILTER_NONE - wxDefaultValidator - - - - - OnExportPcbnew - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND + wxBOTTOM|wxRIGHT|wxLEFT 0 - - "Normal" "Negative" - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Eeschema" "Pcbnew old fmt (.emp)" "Pcbnew kicad_mod" "Postscript" "Logo for title block" + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 + 0 + wxID_ANY + Format + 1 + + 0 + + + 0 + + 1 + m_radioBoxFormat + 1 + + + protected + 1 + + Resizable + 4 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Normal" "Negative" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 0 wxID_ANY Options 1 - - + + 0 + + + 0 + + 1 m_rbOptions + 1 + + protected - + 1 + + Resizable 0 - + 1 + wxRA_SPECIFY_COLS - - - + + 0 + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + OnOptionsSelection - - - - - - + + + + + + 5 - wxTOP|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY Threshold Value: - - + + 0 + + + 0 + + 1 m_ThresholdText + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1189,76 +1727,107 @@ wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - 50 - + 100 + + 0 + 0 - + + 0 + + 1 m_sliderThreshold + 1 + + protected - - - wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_TOP - + 1 + + Resizable + 1 + + wxSL_HORIZONTAL|wxSL_LABELS + + 0 Adjust the level to convert the greyscale picture to a black and white picture. - + wxFILTER_NONE wxDefaultValidator - - 25 - - - - - - - - - - - - + + 50 + + + + + + + + + + + + OnThresholdChange - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1266,54 +1835,50 @@ - - + + 1 1 - + 1 - + 0 wxID_ANY - - + + m_statusBar protected - - + + wxST_SIZEGRIP - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bitmap2component/bitmap2cmp_gui_base.h b/bitmap2component/bitmap2cmp_gui_base.h index e826f55b8e..301a63398b 100644 --- a/bitmap2component/bitmap2cmp_gui_base.h +++ b/bitmap2component/bitmap2cmp_gui_base.h @@ -1,15 +1,16 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __bitmap2cmp_gui_base__ -#define __bitmap2cmp_gui_base__ +#ifndef __BITMAP2CMP_GUI_BASE_H__ +#define __BITMAP2CMP_GUI_BASE_H__ +#include +#include #include - #include #include #include @@ -56,8 +57,8 @@ class BM2CMP_FRAME_BASE : public wxFrame wxStaticText* m_BPPValue; wxStaticText* m_BPPunits; wxButton* m_buttonLoad; - wxButton* m_buttonExportEeschema; - wxButton* m_buttonExportPcbnew; + wxButton* m_buttonExport; + wxRadioBox* m_radioBoxFormat; wxRadioBox* m_rbOptions; wxStaticText* m_ThresholdText; wxSlider* m_sliderThreshold; @@ -66,17 +67,17 @@ class BM2CMP_FRAME_BASE : public wxFrame // Virtual event handlers, overide them in your derived class virtual void OnPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnLoadFile( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExportEeschema( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExportPcbnew( wxCommandEvent& event ) { event.Skip(); } + virtual void OnExport( wxCommandEvent& event ) { event.Skip(); } virtual void OnOptionsSelection( wxCommandEvent& event ) { event.Skip(); } virtual void OnThresholdChange( wxScrollEvent& event ) { event.Skip(); } public: - BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bitmap to Component Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,419 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); + BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bitmap to Component Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 527,470 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); + ~BM2CMP_FRAME_BASE(); }; -#endif //__bitmap2cmp_gui_base__ +#endif //__BITMAP2CMP_GUI_BASE_H__ diff --git a/bitmap2component/bitmap2component.cpp b/bitmap2component/bitmap2component.cpp index e2c2bacbbc..245cfc3447 100644 --- a/bitmap2component/bitmap2component.cpp +++ b/bitmap2component/bitmap2component.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 1992-2010 jean-pierre.charras - * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2013 jean-pierre.charras + * Copyright (C) 1992-2013 Kicad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,8 +22,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include +#include // std::max -// For some unknown reasons, polygon.hpp shoul be included first +// For some unknown reasons, polygon.hpp should be included first #include #include @@ -38,13 +39,6 @@ #include -#ifndef max - #define max( a, b ) ( ( (a) > (b) ) ? (a) : (b) ) -#endif -#ifndef min - #define min( a, b ) ( ( (a) < (b) ) ? (a) : (b) ) -#endif - // Define some types used here from boost::polygon namespace bpl = boost::polygon; // bpl = boost polygon library using namespace bpl::operators; // +, -, =, ... @@ -58,9 +52,12 @@ typedef bpl::point_data KPolyPoint; // define a corner o enum output_format { POSTSCRIPT_FMT = 1, - PCBNEW_FMT, - EESCHEMA_FMT + PCBNEW_LEGACY_EMP, + PCBNEW_KICAD_MOD, + EESCHEMA_FMT, + KICAD_LOGO }; + /* free a potrace bitmap */ static void bm_free( potrace_bitmap_t* bm ) { @@ -172,22 +169,37 @@ int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile, int aFo switch( aFormat ) { - case 2: + case 4: + info.m_Format = KICAD_LOGO; + info.m_ScaleX = 1e3 * 25.4 / 300; // the conversion scale from PPI to micro + info.m_ScaleY = info.m_ScaleX; // Y axis is top to bottom + info.CreateOutputFile(); + break; + + case 3: info.m_Format = POSTSCRIPT_FMT; - info.m_ScaleX = info.m_ScaleY = 1.0; // the conversion scale + info.m_ScaleX = 1.0; // the conversion scale + info.m_ScaleY = info.m_ScaleX; // output vector data, e.g. as a rudimentary EPS file (mainly for tests) info.CreateOutputFile(); break; - case 1: + case 2: info.m_Format = EESCHEMA_FMT; - info.m_ScaleX = 1000.0 / 300; // the conversion scale + info.m_ScaleX = 1000.0 / 300; // the conversion scale from PPI to UI info.m_ScaleY = -info.m_ScaleX; // Y axis is bottom to Top for components in libs info.CreateOutputFile(); break; + case 1: + info.m_Format = PCBNEW_KICAD_MOD; + info.m_ScaleX = 1e6 * 25.4 / 300; // the conversion scale from PPI to UI + info.m_ScaleY = info.m_ScaleX; // Y axis is top to bottom in modedit + info.CreateOutputFile(); + break; + case 0: - info.m_Format = PCBNEW_FMT; + info.m_Format = PCBNEW_LEGACY_EMP; info.m_ScaleX = 10000.0 / 300; // the conversion scale info.m_ScaleY = info.m_ScaleX; // Y axis is top to bottom in modedit info.CreateOutputFile(); @@ -221,7 +233,7 @@ void BITMAPCONV_INFO::OuputFileHeader() fprintf( m_Outfile, "gsave\n" ); break; - case PCBNEW_FMT: + case PCBNEW_LEGACY_EMP: #define FIELD_LAYER 21 fieldSize = 600; // fields text size = 60 mils Ypos += fieldSize / 2; @@ -240,6 +252,22 @@ void BITMAPCONV_INFO::OuputFileHeader() -Ypos, fieldSize, fieldSize, fieldSize / 5, FIELD_LAYER, m_CmpName ); break; + case PCBNEW_KICAD_MOD: + // fields text size = 1.5 mm + // fields text thickness = 1.5 / 5 = 0.3mm + fprintf( m_Outfile, "(module %s (layer F.Cu)\n (at 0 0)\n", + m_CmpName ); + fprintf( m_Outfile, " (fp_text reference \"G***\" (at 0 0) (layer F.SilkS) hide\n" + " (effects (font (thickness 0.3)))\n )\n" ); + fprintf( m_Outfile, " (fp_text value \"%s\" (at 0.75 0) (layer F.SilkS) hide\n" + " (effects (font (thickness 0.3)))\n )\n", + m_CmpName ); + break; + + case KICAD_LOGO: + fprintf( m_Outfile, "(polygon (pos 0 0 rbcorner) (rotate 0) (linewidth 0.01)\n" ); + break; + case EESCHEMA_FMT: fprintf( m_Outfile, "EESchema-LIBRARY Version 2.3\n" ); fprintf( m_Outfile, "#\n# %s\n", m_CmpName ); @@ -267,11 +295,19 @@ void BITMAPCONV_INFO::OuputFileEnd() fprintf( m_Outfile, "%%EOF\n" ); break; - case PCBNEW_FMT: + case PCBNEW_LEGACY_EMP: fprintf( m_Outfile, "$EndMODULE %s\n", m_CmpName ); fprintf( m_Outfile, "$EndLIBRARY\n" ); break; + case PCBNEW_KICAD_MOD: + fprintf( m_Outfile, ")\n" ); + break; + + case KICAD_LOGO: + fprintf( m_Outfile, ")\n" ); + break; + case EESCHEMA_FMT: fprintf( m_Outfile, "ENDDRAW\n" ); fprintf( m_Outfile, "ENDDEF\n" ); @@ -282,11 +318,11 @@ void BITMAPCONV_INFO::OuputFileEnd() /** * Function OuputOnePolygon * write one polygon to output file. - * Polygon coordinates are expected scaled by the polugon extraction function + * Polygon coordinates are expected scaled by the polygon extraction function */ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon ) { - unsigned ii; + unsigned ii, jj; KPolyPoint currpoint; int offsetX = (int)( m_PixmapWidth / 2 * m_ScaleX ); @@ -297,19 +333,27 @@ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon ) switch( m_Format ) { case POSTSCRIPT_FMT: - fprintf( m_Outfile, "%d %d moveto\n", - startpoint.x(), startpoint.y() ); + offsetY = (int)( m_PixmapHeight * m_ScaleY ); + fprintf( m_Outfile, "newpath\n%d %d moveto\n", + startpoint.x(), offsetY - startpoint.y() ); + jj = 0; for( ii = 1; ii < aPolygon.size(); ii++ ) { currpoint = *(aPolygon.begin() + ii); - fprintf( m_Outfile, "%d %d lineto\n", - currpoint.x(), currpoint.y() ); + fprintf( m_Outfile, " %d %d lineto", + currpoint.x(), offsetY - currpoint.y() ); + + if( jj++ > 6 ) + { + jj = 0; + fprintf( m_Outfile, ("\n") ); + } } - fprintf( m_Outfile, "0 setgray fill\n" ); + fprintf( m_Outfile, "\nclosepath fill\n" ); break; - case PCBNEW_FMT: + case PCBNEW_LEGACY_EMP: { LAYER_NUM layer = SILKSCREEN_N_FRONT; int width = 1; @@ -330,6 +374,54 @@ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon ) } break; + case PCBNEW_KICAD_MOD: + { + double width = 0.1; + fprintf( m_Outfile, " (fp_poly (pts" ); + + jj = 0; + for( ii = 0; ii < aPolygon.size(); ii++ ) + { + currpoint = *( aPolygon.begin() + ii ); + fprintf( m_Outfile, " (xy %f %f)", + (currpoint.x() - offsetX) / 1e6, + (currpoint.y() - offsetY) / 1e6 ); + + if( jj++ > 6 ) + { + jj = 0; + fprintf( m_Outfile, ("\n ") ); + } + } + // Close polygon + fprintf( m_Outfile, " (xy %f %f) )", + (startpoint.x() - offsetX) / 1e6, (startpoint.y() - offsetY) / 1e6 ); + fprintf( m_Outfile, "(layer F.SilkS) (width %f)\n )\n", width ); + } + break; + + case KICAD_LOGO: + fprintf( m_Outfile, " (pts" ); + // Internal units = micron, file unit = mm + jj = 0; + for( ii = 0; ii < aPolygon.size(); ii++ ) + { + currpoint = *( aPolygon.begin() + ii ); + fprintf( m_Outfile, " (xy %.3f %.3f)", + (currpoint.x() - offsetX) / 1e3, + (currpoint.y() - offsetY) / 1e3 ); + + if( jj++ > 4 ) + { + jj = 0; + fprintf( m_Outfile, ("\n ") ); + } + } + // Close polygon + fprintf( m_Outfile, " (xy %.3f %.3f) )\n", + (startpoint.x() - offsetX) / 1e3, (startpoint.y() - offsetY) / 1e3 ); + break; + case EESCHEMA_FMT: fprintf( m_Outfile, "P %d 0 0 1", (int) aPolygon.size() + 1 ); for( ii = 0; ii < aPolygon.size(); ii++ ) @@ -363,6 +455,9 @@ void BITMAPCONV_INFO::CreateOutputFile() KPolygonSet polyset_holes; potrace_dpoint_t( *c )[3]; + + setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C + OuputFileHeader(); bool main_outline = true; @@ -451,6 +546,8 @@ void BITMAPCONV_INFO::CreateOutputFile() } OuputFileEnd(); + + setlocale( LC_NUMERIC, "" ); // revert to the current locale } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 4618255a91..085d7e9b61 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -954,8 +954,9 @@ wxString ZONE_CONTAINER::GetSelectMenuText() const } } - text.Printf( _( "Zone Outline %s on %s" ), GetChars( text ), + wxString msg; + msg.Printf( _( "Zone Outline %s on %s" ), GetChars( text ), GetChars( GetLayerName() ) ); - return text; + return msg; }