diff --git a/bitmap2component/bitmap2cmp_frame.cpp b/bitmap2component/bitmap2cmp_frame.cpp index 8899146d67..59f6cfcf31 100644 --- a/bitmap2component/bitmap2cmp_frame.cpp +++ b/bitmap2component/bitmap2cmp_frame.cpp @@ -30,14 +30,13 @@ #include #include #include -#include -#include #include #include #include #include #include #include +#include #include #include @@ -333,8 +332,8 @@ void BITMAP2CMP_FRAME::ShowChangedLanguage() mainSizer->Add( m_panel, 1, wxEXPAND, 5 ); Layout(); - if( !m_bitmapFileName.IsEmpty() ) - OpenProjectFiles( std::vector( 1, m_bitmapFileName ) ); + if( !m_srcFileName.IsEmpty() ) + OpenProjectFiles( std::vector( 1, m_srcFileName ) ); LoadSettings( config() ); m_panel->SetOutputSize( imageSizeX, imageSizeY ); @@ -348,9 +347,9 @@ void BITMAP2CMP_FRAME::UpdateTitle() { wxString title; - if( !m_bitmapFileName.IsEmpty() ) + if( !m_srcFileName.IsEmpty() ) { - wxFileName filename( m_bitmapFileName ); + wxFileName filename( m_srcFileName ); title = filename.GetFullName() + wxT( " \u2014 " ); } @@ -364,12 +363,10 @@ void BITMAP2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_BASE_FRAME::LoadSettings( aCfg ); - BITMAP2CMP_SETTINGS* cfg = dynamic_cast( aCfg ); - - if( cfg ) + if( BITMAP2CMP_SETTINGS* cfg = dynamic_cast( aCfg ) ) { - m_bitmapFileName = cfg->m_BitmapFileName; - m_convertedFileName = cfg->m_ConvertedFileName; + m_srcFileName = cfg->m_BitmapFileName; + m_outFileName = cfg->m_ConvertedFileName; m_panel->LoadSettings( cfg ); } } @@ -379,12 +376,10 @@ void BITMAP2CMP_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { EDA_BASE_FRAME::SaveSettings( aCfg ); - BITMAP2CMP_SETTINGS* cfg = dynamic_cast( aCfg ); - - if( cfg ) + if( BITMAP2CMP_SETTINGS* cfg = dynamic_cast( aCfg ) ) { - cfg->m_BitmapFileName = m_bitmapFileName; - cfg->m_ConvertedFileName = m_convertedFileName; + cfg->m_BitmapFileName = m_srcFileName; + cfg->m_ConvertedFileName = m_outFileName; m_panel->SaveSettings( cfg ); } } @@ -392,7 +387,7 @@ void BITMAP2CMP_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) void BITMAP2CMP_FRAME::OnLoadFile() { - wxFileName fn( m_bitmapFileName ); + wxFileName fn( m_srcFileName ); wxString path = fn.GetPath(); if( path.IsEmpty() || !wxDirExists( path ) ) @@ -402,9 +397,7 @@ void BITMAP2CMP_FRAME::OnLoadFile() _( "Image Files" ) + wxS( " " )+ wxImage::GetImageExtWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - int diag = fileDlg.ShowModal(); - - if( diag != wxID_OK ) + if( fileDlg.ShowModal() != wxID_OK ) return; wxString fullFilename = fileDlg.GetPath(); @@ -422,11 +415,11 @@ void BITMAP2CMP_FRAME::OnLoadFile() bool BITMAP2CMP_FRAME::OpenProjectFiles( const std::vector& aFileSet, int aCtl ) { - m_bitmapFileName = aFileSet[0]; + m_srcFileName = aFileSet[0]; if( m_panel->OpenProjectFiles( aFileSet, aCtl ) ) { - UpdateFileHistory( m_bitmapFileName ); + UpdateFileHistory( m_srcFileName ); return true; } @@ -436,7 +429,7 @@ bool BITMAP2CMP_FRAME::OpenProjectFiles( const std::vector& aFileSet, void BITMAP2CMP_FRAME::ExportDrawingSheetFormat() { - wxFileName fn( m_convertedFileName ); + wxFileName fn( m_outFileName ); wxString path = fn.GetPath(); if( path.IsEmpty() || !wxDirExists(path) ) @@ -444,28 +437,24 @@ void BITMAP2CMP_FRAME::ExportDrawingSheetFormat() wxFileDialog fileDlg( this, _( "Create Drawing Sheet File" ), path, wxEmptyString, FILEEXT::DrawingSheetFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - int diag = fileDlg.ShowModal(); - if( diag != wxID_OK ) + if( fileDlg.ShowModal() != wxID_OK ) return; fn = fileDlg.GetPath(); fn.SetExt( FILEEXT::DrawingSheetFileExtension ); - m_convertedFileName = fn.GetFullPath(); + m_outFileName = fn.GetFullPath(); - FILE* outfile; - outfile = wxFopen( m_convertedFileName, wxT( "w" ) ); + FILE* outfile = wxFopen( m_outFileName, wxT( "w" ) ); - if( outfile == nullptr ) + if( !outfile ) { - wxString msg; - msg.Printf( _( "File '%s' could not be created." ), m_convertedFileName ); - wxMessageBox( msg ); + wxMessageBox( wxString::Format( _( "File '%s' could not be created." ), m_outFileName ) ); return; } std::string buffer; - m_panel->ExportToBuffer( buffer, KICAD_WKS_LOGO ); + m_panel->ExportToBuffer( buffer, DRAWING_SHEET_FMT ); fputs( buffer.c_str(), outfile ); fclose( outfile ); } @@ -473,7 +462,7 @@ void BITMAP2CMP_FRAME::ExportDrawingSheetFormat() void BITMAP2CMP_FRAME::ExportPostScriptFormat() { - wxFileName fn( m_convertedFileName ); + wxFileName fn( m_outFileName ); wxString path = fn.GetPath(); if( path.IsEmpty() || !wxDirExists( path ) ) @@ -487,16 +476,13 @@ void BITMAP2CMP_FRAME::ExportPostScriptFormat() fn = fileDlg.GetPath(); fn.SetExt( wxT( "ps" ) ); - m_convertedFileName = fn.GetFullPath(); + m_outFileName = fn.GetFullPath(); - FILE* outfile; - outfile = wxFopen( m_convertedFileName, wxT( "w" ) ); + FILE* outfile = wxFopen( m_outFileName, wxT( "w" ) ); - if( outfile == nullptr ) + if( !outfile ) { - wxString msg; - msg.Printf( _( "File '%s' could not be created." ), m_convertedFileName ); - wxMessageBox( msg ); + wxMessageBox( wxString::Format( _( "File '%s' could not be created." ), m_outFileName ) ); return; } @@ -509,10 +495,10 @@ void BITMAP2CMP_FRAME::ExportPostScriptFormat() void BITMAP2CMP_FRAME::ExportEeschemaFormat() { - wxFileName fn( m_convertedFileName ); + wxFileName fn( m_outFileName ); wxString path = fn.GetPath(); - if( path.IsEmpty() || !wxDirExists(path) ) + if( path.IsEmpty() || !wxDirExists( path ) ) path = ::wxGetCwd(); wxFileDialog fileDlg( this, _( "Create Symbol Library" ), path, wxEmptyString, @@ -523,20 +509,18 @@ void BITMAP2CMP_FRAME::ExportEeschemaFormat() return; fn = EnsureFileExtension( fileDlg.GetPath(), FILEEXT::KiCadSymbolLibFileExtension ); - m_convertedFileName = fn.GetFullPath(); + m_outFileName = fn.GetFullPath(); - FILE* outfile = wxFopen( m_convertedFileName, wxT( "w" ) ); + FILE* outfile = wxFopen( m_outFileName, wxT( "w" ) ); - if( outfile == nullptr ) + if( !outfile ) { - wxString msg; - msg.Printf( _( "File '%s' could not be created." ), m_convertedFileName ); - wxMessageBox( msg ); + wxMessageBox( wxString::Format( _( "File '%s' could not be created." ), m_outFileName ) ); return; } std::string buffer; - m_panel->ExportToBuffer( buffer, EESCHEMA_FMT ); + m_panel->ExportToBuffer( buffer, SYMBOL_FMT ); fputs( buffer.c_str(), outfile ); fclose( outfile ); } @@ -544,7 +528,7 @@ void BITMAP2CMP_FRAME::ExportEeschemaFormat() void BITMAP2CMP_FRAME::ExportPcbnewFormat() { - wxFileName fn( m_convertedFileName ); + wxFileName fn( m_outFileName ); wxString path = fn.GetPath(); if( path.IsEmpty() || !wxDirExists( path ) ) @@ -558,20 +542,18 @@ void BITMAP2CMP_FRAME::ExportPcbnewFormat() return; fn = EnsureFileExtension( fileDlg.GetPath(), FILEEXT::KiCadFootprintFileExtension ); - m_convertedFileName = fn.GetFullPath(); + m_outFileName = fn.GetFullPath(); - FILE* outfile = wxFopen( m_convertedFileName, wxT( "w" ) ); + FILE* outfile = wxFopen( m_outFileName, wxT( "w" ) ); - if( outfile == nullptr ) + if( !outfile ) { - wxString msg; - msg.Printf( _( "File '%s' could not be created." ), m_convertedFileName ); - wxMessageBox( msg ); + wxMessageBox( wxString::Format( _( "File '%s' could not be created." ), m_outFileName ) ); return; } std::string buffer; - m_panel->ExportToBuffer( buffer, PCBNEW_KICAD_MOD ); + m_panel->ExportToBuffer( buffer, FOOTPRINT_FMT ); fputs( buffer.c_str(), outfile ); fclose( outfile ); m_mruPath = fn.GetPath(); diff --git a/bitmap2component/bitmap2cmp_frame.h b/bitmap2component/bitmap2cmp_frame.h index 8a43045ecd..ef66cca560 100644 --- a/bitmap2component/bitmap2cmp_frame.h +++ b/bitmap2component/bitmap2cmp_frame.h @@ -88,8 +88,8 @@ private: BITMAP2CMP_PANEL* m_panel; wxStatusBar* m_statusBar; - wxString m_bitmapFileName; - wxString m_convertedFileName; + wxString m_srcFileName; + wxString m_outFileName; }; #endif// BITMOP2CMP_GUI_H_ diff --git a/bitmap2component/bitmap2cmp_panel.cpp b/bitmap2component/bitmap2cmp_panel.cpp index 3961ee6c27..313b9c9f5d 100644 --- a/bitmap2component/bitmap2cmp_panel.cpp +++ b/bitmap2component/bitmap2cmp_panel.cpp @@ -27,11 +27,8 @@ #include #include #include -#include #include -#include #include // for KiROUND -#include #include #include #include @@ -44,10 +41,11 @@ BITMAP2CMP_PANEL::BITMAP2CMP_PANEL( BITMAP2CMP_FRAME* aParent ) : BITMAP2CMP_PANEL_BASE( aParent ), - m_parentFrame( aParent ), m_negative( false ), + m_parentFrame( aParent ), + m_negative( false ), m_aspectRatio( 1.0 ) { - for( wxString unit : { _( "mm" ), _( "Inch" ), _( "DPI" ) } ) + for( const wxString& unit : { _( "mm" ), _( "Inch" ), _( "DPI" ) } ) m_PixelUnit->Append( unit ); m_outputSizeX.SetUnit( getUnitFromSelection() ); @@ -55,19 +53,14 @@ BITMAP2CMP_PANEL::BITMAP2CMP_PANEL( BITMAP2CMP_FRAME* aParent ) : m_outputSizeX.SetOutputSize( 0, getUnitFromSelection() ); m_outputSizeY.SetOutputSize( 0, getUnitFromSelection() ); - m_UnitSizeX->ChangeValue( FormatOutputSize( m_outputSizeX.GetOutputSize() ) ); - m_UnitSizeY->ChangeValue( FormatOutputSize( m_outputSizeY.GetOutputSize() ) ); + m_UnitSizeX->ChangeValue( formatOutputSize( m_outputSizeX.GetOutputSize() ) ); + m_UnitSizeY->ChangeValue( formatOutputSize( m_outputSizeY.GetOutputSize() ) ); m_buttonExportFile->Enable( false ); m_buttonExportClipboard->Enable( false ); } -BITMAP2CMP_PANEL::~BITMAP2CMP_PANEL() -{ -} - - wxWindow* BITMAP2CMP_PANEL::GetCurrentPage() { return m_Notebook->GetCurrentPage(); @@ -76,12 +69,8 @@ wxWindow* BITMAP2CMP_PANEL::GetCurrentPage() void BITMAP2CMP_PANEL::LoadSettings( BITMAP2CMP_SETTINGS* cfg ) { - int u_select = cfg->m_Units; - - if( u_select < 0 || u_select > 2 ) // Validity control - u_select = 0; - - m_PixelUnit->SetSelection( u_select ); + if( cfg->m_Units >= 0 && cfg->m_Units < (int) m_PixelUnit->GetCount() ) + m_PixelUnit->SetSelection( cfg->m_Units ); m_sliderThreshold->SetValue( cfg->m_Threshold ); @@ -91,32 +80,30 @@ void BITMAP2CMP_PANEL::LoadSettings( BITMAP2CMP_SETTINGS* cfg ) m_aspectRatio = 1.0; m_aspectRatioCheckbox->SetValue( true ); - int format = cfg->m_LastFormat; + switch( cfg->m_LastFormat ) + { + default: + case FOOTPRINT_FMT: m_rbFootprint->SetValue( true ); break; + case SYMBOL_FMT: m_rbSymbol->SetValue( true ); break; + case POSTSCRIPT_FMT: m_rbPostscript->SetValue( true ); break; + case DRAWING_SHEET_FMT: m_rbWorksheet->SetValue( true ); break; + } - if( format < 0 || format > FINAL_FMT ) - format = PCBNEW_KICAD_MOD; + m_layerLabel->Enable( cfg->m_LastFormat == FOOTPRINT_FMT ); + m_layerCtrl->Enable( cfg->m_LastFormat == FOOTPRINT_FMT ); - m_rbOutputFormat->SetSelection( format ); - - bool enable = format == PCBNEW_KICAD_MOD; - m_chPCBLayer->Enable( enable ); - - int last_layer = cfg->m_LastModLayer; - - if( last_layer < 0 || last_layer > static_cast( MOD_LYR_FINAL ) ) // Out of range - last_layer = MOD_LYR_FSILKS; - - m_chPCBLayer->SetSelection( last_layer ); + if( cfg->m_LastLayer >= 0 && cfg->m_LastLayer < (int) m_layerCtrl->GetCount() ) + m_layerCtrl->SetSelection( cfg->m_LastLayer ); } void BITMAP2CMP_PANEL::SaveSettings( BITMAP2CMP_SETTINGS* cfg ) { - cfg->m_Threshold = m_sliderThreshold->GetValue(); - cfg->m_Negative = m_checkNegative->IsChecked(); - cfg->m_LastFormat = m_rbOutputFormat->GetSelection(); - cfg->m_LastModLayer = m_chPCBLayer->GetSelection(); - cfg->m_Units = m_PixelUnit->GetSelection(); + cfg->m_Threshold = m_sliderThreshold->GetValue(); + cfg->m_Negative = m_checkNegative->IsChecked(); + cfg->m_LastFormat = getOutputFormat(); + cfg->m_LastLayer = m_layerCtrl->GetSelection(); + cfg->m_Units = m_PixelUnit->GetSelection(); } @@ -244,9 +231,9 @@ bool BITMAP2CMP_PANEL::OpenProjectFiles( const std::vector& aFileSet, { for( int y = 0; y < m_Pict_Bitmap.GetHeight(); y++ ) { - if( m_Pict_Image.GetRed( x, y ) == m_Pict_Image.GetMaskRed() && - m_Pict_Image.GetGreen( x, y ) == m_Pict_Image.GetMaskGreen() && - m_Pict_Image.GetBlue( x, y ) == m_Pict_Image.GetMaskBlue() ) + if( m_Pict_Image.GetRed( x, y ) == m_Pict_Image.GetMaskRed() + && m_Pict_Image.GetGreen( x, y ) == m_Pict_Image.GetMaskGreen() + && m_Pict_Image.GetBlue( x, y ) == m_Pict_Image.GetMaskBlue() ) { m_Greyscale_Image.SetRGB( x, y, 255, 255, 255 ); } @@ -255,26 +242,26 @@ bool BITMAP2CMP_PANEL::OpenProjectFiles( const std::vector& aFileSet, } if( m_negative ) - NegateGreyscaleImage( ); + negateGreyscaleImage(); m_Greyscale_Bitmap = wxBitmap( m_Greyscale_Image ); m_NB_Image = m_Greyscale_Image; - Binarize( (double) m_sliderThreshold->GetValue() / m_sliderThreshold->GetMax() ); + binarize( (double)m_sliderThreshold->GetValue() / m_sliderThreshold->GetMax() ); m_buttonExportFile->Enable( true ); m_buttonExportClipboard->Enable( true ); m_outputSizeX.SetOutputSizeFromInitialImageSize(); - m_UnitSizeX->ChangeValue( FormatOutputSize( m_outputSizeX.GetOutputSize() ) ); + m_UnitSizeX->ChangeValue( formatOutputSize( m_outputSizeX.GetOutputSize() ) ); m_outputSizeY.SetOutputSizeFromInitialImageSize(); - m_UnitSizeY->ChangeValue( FormatOutputSize( m_outputSizeY.GetOutputSize() ) ); + m_UnitSizeY->ChangeValue( formatOutputSize( m_outputSizeY.GetOutputSize() ) ); return true; } // return a string giving the output size, according to the selected unit -wxString BITMAP2CMP_PANEL::FormatOutputSize( double aSize ) +wxString BITMAP2CMP_PANEL::formatOutputSize( double aSize ) { wxString text; @@ -295,13 +282,9 @@ void BITMAP2CMP_PANEL::updateImageInfo() if( m_Pict_Bitmap.IsOk() ) { - int h = m_Pict_Bitmap.GetHeight(); - int w = m_Pict_Bitmap.GetWidth(); - int nb = m_Pict_Bitmap.GetDepth(); - - m_SizeXValue->SetLabel( wxString::Format( wxT( "%d" ), w ) ); - m_SizeYValue->SetLabel( wxString::Format( wxT( "%d" ), h ) ); - m_BPPValue->SetLabel( wxString::Format( wxT( "%d" ), nb ) ); + m_SizeXValue->SetLabel( wxString::Format( wxT( "%d" ), m_Pict_Bitmap.GetWidth() ) ); + m_SizeYValue->SetLabel( wxString::Format( wxT( "%d" ), m_Pict_Bitmap.GetHeight() ) ); + m_BPPValue->SetLabel( wxString::Format( wxT( "%d" ), m_Pict_Bitmap.GetDepth() ) ); } } @@ -338,7 +321,7 @@ void BITMAP2CMP_PANEL::OnSizeChangeX( wxCommandEvent& event ) } m_outputSizeY.SetOutputSize( calculatedY, getUnitFromSelection() ); - m_UnitSizeY->ChangeValue( FormatOutputSize( m_outputSizeY.GetOutputSize() ) ); + m_UnitSizeY->ChangeValue( formatOutputSize( m_outputSizeY.GetOutputSize() ) ); } m_outputSizeX.SetOutputSize( new_size, getUnitFromSelection() ); @@ -367,7 +350,7 @@ void BITMAP2CMP_PANEL::OnSizeChangeY( wxCommandEvent& event ) } m_outputSizeX.SetOutputSize( calculatedX, getUnitFromSelection() ); - m_UnitSizeX->ChangeValue( FormatOutputSize( m_outputSizeX.GetOutputSize() ) ); + m_UnitSizeX->ChangeValue( formatOutputSize( m_outputSizeX.GetOutputSize() ) ); } m_outputSizeY.SetOutputSize( new_size, getUnitFromSelection() ); @@ -383,8 +366,8 @@ void BITMAP2CMP_PANEL::OnSizeUnitChange( wxCommandEvent& event ) m_outputSizeY.SetUnit( getUnitFromSelection() ); updateImageInfo(); - m_UnitSizeX->ChangeValue( FormatOutputSize( m_outputSizeX.GetOutputSize() ) ); - m_UnitSizeY->ChangeValue( FormatOutputSize( m_outputSizeY.GetOutputSize() ) ); + m_UnitSizeX->ChangeValue( formatOutputSize( m_outputSizeX.GetOutputSize() ) ); + m_UnitSizeY->ChangeValue( formatOutputSize( m_outputSizeY.GetOutputSize() ) ); } @@ -394,8 +377,8 @@ void BITMAP2CMP_PANEL::SetOutputSize( const IMAGE_SIZE& aSizeX, const IMAGE_SIZE m_outputSizeY = aSizeY; updateImageInfo(); - m_UnitSizeX->ChangeValue( FormatOutputSize( m_outputSizeX.GetOutputSize() ) ); - m_UnitSizeY->ChangeValue( FormatOutputSize( m_outputSizeY.GetOutputSize() ) ); + m_UnitSizeX->ChangeValue( formatOutputSize( m_outputSizeX.GetOutputSize() ) ); + m_UnitSizeY->ChangeValue( formatOutputSize( m_outputSizeY.GetOutputSize() ) ); } @@ -410,28 +393,25 @@ void BITMAP2CMP_PANEL::ToggleAspectRatioLock( wxCommandEvent& event ) } -void BITMAP2CMP_PANEL::Binarize( double aThreshold ) +void BITMAP2CMP_PANEL::binarize( double aThreshold ) { - int h = m_Greyscale_Image.GetHeight(); - int w = m_Greyscale_Image.GetWidth(); unsigned char threshold = aThreshold * 255; unsigned char alpha_thresh = 0.7 * threshold; - for( int y = 0; y < h; y++ ) + for( int y = 0; y < m_Greyscale_Image.GetHeight(); y++ ) { - for( int x = 0; x < w; x++ ) + for( int x = 0; x < m_Greyscale_Image.GetWidth(); x++ ) { - unsigned char pixout; - unsigned char pixin = m_Greyscale_Image.GetGreen( x, y ); + unsigned char pixel = m_Greyscale_Image.GetGreen( x, y ); unsigned char alpha = m_Greyscale_Image.HasAlpha() ? m_Greyscale_Image.GetAlpha( x, y ) : wxALPHA_OPAQUE; - if( pixin < threshold && alpha > alpha_thresh ) - pixout = 0; + if( pixel < threshold && alpha > alpha_thresh ) + pixel = 0; else - pixout = 255; + pixel = 255; - m_NB_Image.SetRGB( x, y, pixout, pixout, pixout ); + m_NB_Image.SetRGB( x, y, pixel, pixel, pixel ); } } @@ -439,19 +419,15 @@ void BITMAP2CMP_PANEL::Binarize( double aThreshold ) } -void BITMAP2CMP_PANEL::NegateGreyscaleImage( ) +void BITMAP2CMP_PANEL::negateGreyscaleImage( ) { - unsigned char pix; - int h = m_Greyscale_Image.GetHeight(); - int w = m_Greyscale_Image.GetWidth(); - - for( int y = 0; y < h; y++ ) + for( int y = 0; y < m_Greyscale_Image.GetHeight(); y++ ) { - for( int x = 0; x < w; x++ ) + for( int x = 0; x < m_Greyscale_Image.GetWidth(); x++ ) { - pix = m_Greyscale_Image.GetGreen( x, y ); - pix = ~pix; - m_Greyscale_Image.SetRGB( x, y, pix, pix, pix ); + unsigned char pixel = m_Greyscale_Image.GetGreen( x, y ); + pixel = ~pixel; + m_Greyscale_Image.SetRGB( x, y, pixel, pixel, pixel ); } } } @@ -461,10 +437,10 @@ void BITMAP2CMP_PANEL::OnNegativeClicked( wxCommandEvent& ) { if( m_checkNegative->GetValue() != m_negative ) { - NegateGreyscaleImage(); + negateGreyscaleImage(); m_Greyscale_Bitmap = wxBitmap( m_Greyscale_Image ); - Binarize( (double)m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() ); + binarize( (double)m_sliderThreshold->GetValue() / m_sliderThreshold->GetMax() ); m_negative = m_checkNegative->GetValue(); Refresh(); @@ -474,28 +450,40 @@ void BITMAP2CMP_PANEL::OnNegativeClicked( wxCommandEvent& ) void BITMAP2CMP_PANEL::OnThresholdChange( wxScrollEvent& event ) { - Binarize( (double)m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() ); + binarize( (double)m_sliderThreshold->GetValue() / m_sliderThreshold->GetMax() ); Refresh(); } void BITMAP2CMP_PANEL::OnExportToFile( wxCommandEvent& event ) { - // choices of m_rbOutputFormat are expected to be in same order as - // OUTPUT_FMT_ID. See bitmap2component.h - OUTPUT_FMT_ID format = (OUTPUT_FMT_ID) m_rbOutputFormat->GetSelection(); - exportBitmap( format ); + switch( getOutputFormat() ) + { + case SYMBOL_FMT: m_parentFrame->ExportEeschemaFormat(); break; + case FOOTPRINT_FMT: m_parentFrame->ExportPcbnewFormat(); break; + case POSTSCRIPT_FMT: m_parentFrame->ExportPostScriptFormat(); break; + case DRAWING_SHEET_FMT: m_parentFrame->ExportDrawingSheetFormat(); break; + } +} + + +OUTPUT_FMT_ID BITMAP2CMP_PANEL::getOutputFormat() +{ + if( m_rbSymbol->GetValue() ) + return SYMBOL_FMT; + else if( m_rbPostscript->GetValue() ) + return POSTSCRIPT_FMT; + else if( m_rbWorksheet->GetValue() ) + return DRAWING_SHEET_FMT; + else + return FOOTPRINT_FMT; } void BITMAP2CMP_PANEL::OnExportToClipboard( wxCommandEvent& event ) { - // choices of m_rbOutputFormat are expected to be in same order as - // OUTPUT_FMT_ID. See bitmap2component.h - OUTPUT_FMT_ID format = (OUTPUT_FMT_ID) m_rbOutputFormat->GetSelection(); - std::string buffer; - ExportToBuffer( buffer, format ); + ExportToBuffer( buffer, getOutputFormat() ); wxLogNull doNotLog; // disable logging of failed clipboard actions @@ -515,61 +503,57 @@ void BITMAP2CMP_PANEL::OnExportToClipboard( wxCommandEvent& event ) } -void BITMAP2CMP_PANEL::exportBitmap( OUTPUT_FMT_ID aFormat ) -{ - switch( aFormat ) - { - case EESCHEMA_FMT: m_parentFrame->ExportEeschemaFormat(); break; - case PCBNEW_KICAD_MOD: m_parentFrame->ExportPcbnewFormat(); break; - case POSTSCRIPT_FMT: m_parentFrame->ExportPostScriptFormat(); break; - case KICAD_WKS_LOGO: m_parentFrame->ExportDrawingSheetFormat(); break; - } -} - - void BITMAP2CMP_PANEL::ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ) { // Create a potrace bitmap - int h = m_NB_Image.GetHeight(); - int w = m_NB_Image.GetWidth(); - potrace_bitmap_t* potrace_bitmap = bm_new( w, h ); + potrace_bitmap_t* potrace_bitmap = bm_new( m_NB_Image.GetWidth(), m_NB_Image.GetHeight() ); if( !potrace_bitmap ) { - wxString msg; - msg.Printf( _( "Error allocating memory for potrace bitmap" ) ); - wxMessageBox( msg ); + wxMessageBox( _( "Error allocating memory for potrace bitmap" ) ); return; } /* fill the bitmap with data */ - for( int y = 0; y < h; y++ ) + for( int y = 0; y < m_NB_Image.GetHeight(); y++ ) { - for( int x = 0; x < w; x++ ) + for( int x = 0; x < m_NB_Image.GetWidth(); x++ ) { - unsigned char pix = m_NB_Image.GetGreen( x, y ); - BM_PUT( potrace_bitmap, x, y, pix ? 0 : 1 ); + unsigned char pixel = m_NB_Image.GetGreen( x, y ); + BM_PUT( potrace_bitmap, x, y, pixel ? 0 : 1 ); } } - // choices of m_rbPCBLayer are expected to be in same order as - // BMP2CMP_MOD_LAYER. See bitmap2component.h - BMP2CMP_MOD_LAYER modLayer = MOD_LYR_FSILKS; + wxString layer = wxT( "F.SilkS" ); - if( aFormat == PCBNEW_KICAD_MOD ) - modLayer = (BMP2CMP_MOD_LAYER) m_chPCBLayer->GetSelection(); + if( aFormat == FOOTPRINT_FMT ) + { + switch( m_layerCtrl->GetSelection() ) + { + case 0: layer = wxT( "F.Cu" ); break; + case 1: layer = wxT( "F.SilkS" ); break; + case 2: layer = wxT( "F.Mask" ); break; + case 3: layer = wxT( "Dwgs.User" ); break; + case 4: layer = wxT( "Cmts.User" ); break; + case 5: layer = wxT( "Eco1.User" ); break; + case 6: layer = wxT( "Eco2.User" ); break; + case 7: layer = wxT( "F.Fab" ); break; + } + } + + WX_STRING_REPORTER reporter; + BITMAPCONV_INFO converter( aOutput, reporter ); - BITMAPCONV_INFO converter( aOutput ); converter.ConvertBitmap( potrace_bitmap, aFormat, m_outputSizeX.GetOutputDPI(), - m_outputSizeY.GetOutputDPI(), modLayer ); + m_outputSizeY.GetOutputDPI(), layer ); - if( !converter.GetErrorMessages().empty() ) - wxMessageBox( converter.GetErrorMessages().c_str(), _( "Errors" ) ); + if( reporter.HasMessage() ) + wxMessageBox( reporter.GetMessages(), _( "Errors" ) ); } void BITMAP2CMP_PANEL::OnFormatChange( wxCommandEvent& event ) { - bool enable = m_rbOutputFormat->GetSelection() == PCBNEW_KICAD_MOD; - m_chPCBLayer->Enable( enable ); + m_layerLabel->Enable( m_rbFootprint->GetValue() ); + m_layerCtrl->Enable( m_rbFootprint->GetValue() ); } diff --git a/bitmap2component/bitmap2cmp_panel.h b/bitmap2component/bitmap2cmp_panel.h index 8717990476..e83f76b4ad 100644 --- a/bitmap2component/bitmap2cmp_panel.h +++ b/bitmap2component/bitmap2cmp_panel.h @@ -40,32 +40,13 @@ public: // to the value in new unit void SetUnit( EDA_UNITS aUnit ); - // Accessors: - void SetOriginalDPI( int aDPI ) - { - m_originalDPI = aDPI; - } + void SetOriginalDPI( int aDPI ) { m_originalDPI = aDPI; } - void SetOriginalSizePixels( int aPixels ) - { - m_originalSizePixels = aPixels; - } + void SetOriginalSizePixels( int aPixels ) { m_originalSizePixels = aPixels; } + int GetOriginalSizePixels() { return m_originalSizePixels; } - double GetOutputSize() - { - return m_outputSize; - } - - void SetOutputSize( double aSize, EDA_UNITS aUnit ) - { - m_unit = aUnit; - m_outputSize = aSize; - } - - int GetOriginalSizePixels() - { - return m_originalSizePixels; - } + double GetOutputSize() { return m_outputSize; } + void SetOutputSize( double aSize, EDA_UNITS aUnit ) { m_outputSize = aSize; m_unit = aUnit; } // Set the m_outputSize value from the m_originalSizePixels and the selected unit void SetOutputSizeFromInitialImageSize(); @@ -88,7 +69,7 @@ class BITMAP2CMP_PANEL : public BITMAP2CMP_PANEL_BASE { public: BITMAP2CMP_PANEL( BITMAP2CMP_FRAME* aParent ); - ~BITMAP2CMP_PANEL(); + ~BITMAP2CMP_PANEL() {} bool OpenProjectFiles( const std::vector& aFilenames, int aCtl = 0 ); @@ -117,28 +98,27 @@ private: void OnPaintBW( wxPaintEvent& event ) override; void OnExportToFile( wxCommandEvent& event ) override; void OnExportToClipboard( wxCommandEvent& event ) override; + void OnFormatChange( wxCommandEvent& event ) override; + void OnNegativeClicked( wxCommandEvent& event ) override; + void OnThresholdChange( wxScrollEvent& event ) override; + void OnSizeChangeX( wxCommandEvent& event ) override; + void OnSizeChangeY( wxCommandEvent& event ) override; + void OnSizeUnitChange( wxCommandEvent& event ) override; + void ToggleAspectRatioLock( wxCommandEvent& event ) override; + + OUTPUT_FMT_ID getOutputFormat(); ///< @return the EDA_UNITS from the m_PixelUnit choice EDA_UNITS getUnitFromSelection(); // return a string giving the output size, according to the selected unit - wxString FormatOutputSize( double aSize ); + wxString formatOutputSize( double aSize ); - void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level) - void OnNegativeClicked( wxCommandEvent& event ) override; - void OnThresholdChange( wxScrollEvent& event ) override; + void binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level) - void OnSizeChangeX( wxCommandEvent& event ) override; - void OnSizeChangeY( wxCommandEvent& event ) override; - void OnSizeUnitChange( wxCommandEvent& event ) override; - - void ToggleAspectRatioLock( wxCommandEvent& event ) override; - - void NegateGreyscaleImage(); + void negateGreyscaleImage(); void updateImageInfo(); - void OnFormatChange( wxCommandEvent& event ) override; - void exportBitmap( OUTPUT_FMT_ID aFormat ); private: BITMAP2CMP_FRAME* m_parentFrame; diff --git a/bitmap2component/bitmap2cmp_panel_base.cpp b/bitmap2component/bitmap2cmp_panel_base.cpp index 2bd5f29049..e386166d68 100644 --- a/bitmap2component/bitmap2cmp_panel_base.cpp +++ b/bitmap2component/bitmap2cmp_panel_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -27,7 +27,7 @@ BITMAP2CMP_PANEL_BASE::BITMAP2CMP_PANEL_BASE( wxWindow* parent, wxWindowID id, c m_BNPicturePanel->SetScrollRate( 5, 5 ); m_Notebook->AddPage( m_BNPicturePanel, _("Black && White Picture"), true ); - bMainSizer->Add( m_Notebook, 1, wxEXPAND|wxBOTTOM|wxLEFT, 5 ); + bMainSizer->Add( m_Notebook, 1, wxEXPAND|wxBOTTOM|wxLEFT, 10 ); wxBoxSizer* brightSizer; brightSizer = new wxBoxSizer( wxVERTICAL ); @@ -96,7 +96,7 @@ BITMAP2CMP_PANEL_BASE::BITMAP2CMP_PANEL_BASE( wxWindow* parent, wxWindowID id, c brightSizer->Add( sbSizerInfo, 0, wxEXPAND|wxALL, 5 ); m_buttonLoad = new wxButton( this, wxID_ANY, _("Load Source Image"), wxDefaultPosition, wxDefaultSize, 0 ); - brightSizer->Add( m_buttonLoad, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + brightSizer->Add( m_buttonLoad, 0, wxEXPAND|wxALL, 5 ); brightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); @@ -104,35 +104,35 @@ BITMAP2CMP_PANEL_BASE::BITMAP2CMP_PANEL_BASE( wxWindow* parent, wxWindowID id, c wxStaticBoxSizer* sbSizerImgPrms; sbSizerImgPrms = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Output Size") ), wxVERTICAL ); - m_aspectRatioCheckbox = new wxCheckBox( sbSizerImgPrms->GetStaticBox(), wxID_ANY, _("Lock height / width ratio"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizerImgPrms->Add( m_aspectRatioCheckbox, 0, wxBOTTOM, 5 ); - wxBoxSizer* bSizerRes; bSizerRes = new wxBoxSizer( wxHORIZONTAL ); - m_staticTextOSize = new wxStaticText( sbSizerImgPrms->GetStaticBox(), wxID_ANY, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextOSize->Wrap( -1 ); - bSizerRes->Add( m_staticTextOSize, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT|wxTOP, 5 ); + m_sizeLabel = new wxStaticText( sbSizerImgPrms->GetStaticBox(), wxID_ANY, _("Size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sizeLabel->Wrap( -1 ); + bSizerRes->Add( m_sizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_UnitSizeX = new wxTextCtrl( sbSizerImgPrms->GetStaticBox(), wxID_ANY, _("300"), wxDefaultPosition, wxDefaultSize, 0 ); m_UnitSizeX->SetMinSize( wxSize( 60,-1 ) ); - bSizerRes->Add( m_UnitSizeX, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + bSizerRes->Add( m_UnitSizeX, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_UnitSizeY = new wxTextCtrl( sbSizerImgPrms->GetStaticBox(), wxID_ANY, _("300"), wxDefaultPosition, wxDefaultSize, 0 ); m_UnitSizeY->SetMinSize( wxSize( 60,-1 ) ); - bSizerRes->Add( m_UnitSizeY, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + bSizerRes->Add( m_UnitSizeY, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); wxArrayString m_PixelUnitChoices; m_PixelUnit = new wxChoice( sbSizerImgPrms->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_PixelUnitChoices, 0 ); m_PixelUnit->SetSelection( 0 ); m_PixelUnit->SetMinSize( wxSize( 80,-1 ) ); - bSizerRes->Add( m_PixelUnit, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 ); + bSizerRes->Add( m_PixelUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - sbSizerImgPrms->Add( bSizerRes, 0, wxEXPAND, 5 ); + sbSizerImgPrms->Add( bSizerRes, 0, wxEXPAND|wxBOTTOM, 5 ); + + m_aspectRatioCheckbox = new wxCheckBox( sbSizerImgPrms->GetStaticBox(), wxID_ANY, _("Lock height / width ratio"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerImgPrms->Add( m_aspectRatioCheckbox, 0, wxALL, 5 ); brightSizer->Add( sbSizerImgPrms, 0, wxALL|wxEXPAND, 5 ); @@ -142,7 +142,7 @@ BITMAP2CMP_PANEL_BASE::BITMAP2CMP_PANEL_BASE( wxWindow* parent, wxWindowID id, c m_ThresholdText = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Black / white threshold:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ThresholdText->Wrap( -1 ); - sbSizer2->Add( m_ThresholdText, 0, wxLEFT, 5 ); + sbSizer2->Add( m_ThresholdText, 0, wxRIGHT|wxLEFT, 5 ); m_sliderThreshold = new wxSlider( sbSizer2->GetStaticBox(), 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.") ); @@ -150,29 +150,54 @@ BITMAP2CMP_PANEL_BASE::BITMAP2CMP_PANEL_BASE( wxWindow* parent, wxWindowID id, c sbSizer2->Add( m_sliderThreshold, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_checkNegative = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Negative"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer2->Add( m_checkNegative, 0, wxBOTTOM, 5 ); + sbSizer2->Add( m_checkNegative, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); brightSizer->Add( sbSizer2, 0, wxALL|wxEXPAND, 5 ); - m_sizerPcbLayer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pcb Layer for Graphics") ), wxVERTICAL ); + wxStaticBoxSizer* sbOutputFormat; + sbOutputFormat = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Output Format") ), wxVERTICAL ); - wxString m_chPCBLayerChoices[] = { _("Front silk screen"), _("Front solder mask"), _("Front Fab layer"), _("User layer drawings"), _("User layer comments"), _("User layer Eco1"), _("User layer Eco2") }; - int m_chPCBLayerNChoices = sizeof( m_chPCBLayerChoices ) / sizeof( wxString ); - m_chPCBLayer = new wxChoice( m_sizerPcbLayer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_chPCBLayerNChoices, m_chPCBLayerChoices, 0 ); - m_chPCBLayer->SetSelection( 0 ); - m_sizerPcbLayer->Add( m_chPCBLayer, 0, wxALL|wxEXPAND, 5 ); + wxFlexGridSizer* fgSizer2; + fgSizer2 = new wxFlexGridSizer( 5, 1, 2, 0 ); + fgSizer2->SetFlexibleDirection( wxBOTH ); + fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_rbSymbol = new wxRadioButton( sbOutputFormat->GetStaticBox(), wxID_ANY, _("Symbol (.kicad_sym file)"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer2->Add( m_rbSymbol, 0, wxBOTTOM|wxRIGHT, 5 ); + + m_rbFootprint = new wxRadioButton( sbOutputFormat->GetStaticBox(), wxID_ANY, _("Footprint (.kicad_mod file)"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer2->Add( m_rbFootprint, 0, wxTOP|wxRIGHT, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + + m_layerLabel = new wxStaticText( sbOutputFormat->GetStaticBox(), wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_layerLabel->Wrap( -1 ); + bSizer4->Add( m_layerLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 28 ); + + wxString m_layerCtrlChoices[] = { _("F.Cu"), _("F.Silkscreen"), _("F.Mask"), _("User.Drawings"), _("User.Comments"), _("User.Eco1"), _("User.Eco2"), _("F.Fab") }; + int m_layerCtrlNChoices = sizeof( m_layerCtrlChoices ) / sizeof( wxString ); + m_layerCtrl = new wxChoice( sbOutputFormat->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_layerCtrlNChoices, m_layerCtrlChoices, 0 ); + m_layerCtrl->SetSelection( 0 ); + bSizer4->Add( m_layerCtrl, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - brightSizer->Add( m_sizerPcbLayer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + fgSizer2->Add( bSizer4, 1, wxEXPAND, 5 ); - wxString m_rbOutputFormatChoices[] = { _("Symbol (.kicad_sym file)"), _("Footprint (.kicad_mod file)"), _("Postscript (.ps file)"), _("Drawing Sheet (.kicad_wks file)") }; - int m_rbOutputFormatNChoices = sizeof( m_rbOutputFormatChoices ) / sizeof( wxString ); - m_rbOutputFormat = new wxRadioBox( this, wxID_ANY, _("Output Format"), wxDefaultPosition, wxDefaultSize, m_rbOutputFormatNChoices, m_rbOutputFormatChoices, 1, wxRA_SPECIFY_COLS ); - m_rbOutputFormat->SetSelection( 0 ); - brightSizer->Add( m_rbOutputFormat, 0, wxEXPAND|wxALL, 5 ); + m_rbPostscript = new wxRadioButton( sbOutputFormat->GetStaticBox(), wxID_ANY, _("Postscript (.ps file)"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer2->Add( m_rbPostscript, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); - m_buttonExportFile = new wxButton( this, wxID_ANY, _("Export to File"), wxDefaultPosition, wxDefaultSize, 0 ); + m_rbWorksheet = new wxRadioButton( sbOutputFormat->GetStaticBox(), wxID_ANY, _("Drawing Sheet (.kicad_wks file)"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer2->Add( m_rbWorksheet, 0, wxTOP|wxRIGHT, 5 ); + + + sbOutputFormat->Add( fgSizer2, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + + brightSizer->Add( sbOutputFormat, 1, wxEXPAND|wxALL, 5 ); + + m_buttonExportFile = new wxButton( this, wxID_ANY, _("Export to File..."), wxDefaultPosition, wxDefaultSize, 0 ); brightSizer->Add( m_buttonExportFile, 0, wxEXPAND|wxALL, 5 ); m_buttonExportClipboard = new wxButton( this, wxID_ANY, _("Export to Clipboard"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -191,14 +216,17 @@ BITMAP2CMP_PANEL_BASE::BITMAP2CMP_PANEL_BASE( wxWindow* parent, wxWindowID id, c m_GreyscalePicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintGreyscale ), NULL, this ); m_BNPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintBW ), NULL, this ); m_buttonLoad->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnLoadFile ), NULL, this ); - m_aspectRatioCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::ToggleAspectRatioLock ), NULL, this ); m_UnitSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeChangeX ), NULL, this ); m_UnitSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeChangeY ), NULL, this ); m_PixelUnit->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeUnitChange ), NULL, this ); + m_aspectRatioCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::ToggleAspectRatioLock ), NULL, this ); m_sliderThreshold->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( BITMAP2CMP_PANEL_BASE::OnThresholdChange ), NULL, this ); m_sliderThreshold->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BITMAP2CMP_PANEL_BASE::OnThresholdChange ), NULL, this ); m_checkNegative->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnNegativeClicked ), NULL, this ); - m_rbOutputFormat->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_rbSymbol->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_rbFootprint->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_rbPostscript->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_rbWorksheet->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); m_buttonExportFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnExportToFile ), NULL, this ); m_buttonExportClipboard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnExportToClipboard ), NULL, this ); } @@ -210,14 +238,17 @@ BITMAP2CMP_PANEL_BASE::~BITMAP2CMP_PANEL_BASE() m_GreyscalePicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintGreyscale ), NULL, this ); m_BNPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BITMAP2CMP_PANEL_BASE::OnPaintBW ), NULL, this ); m_buttonLoad->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnLoadFile ), NULL, this ); - m_aspectRatioCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::ToggleAspectRatioLock ), NULL, this ); m_UnitSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeChangeX ), NULL, this ); m_UnitSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeChangeY ), NULL, this ); m_PixelUnit->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnSizeUnitChange ), NULL, this ); + m_aspectRatioCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::ToggleAspectRatioLock ), NULL, this ); m_sliderThreshold->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( BITMAP2CMP_PANEL_BASE::OnThresholdChange ), NULL, this ); m_sliderThreshold->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BITMAP2CMP_PANEL_BASE::OnThresholdChange ), NULL, this ); m_checkNegative->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnNegativeClicked ), NULL, this ); - m_rbOutputFormat->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_rbSymbol->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_rbFootprint->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_rbPostscript->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); + m_rbWorksheet->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnFormatChange ), NULL, this ); m_buttonExportFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnExportToFile ), NULL, this ); m_buttonExportClipboard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BITMAP2CMP_PANEL_BASE::OnExportToClipboard ), NULL, this ); diff --git a/bitmap2component/bitmap2cmp_panel_base.fbp b/bitmap2component/bitmap2cmp_panel_base.fbp index 92ed307a8a..9159a721ca 100644 --- a/bitmap2component/bitmap2cmp_panel_base.fbp +++ b/bitmap2component/bitmap2cmp_panel_base.fbp @@ -1,78 +1,360 @@ - + - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - bitmap2cmp_panel_base - 1000 - none - - - 1 - bitmap2cmp_panel - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT + + + C++ + + 1 + connect + none + + + 0 + 0 + res + UTF-8 + bitmap2cmp_panel_base + 1000 + 1 + 1 + UI + bitmap2cmp_panel + . + 0 + source_name + 1 + 0 + source_name + + + 1 + 1 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 0 + 1 + impl_virtual + + + 0 + wxID_ANY + + + BITMAP2CMP_PANEL_BASE + + -1,-1 + ; ; forward_declare + + 0 + + + wxTAB_TRAVERSAL + + + bMainSizer + wxHORIZONTAL + none + + 10 + wxEXPAND|wxBOTTOM|wxLEFT + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left + 0 1 - impl_virtual + 1 + 0 0 wxID_ANY + + 0 - - BITMAP2CMP_PANEL_BASE + + 0 + 500,-1 + 1 + m_Notebook + 1 + + + protected + 1 - -1,-1 - ; ; forward_declare + Resizable + 1 + + + + 0 - 0 - wxTAB_TRAVERSAL - + + + + Original Picture + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + -1,-1 + + 0 + -1,-1 + 1 + m_InitialPicturePanel + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + OnPaintInit + + + + + Greyscale Picture + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + -1,-1 + + 0 + -1,-1 + 1 + m_GreyscalePicturePanel + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + OnPaintGreyscale + + + + + Black && White Picture + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 - bMainSizer - wxHORIZONTAL + 1 + m_BNPicturePanel + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + OnPaintBW + + + + + + 5 + wxEXPAND|wxALL + 0 + + + brightSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxALL + 0 + + wxID_ANY + Image Information + + sbSizerInfo + wxVERTICAL + 1 none - - 5 - wxEXPAND|wxBOTTOM|wxLEFT - 1 - + + 5 + wxEXPAND + 0 + + 4 + wxBOTH + 1,2 + + 0 + + fgSizerInfo + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + 1 1 1 1 - + 0 - - + 0 + 0 - 1 0 @@ -83,6 +365,7 @@ Dock 0 Left + 0 1 1 @@ -90,14 +373,16 @@ 0 0 wxID_ANY + Image size: + 0 0 0 - 500,-1 + 1 - m_Notebook + m_staticTextISize 1 @@ -114,1843 +399,1876 @@ - - - Original Picture - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - -1,-1 - - 0 - -1,-1 - 1 - m_InitialPicturePanel - 1 - - - protected - 1 - - Resizable - 5 - 5 - 1 - - - 0 - - - - wxHSCROLL|wxVSCROLL - OnPaintInit - - - - - 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 - -1,-1 - 1 - m_GreyscalePicturePanel - 1 - - - protected - 1 - - Resizable - 5 - 5 - 1 - - - 0 - - - - wxHSCROLL|wxVSCROLL - OnPaintGreyscale - - - - - Black && White Picture - 1 - - 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 - 1 - - - 0 - - - - wxHSCROLL|wxVSCROLL - OnPaintBW - - + -1 + - - - 5 - wxEXPAND|wxALL - 0 - + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + 0000 + 0 + + 0 + + + 0 - brightSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxALL - 0 - - wxID_ANY - Image Information - - sbSizerInfo - wxVERTICAL - 1 - none - - 5 - wxEXPAND - 0 - - 4 - wxBOTH - 1,2 - - 0 - - fgSizerInfo - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 0 - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Image size: - 0 - - 0 - - - 0 - - 1 - m_staticTextISize - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - 0000 - 0 - - 0 - - - 0 - - 1 - m_SizeXValue - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - 0000 - 0 - - 0 - - - 0 - - 1 - m_SizeYValue - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - pixels - 0 - - 0 - - - 0 - - 1 - m_SizePixUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Image PPI: - 0 - - 0 - - - 0 - - 1 - m_staticTextDPI - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - 0000 - 0 - - 0 - - - 0 - - 1 - m_InputXValueDPI - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - 0000 - 0 - - 0 - - - 0 - - 1 - m_InputYValueDPI - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - PPI - 0 - - 0 - - - 0 - - 1 - m_DPIUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxBOTTOM|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - BPP: - 0 - - 0 - - - 0 - - 1 - m_staticTextBPP - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - 0000 - 0 - - 0 - - - 0 - - 1 - m_BPPValue - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - bits - 0 - - 0 - - - 0 - - 1 - m_BPPunits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - - 0 - - 0 - protected - 0 - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Load Source Image - - 0 - - 0 - - - 0 - - 1 - m_buttonLoad - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnLoadFile - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALL|wxEXPAND - 0 - - wxID_ANY - Output Size - - sbSizerImgPrms - wxVERTICAL - 1 - none - - 5 - wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Lock height / width ratio - - 0 - - - 0 - - 1 - m_aspectRatioCheckbox - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - ToggleAspectRatioLock - - - - 5 - wxEXPAND - 0 - - - bSizerRes - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Size: - 0 - - 0 - - - 0 - - 1 - m_staticTextOSize - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - 60,-1 - 1 - m_UnitSizeX - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NUMERIC - wxTextValidator - - 300 - - - - OnSizeChangeX - - - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - 60,-1 - 1 - m_UnitSizeY - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NUMERIC - wxTextValidator - - 300 - - - - OnSizeChangeY - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 80,-1 - 1 - m_PixelUnit - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; Not forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnSizeUnitChange - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - wxID_ANY - Options - - sbSizer2 - wxVERTICAL - 1 - none - - 5 - wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Black / white threshold: - 0 - - 0 - - - 0 - - 1 - m_ThresholdText - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - 100 - - 0 - - 0 - - 0 - - 1 - m_sliderThreshold - 1 - - - protected - 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 - - 50 - - - - OnThresholdChange - OnThresholdChange - - - - 5 - wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Negative - - 0 - - - 0 - - 1 - m_checkNegative - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnNegativeClicked - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - wxID_ANY - Pcb Layer for Graphics - - m_sizerPcbLayer - wxVERTICAL - 1 - protected - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Front silk screen" "Front solder mask" "Front Fab layer" "User layer drawings" "User layer comments" "User layer Eco1" "User layer Eco2" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_chPCBLayer - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Symbol (.kicad_sym file)" "Footprint (.kicad_mod file)" "Postscript (.ps file)" "Drawing Sheet (.kicad_wks file)" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Output Format - 1 - - 0 - - - 0 - - 1 - m_rbOutputFormat - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnFormatChange - - - - 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Export to File - - 0 - - 0 - - - 0 - - 1 - m_buttonExportFile - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnExportToFile - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Export to Clipboard - - 0 - - 0 - - - 0 - - 1 - m_buttonExportClipboard - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnExportToClipboard - - + 1 + m_SizeXValue + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + 0000 + 0 + + 0 + + + 0 + + 1 + m_SizeYValue + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + pixels + 0 + + 0 + + + 0 + + 1 + m_SizePixUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Image PPI: + 0 + + 0 + + + 0 + + 1 + m_staticTextDPI + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + 0000 + 0 + + 0 + + + 0 + + 1 + m_InputXValueDPI + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + 0000 + 0 + + 0 + + + 0 + + 1 + m_InputYValueDPI + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + PPI + 0 + + 0 + + + 0 + + 1 + m_DPIUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxBOTTOM|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + BPP: + 0 + + 0 + + + 0 + + 1 + m_staticTextBPP + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + 0000 + 0 + + 0 + + + 0 + + 1 + m_BPPValue + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + bits + 0 + + 0 + + + 0 + + 1 + m_BPPunits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + + 0 + + 0 + protected + 0 + + + + + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Load Source Image + + 0 + + 0 + + + 0 + + 1 + m_buttonLoad + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnLoadFile + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL|wxEXPAND + 0 + + wxID_ANY + Output Size + + sbSizerImgPrms + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxBOTTOM + 0 + + + bSizerRes + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Size: + 0 + + 0 + + + 0 + + 1 + m_sizeLabel + 1 + + + private + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + 60,-1 + 1 + m_UnitSizeX + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NUMERIC + wxTextValidator + + 300 + + + + OnSizeChangeX + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + 60,-1 + 1 + m_UnitSizeY + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NUMERIC + wxTextValidator + + 300 + + + + OnSizeChangeY + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 80,-1 + 1 + m_PixelUnit + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; Not forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSizeUnitChange + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Lock height / width ratio + + 0 + + + 0 + + 1 + m_aspectRatioCheckbox + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + ToggleAspectRatioLock + + + + + + 5 + wxALL|wxEXPAND + 0 + + wxID_ANY + Options + + sbSizer2 + wxVERTICAL + 1 + none + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Black / white threshold: + 0 + + 0 + + + 0 + + 1 + m_ThresholdText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + 100 + + 0 + + 0 + + 0 + + 1 + m_sliderThreshold + 1 + + + protected + 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 + + 50 + + + + OnThresholdChange + OnThresholdChange + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Negative + + 0 + + + 0 + + 1 + m_checkNegative + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnNegativeClicked + + + + + + 5 + wxEXPAND|wxALL + 1 + + wxID_ANY + Output Format + + sbOutputFormat + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 1 + + 1 + wxBOTH + + + 0 + + fgSizer2 + wxFLEX_GROWMODE_SPECIFIED + none + 5 + 2 + + 5 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Symbol (.kicad_sym file) + + 0 + + + 0 + + 1 + m_rbSymbol + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnFormatChange + + + + 5 + wxTOP|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Footprint (.kicad_mod file) + + 0 + + + 0 + + 1 + m_rbFootprint + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnFormatChange + + + + 5 + wxEXPAND + 1 + + + bSizer4 + wxHORIZONTAL + none + + 28 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Layer: + 0 + + 0 + + + 0 + + 1 + m_layerLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + "F.Cu" "F.Silkscreen" "F.Mask" "User.Drawings" "User.Comments" "User.Eco1" "User.Eco2" "F.Fab" + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_layerCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Postscript (.ps file) + + 0 + + + 0 + + 1 + m_rbPostscript + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnFormatChange + + + + 5 + wxTOP|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Drawing Sheet (.kicad_wks file) + + 0 + + + 0 + + 1 + m_rbWorksheet + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnFormatChange + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Export to File... + + 0 + + 0 + + + 0 + + 1 + m_buttonExportFile + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnExportToFile + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Export to Clipboard + + 0 + + 0 + + + 0 + + 1 + m_buttonExportClipboard + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnExportToClipboard + + + + + diff --git a/bitmap2component/bitmap2cmp_panel_base.h b/bitmap2component/bitmap2cmp_panel_base.h index ce2479e918..e6e1a2250b 100644 --- a/bitmap2component/bitmap2cmp_panel_base.h +++ b/bitmap2component/bitmap2cmp_panel_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -24,23 +24,23 @@ #include #include #include -#include #include #include #include +#include #include -#include +#include #include /////////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// /// Class BITMAP2CMP_PANEL_BASE /////////////////////////////////////////////////////////////////////////////// class BITMAP2CMP_PANEL_BASE : public wxPanel { private: + wxStaticText* m_sizeLabel; protected: wxNotebook* m_Notebook; @@ -59,17 +59,19 @@ class BITMAP2CMP_PANEL_BASE : public wxPanel wxStaticText* m_BPPValue; wxStaticText* m_BPPunits; wxButton* m_buttonLoad; - wxCheckBox* m_aspectRatioCheckbox; - wxStaticText* m_staticTextOSize; wxTextCtrl* m_UnitSizeX; wxTextCtrl* m_UnitSizeY; wxChoice* m_PixelUnit; + wxCheckBox* m_aspectRatioCheckbox; wxStaticText* m_ThresholdText; wxSlider* m_sliderThreshold; wxCheckBox* m_checkNegative; - wxStaticBoxSizer* m_sizerPcbLayer; - wxChoice* m_chPCBLayer; - wxRadioBox* m_rbOutputFormat; + wxRadioButton* m_rbSymbol; + wxRadioButton* m_rbFootprint; + wxStaticText* m_layerLabel; + wxChoice* m_layerCtrl; + wxRadioButton* m_rbPostscript; + wxRadioButton* m_rbWorksheet; wxButton* m_buttonExportFile; wxButton* m_buttonExportClipboard; @@ -78,10 +80,10 @@ class BITMAP2CMP_PANEL_BASE : public wxPanel virtual void OnPaintGreyscale( wxPaintEvent& event ) { event.Skip(); } virtual void OnPaintBW( wxPaintEvent& event ) { event.Skip(); } virtual void OnLoadFile( wxCommandEvent& event ) { event.Skip(); } - virtual void ToggleAspectRatioLock( wxCommandEvent& event ) { event.Skip(); } virtual void OnSizeChangeX( wxCommandEvent& event ) { event.Skip(); } virtual void OnSizeChangeY( wxCommandEvent& event ) { event.Skip(); } virtual void OnSizeUnitChange( wxCommandEvent& event ) { event.Skip(); } + virtual void ToggleAspectRatioLock( wxCommandEvent& event ) { event.Skip(); } virtual void OnThresholdChange( wxScrollEvent& event ) { event.Skip(); } virtual void OnNegativeClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnFormatChange( wxCommandEvent& event ) { event.Skip(); } diff --git a/bitmap2component/bitmap2cmp_settings.cpp b/bitmap2component/bitmap2cmp_settings.cpp index 070ebd6793..a766638013 100644 --- a/bitmap2component/bitmap2cmp_settings.cpp +++ b/bitmap2component/bitmap2cmp_settings.cpp @@ -27,28 +27,45 @@ ///! Update the schema version whenever a migration is required -const int bitmap2cmpSchemaVersion = 0; +const int bitmap2cmpSchemaVersion = 1; BITMAP2CMP_SETTINGS::BITMAP2CMP_SETTINGS() : APP_SETTINGS_BASE( "bitmap2component", bitmap2cmpSchemaVersion ), - m_BitmapFileName(), m_ConvertedFileName(), m_Units(), m_Threshold(), m_Negative(), - m_LastFormat(), m_LastModLayer() + m_BitmapFileName(), + m_ConvertedFileName(), + m_Units(), + m_Threshold(), + m_Negative(), + m_LastFormat(), + m_LastLayer() { m_params.emplace_back( new PARAM( "bitmap_file_name", &m_BitmapFileName, "" ) ); - - m_params.emplace_back( - new PARAM( "converted_file_name", &m_ConvertedFileName, "" ) ); - + m_params.emplace_back( new PARAM( "converted_file_name", &m_ConvertedFileName, "" ) ); m_params.emplace_back( new PARAM( "units", &m_Units, 0 ) ); - m_params.emplace_back( new PARAM( "threshold", &m_Threshold, 50 ) ); - m_params.emplace_back( new PARAM( "negative", &m_Negative, false ) ); - m_params.emplace_back( new PARAM( "last_format", &m_LastFormat, 0 ) ); + m_params.emplace_back( new PARAM( "last_mod_layer", &m_LastLayer, 0 ) ); - m_params.emplace_back( new PARAM( "last_mod_layer", &m_LastModLayer, 0 ) ); + registerMigration( 0, 1, + [&]() -> bool + { + // Version 1 introduced a new layer (F.Cu), and changed the ordering to + // be consistent with PCBNew. + switch( Get( "last_mod_layer" ).value_or( 0 ) ) + { + default: + case 0: Set( "last_mod_layer", 1 ); break; + case 1: Set( "last_mod_layer", 2 ); break; + case 2: Set( "last_mod_layer", 7 ); break; + case 3: Set( "last_mod_layer", 3 ); break; + case 4: Set( "last_mod_layer", 4 ); break; + case 5: Set( "last_mod_layer", 5 ); break; + case 6: Set( "last_mod_layer", 6 ); break; + } + return true; + } ); } diff --git a/bitmap2component/bitmap2cmp_settings.h b/bitmap2component/bitmap2cmp_settings.h index fde9625d08..7e52b79c21 100644 --- a/bitmap2component/bitmap2cmp_settings.h +++ b/bitmap2component/bitmap2cmp_settings.h @@ -35,22 +35,16 @@ public: virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override; +public: wxString m_BitmapFileName; - wxString m_ConvertedFileName; - - int m_Units; - - int m_Threshold; - - bool m_Negative; - - int m_LastFormat; - - int m_LastModLayer; + int m_Units; + int m_Threshold; + bool m_Negative; + int m_LastFormat; + int m_LastLayer; protected: - virtual std::string getLegacyFrameName() const override { return "Bmconverter_"; } }; diff --git a/bitmap2component/bitmap2component.cpp b/bitmap2component/bitmap2component.cpp index df0082c975..2e2c9474ae 100644 --- a/bitmap2component/bitmap2component.cpp +++ b/bitmap2component/bitmap2component.cpp @@ -33,12 +33,11 @@ #include #include -#include - #include #include - +#include #include +#include #include "bitmap2component.h" @@ -46,23 +45,21 @@ /* free a potrace bitmap */ static void bm_free( potrace_bitmap_t* bm ) { - if( bm != nullptr ) - { + if( bm ) free( bm->map ); - } free( bm ); } static void BezierToPolyline( std::vector & aCornersBuffer, - potrace_dpoint_t p1, - potrace_dpoint_t p2, - potrace_dpoint_t p3, - potrace_dpoint_t p4 ); + potrace_dpoint_t p1, potrace_dpoint_t p2, + potrace_dpoint_t p3, potrace_dpoint_t p4 ); -BITMAPCONV_INFO::BITMAPCONV_INFO( std::string& aData ): - m_Data( aData ) + +BITMAPCONV_INFO::BITMAPCONV_INFO( std::string& aData, REPORTER& aReporter ): + m_Data( aData ), + m_reporter( aReporter ) { m_Format = POSTSCRIPT_FMT; m_PixmapWidth = 0; @@ -75,7 +72,7 @@ BITMAPCONV_INFO::BITMAPCONV_INFO( std::string& aData ): int BITMAPCONV_INFO::ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, OUTPUT_FMT_ID aFormat, - int aDpi_X, int aDpi_Y, BMP2CMP_MOD_LAYER aModLayer ) + int aDpi_X, int aDpi_Y, const wxString& aLayer ) { potrace_param_t* param; potrace_state_t* st; @@ -85,7 +82,8 @@ int BITMAPCONV_INFO::ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, OUTPUT_FM if( !param ) { - m_errors += fmt::format( "Error allocating parameters: {}\n", strerror( errno ) ); + m_reporter.Report( fmt::format( "Error allocating parameters: {}\n", strerror( errno ) ), + RPT_SEVERITY_ERROR ); return 1; } @@ -100,57 +98,47 @@ int BITMAPCONV_INFO::ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, OUTPUT_FM if( !st || st->status != POTRACE_STATUS_OK ) { if( st ) - { potrace_state_free( st ); - } potrace_param_free( param ); - m_errors += fmt::format( "Error tracing bitmap: {}\n", strerror( errno ) ); + m_reporter.Report( fmt::format( "Error tracing bitmap: {}\n", strerror( errno ) ), + RPT_SEVERITY_ERROR ); return 1; } m_PixmapWidth = aPotrace_bitmap->w; m_PixmapHeight = aPotrace_bitmap->h; // the bitmap size in pixels - m_Paths = st->plist; + m_Paths = st->plist; + m_Format = aFormat; switch( aFormat ) { - case KICAD_WKS_LOGO: - m_Format = KICAD_WKS_LOGO; + case DRAWING_SHEET_FMT: m_ScaleX = PL_IU_PER_MM * 25.4 / aDpi_X; // the conversion scale from PPI to micron m_ScaleY = PL_IU_PER_MM * 25.4 / aDpi_Y; // Y axis is top to bottom createOutputData(); break; case POSTSCRIPT_FMT: - m_Format = POSTSCRIPT_FMT; m_ScaleX = 1.0; // the conversion scale m_ScaleY = m_ScaleX; - - // output vector data, e.g. as a rudimentary EPS file (mainly for tests) createOutputData(); break; - case EESCHEMA_FMT: - m_Format = EESCHEMA_FMT; + case SYMBOL_FMT: m_ScaleX = SCH_IU_PER_MM * 25.4 / aDpi_X; // the conversion scale from PPI to eeschema iu m_ScaleY = -SCH_IU_PER_MM * 25.4 / aDpi_Y; // Y axis is bottom to Top for components in libs createOutputData(); break; - case PCBNEW_KICAD_MOD: - m_Format = PCBNEW_KICAD_MOD; + case FOOTPRINT_FMT: m_ScaleX = PCB_IU_PER_MM * 25.4 / aDpi_X; // the conversion scale from PPI to IU m_ScaleY = PCB_IU_PER_MM * 25.4 / aDpi_Y; // Y axis is top to bottom in Footprint Editor - createOutputData( aModLayer ); - break; - - default: + createOutputData( aLayer ); break; } - bm_free( aPotrace_bitmap ); potrace_state_free( st ); potrace_param_free( param ); @@ -159,131 +147,83 @@ int BITMAPCONV_INFO::ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, OUTPUT_FM } -const char* BITMAPCONV_INFO::getBoardLayerName( BMP2CMP_MOD_LAYER aChoice ) +void BITMAPCONV_INFO::outputDataHeader( const wxString& aBrdLayerName ) { - const char* layerName = "F.SilkS"; - - switch( aChoice ) - { - case MOD_LYR_FSOLDERMASK: - layerName = "F.Mask"; - break; - - case MOD_LYR_FAB: - layerName = "F.Fab"; - break; - - case MOD_LYR_DRAWINGS: - layerName = "Dwgs.User"; - break; - - case MOD_LYR_COMMENTS: - layerName = "Cmts.User"; - break; - - case MOD_LYR_ECO1: - layerName = "Eco1.User"; - break; - - case MOD_LYR_ECO2: - layerName = "Eco2.User"; - break; - - case MOD_LYR_FSILKS: - break; - } - - return layerName; -} - - -void BITMAPCONV_INFO::outputDataHeader( const char * aBrdLayerName ) -{ - double Ypos = ( m_PixmapHeight / 2 * m_ScaleY ); // fields Y position in mm + double Ypos = ( m_PixmapHeight / 2.0 * m_ScaleY ); // fields Y position in mm double fieldSize; // fields text size in mm - std::string strbuf; switch( m_Format ) { case POSTSCRIPT_FMT: - /* output vector data, e.g. as a rudimentary EPS file */ m_Data += "%!PS-Adobe-3.0 EPSF-3.0\n"; - strbuf = fmt::format( "%%BoundingBox: 0 0 {} {}\n", m_PixmapWidth, m_PixmapHeight ); - m_Data += strbuf; + m_Data += fmt::format( "%%BoundingBox: 0 0 {} {}\n", m_PixmapWidth, m_PixmapHeight ); m_Data += "gsave\n"; break; - case PCBNEW_KICAD_MOD: + case FOOTPRINT_FMT: // fields text size = 1.5 mm // fields text thickness = 1.5 / 5 = 0.3mm - strbuf = fmt::format( "(footprint \"{}\" (version 20221018) (generator \"bitmap2component\") (generator_version \"{}\")\n" - " (layer \"F.Cu\")\n", - m_CmpName.c_str(), GetMajorMinorVersion().ToStdString() ); + m_Data += fmt::format( "(footprint \"{}\" (version 20221018) (generator \"bitmap2component\") (generator_version \"{}\")\n" + " (layer \"F.Cu\")\n", + m_CmpName.c_str(), + GetMajorMinorVersion().ToStdString() ); - m_Data += strbuf; - strbuf = fmt::format( - " (attr board_only exclude_from_pos_files exclude_from_bom)\n" ); - m_Data += strbuf; - strbuf = fmt::format( - " (fp_text reference \"G***\" (at 0 0) (layer \"{}\")\n" - " (effects (font (size 1.5 1.5) (thickness 0.3)))\n" - " (uuid {})\n )\n", - aBrdLayerName, KIID().AsString().ToStdString().c_str() ); + m_Data += fmt::format( " (attr board_only exclude_from_pos_files exclude_from_bom)\n" ); + m_Data += fmt::format( " (fp_text reference \"G***\" (at 0 0) (layer \"{}\")\n" + " (effects (font (size 1.5 1.5) (thickness 0.3)))\n" + " (uuid {})\n )\n", + aBrdLayerName.ToStdString().c_str(), + KIID().AsString().ToStdString().c_str() ); - m_Data += strbuf; - strbuf = fmt::format( - " (fp_text value \"{}\" (at 0.75 0) (layer \"{}\") hide\n" - " (effects (font (size 1.5 1.5) (thickness 0.3)))\n" - " (uuid {})\n )\n", - m_CmpName.c_str(), aBrdLayerName, KIID().AsString().ToStdString().c_str() ); - - m_Data += strbuf; + m_Data += fmt::format( " (fp_text value \"{}\" (at 0.75 0) (layer \"{}\") hide\n" + " (effects (font (size 1.5 1.5) (thickness 0.3)))\n" + " (uuid {})\n )\n", + m_CmpName.c_str(), + aBrdLayerName.ToStdString().c_str(), + KIID().AsString().ToStdString().c_str() ); break; - case KICAD_WKS_LOGO: - m_Data += fmt::format("(kicad_wks (version 20220228) (generator \"bitmap2component\") (generator_version \"{}\")\n", GetMajorMinorVersion().ToStdString() ); + case DRAWING_SHEET_FMT: + m_Data += fmt::format( "(kicad_wks (version 20220228) (generator \"bitmap2component\") (generator_version \"{}\")\n", + GetMajorMinorVersion().ToStdString() ); m_Data += " (setup (textsize 1.5 1.5)(linewidth 0.15)(textlinewidth 0.15)\n"; m_Data += " (left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10))\n"; m_Data += " (polygon (name \"\") (pos 0 0) (linewidth 0.01)\n"; break; - case EESCHEMA_FMT: + case SYMBOL_FMT: fieldSize = 1.27; // fields text size in mm (= 50 mils) Ypos /= SCH_IU_PER_MM; Ypos += fieldSize / 2; - // snprintf( strbuf, sizeof(strbuf), "# pixmap size w = %d, h = %d\n#\n", m_PixmapWidth, m_PixmapHeight ); - strbuf = fmt::format( - "(kicad_symbol_lib (version 20220914) (generator \"bitmap2component\") (generator_version \"{}\")\n" - " (symbol \"{}\" (pin_names (offset 1.016)) (in_bom yes) (on_board yes)\n", - GetMajorMinorVersion().ToStdString(), m_CmpName.c_str() ); - m_Data += strbuf; + m_Data += fmt::format( "(kicad_symbol_lib (version 20220914) (generator \"bitmap2component\") (generator_version \"{}\")\n" + " (symbol \"{}\" (pin_names (offset 1.016)) (in_bom yes) (on_board yes)\n", + GetMajorMinorVersion().ToStdString(), + m_CmpName.c_str() ); - strbuf = fmt::format( - " (property \"Reference\" \"#G\" (at 0 {:g} 0)\n" - " (effects (font (size {:g} {:g})) hide)\n )\n", - -Ypos, fieldSize, fieldSize ); - m_Data += strbuf; + m_Data += fmt::format( " (property \"Reference\" \"#G\" (at 0 {:g} 0)\n" + " (effects (font (size {:g} {:g})) hide)\n )\n", + -Ypos, + fieldSize, + fieldSize ); - strbuf = fmt::format( - " (property \"Value\" \"{}\" (at 0 {:g} 0)\n" - " (effects (font (size {:g} {:g})) hide)\n )\n", - m_CmpName.c_str(), Ypos, fieldSize, fieldSize ); - m_Data += strbuf; + m_Data += fmt::format( " (property \"Value\" \"{}\" (at 0 {:g} 0)\n" + " (effects (font (size {:g} {:g})) hide)\n )\n", + m_CmpName.c_str(), + Ypos, + fieldSize, + fieldSize ); - strbuf = fmt::format( - " (property \"Footprint\" \"\" (at 0 0 0)\n" - " (effects (font (size {:g} {:g})) hide)\n )\n", - fieldSize, fieldSize ); - m_Data += strbuf; + m_Data += fmt::format( " (property \"Footprint\" \"\" (at 0 0 0)\n" + " (effects (font (size {:g} {:g})) hide)\n )\n", + fieldSize, + fieldSize ); - strbuf = fmt::format( - " (property \"Datasheet\" \"\" (at 0 0 0)\n" - " (effects (font (size {:g} {:g})) hide)\n )\n", - fieldSize, fieldSize ); - m_Data += strbuf; + m_Data += fmt::format( " (property \"Datasheet\" \"\" (at 0 0 0)\n" + " (effects (font (size {:g} {:g})) hide)\n )\n", + fieldSize, + fieldSize ); - strbuf = fmt::format( " (symbol \"{}_0_0\"\n", m_CmpName.c_str() ); - m_Data += strbuf; + m_Data += fmt::format( " (symbol \"{}_0_0\"\n", m_CmpName.c_str() ); break; } } @@ -298,15 +238,15 @@ void BITMAPCONV_INFO::outputDataEnd() m_Data += "%%EOF\n"; break; - case PCBNEW_KICAD_MOD: + case FOOTPRINT_FMT: m_Data += ")\n"; break; - case KICAD_WKS_LOGO: + case DRAWING_SHEET_FMT: m_Data += " )\n)\n"; break; - case EESCHEMA_FMT: + case SYMBOL_FMT: m_Data += " )\n"; // end symbol_0_0 m_Data += " )\n"; // end symbol m_Data += ")\n"; // end lib @@ -315,16 +255,14 @@ void BITMAPCONV_INFO::outputDataEnd() } -void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char* aBrdLayerName ) +void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const wxString& aBrdLayerName ) { // write one polygon to output file. // coordinates are expected in target unit. - int ii, jj; + int ii, jj; VECTOR2I currpoint; - std::string strbuf; - - int offsetX = (int)( m_PixmapWidth / 2 * m_ScaleX ); - int offsetY = (int)( m_PixmapHeight / 2 * m_ScaleY ); + int offsetX = KiROUND( m_PixmapWidth / 2.0 * m_ScaleX ); + int offsetY = KiROUND( m_PixmapHeight / 2.0 * m_ScaleY ); const VECTOR2I startpoint = aPolygon.CPoint( 0 ); @@ -332,15 +270,13 @@ void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char* { case POSTSCRIPT_FMT: offsetY = (int)( m_PixmapHeight * m_ScaleY ); - strbuf = fmt::format( "newpath\n{} {} moveto\n", startpoint.x, offsetY - startpoint.y ); - m_Data += strbuf; + m_Data += fmt::format( "newpath\n{} {} moveto\n", startpoint.x, offsetY - startpoint.y ); jj = 0; for( ii = 1; ii < aPolygon.PointCount(); ii++ ) { currpoint = aPolygon.CPoint( ii ); - strbuf = fmt::format( " {} {} lineto", currpoint.x, offsetY - currpoint.y ); - m_Data += strbuf; + m_Data += fmt::format( " {} {} lineto", currpoint.x, offsetY - currpoint.y ); if( jj++ > 6 ) { @@ -352,9 +288,7 @@ void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char* m_Data += "\nclosepath fill\n"; break; - case PCBNEW_KICAD_MOD: - { - double width = 0.0; // outline thickness in mm: no thickness + case FOOTPRINT_FMT: m_Data += " (fp_poly\n (pts\n"; jj = 0; @@ -362,23 +296,20 @@ void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char* for( ii = 0; ii < aPolygon.PointCount(); ii++ ) { currpoint = aPolygon.CPoint( ii ); - strbuf = fmt::format( " (xy {} {})\n", - ( currpoint.x - offsetX ) / PCB_IU_PER_MM, - ( currpoint.y - offsetY ) / PCB_IU_PER_MM ); - m_Data += strbuf; + m_Data += fmt::format( " (xy {} {})\n", + ( currpoint.x - offsetX ) / PCB_IU_PER_MM, + ( currpoint.y - offsetY ) / PCB_IU_PER_MM ); } // No need to close polygon m_Data += " )\n\n"; - strbuf = fmt::format( - " (stroke (width {:f}) (type solid)) (fill solid) (layer \"{}\") (uuid {}))\n", - width, aBrdLayerName, KIID().AsString().ToStdString().c_str() ); + m_Data += fmt::format( " (stroke (width {:f}) (type solid)) (fill solid) (layer \"{}\") (uuid {}))\n", + 0.0, + aBrdLayerName.ToStdString().c_str(), + KIID().AsString().ToStdString().c_str() ); + break; - m_Data += strbuf; - } - break; - - case KICAD_WKS_LOGO: + case DRAWING_SHEET_FMT: m_Data += " (pts"; // Internal units = micron, file unit = mm @@ -387,10 +318,9 @@ void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char* for( ii = 0; ii < aPolygon.PointCount(); ii++ ) { currpoint = aPolygon.CPoint( ii ); - strbuf = fmt::format( " (xy {:.3f} {:.3f})", - ( currpoint.x - offsetX ) / PL_IU_PER_MM, - ( currpoint.y - offsetY ) / PL_IU_PER_MM ); - m_Data += strbuf; + m_Data += fmt::format( " (xy {:.3f} {:.3f})", + ( currpoint.x - offsetX ) / PL_IU_PER_MM, + ( currpoint.y - offsetY ) / PL_IU_PER_MM ); if( jj++ > 4 ) { @@ -400,13 +330,12 @@ void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char* } // Close polygon - strbuf = fmt::format( " (xy {:.3f} {:.3f}) )\n", + m_Data += fmt::format( " (xy {:.3f} {:.3f}) )\n", ( startpoint.x - offsetX ) / PL_IU_PER_MM, ( startpoint.y - offsetY ) / PL_IU_PER_MM ); - m_Data += strbuf; break; - case EESCHEMA_FMT: + case SYMBOL_FMT: // The polygon outline thickness is fixed here to 0.01 ( 0.0 is the default thickness) #define SCH_LINE_THICKNESS_MM 0.01 //snprintf( strbuf, sizeof(strbuf), "P %d 0 0 %d", (int) aPolygon.PointCount() + 1, EE_LINE_THICKNESS ); @@ -415,31 +344,27 @@ void BITMAPCONV_INFO::outputOnePolygon( SHAPE_LINE_CHAIN& aPolygon, const char* for( ii = 0; ii < aPolygon.PointCount(); ii++ ) { currpoint = aPolygon.CPoint( ii ); - strbuf = fmt::format( " (xy {:f} {:f})\n", - ( currpoint.x - offsetX ) / SCH_IU_PER_MM, - ( currpoint.y - offsetY ) / SCH_IU_PER_MM ); - m_Data += strbuf; + m_Data += fmt::format( " (xy {:f} {:f})\n", + ( currpoint.x - offsetX ) / SCH_IU_PER_MM, + ( currpoint.y - offsetY ) / SCH_IU_PER_MM ); } // Close polygon - strbuf = fmt::format( " (xy {:f} {:f})\n", - ( startpoint.x - offsetX ) / SCH_IU_PER_MM, - ( startpoint.y - offsetY ) / SCH_IU_PER_MM ); - m_Data += strbuf; + m_Data += fmt::format( " (xy {:f} {:f})\n", + ( startpoint.x - offsetX ) / SCH_IU_PER_MM, + ( startpoint.y - offsetY ) / SCH_IU_PER_MM ); m_Data += " )\n"; // end pts - strbuf = fmt::format( - " (stroke (width {:g}) (type default))\n (fill (type outline))\n", - SCH_LINE_THICKNESS_MM ); - - m_Data += strbuf; + m_Data += fmt::format( " (stroke (width {:g}) (type default))\n" + " (fill (type outline))\n", + SCH_LINE_THICKNESS_MM ); m_Data += " )\n"; // end polyline break; } } -void BITMAPCONV_INFO::createOutputData( BMP2CMP_MOD_LAYER aModLayer ) +void BITMAPCONV_INFO::createOutputData( const wxString& aLayer ) { std::vector cornersBuffer; @@ -456,7 +381,7 @@ void BITMAPCONV_INFO::createOutputData( BMP2CMP_MOD_LAYER aModLayer ) // The layer name has meaning only for .kicad_mod files. // For these files the header creates 2 invisible texts: value and ref // (needed but not useful) on silk screen layer - outputDataHeader( getBoardLayerName( MOD_LYR_FSILKS ) ); + outputDataHeader( "F.SilkS" ); bool main_outline = true; @@ -465,9 +390,10 @@ void BITMAPCONV_INFO::createOutputData( BMP2CMP_MOD_LAYER aModLayer ) */ potrace_path_t* paths = m_Paths; // the list of paths - if(!m_Paths) + if( !m_Paths ) { - m_errors += "No shape in black and white image to convert: no outline created\n"; + m_reporter.Report( _( "No shape in black and white image to convert: no outline created." ), + RPT_SEVERITY_ERROR ); } while( paths != nullptr ) @@ -501,10 +427,11 @@ void BITMAPCONV_INFO::createOutputData( BMP2CMP_MOD_LAYER aModLayer ) // build the current main polygon polyset_areas.NewOutline(); - for( unsigned int i = 0; i < cornersBuffer.size(); i++ ) + + for( const potrace_dpoint_s& pt : cornersBuffer ) { - polyset_areas.Append( int( cornersBuffer[i].x * m_ScaleX ), - int( cornersBuffer[i].y * m_ScaleY ) ); + polyset_areas.Append( int( pt.x * m_ScaleX ), + int( pt.y * m_ScaleY ) ); } } else @@ -512,10 +439,10 @@ void BITMAPCONV_INFO::createOutputData( BMP2CMP_MOD_LAYER aModLayer ) // Add current hole in polyset_holes polyset_holes.NewOutline(); - for( unsigned int i = 0; i < cornersBuffer.size(); i++ ) + for( const potrace_dpoint_s& pt : cornersBuffer ) { - polyset_holes.Append( int( cornersBuffer[i].x * m_ScaleX ), - int( cornersBuffer[i].y * m_ScaleY ) ); + polyset_holes.Append( int( pt.x * m_ScaleX ), + int( pt.y * m_ScaleY ) ); } } @@ -538,7 +465,7 @@ void BITMAPCONV_INFO::createOutputData( BMP2CMP_MOD_LAYER aModLayer ) for( int ii = 0; ii < polyset_areas.OutlineCount(); ii++ ) { SHAPE_LINE_CHAIN& poly = polyset_areas.Outline( ii ); - outputOnePolygon( poly, getBoardLayerName( aModLayer )); + outputOnePolygon( poly, aLayer ); } polyset_areas.RemoveAllContours(); diff --git a/bitmap2component/bitmap2component.h b/bitmap2component/bitmap2component.h index 1fe3e56302..9719467518 100644 --- a/bitmap2component/bitmap2component.h +++ b/bitmap2component/bitmap2component.h @@ -27,71 +27,52 @@ #include #include -// for consistency this enum should conform to the -// indices in m_radioBoxFormat from bitmap2cmp_gui.cpp +class REPORTER; + enum OUTPUT_FMT_ID { - EESCHEMA_FMT = 0, - PCBNEW_KICAD_MOD, + SYMBOL_FMT, + FOOTPRINT_FMT, POSTSCRIPT_FMT, - KICAD_WKS_LOGO, - FINAL_FMT = KICAD_WKS_LOGO + DRAWING_SHEET_FMT, }; -// for consistency this enum should conform to the -// indices in m_cbPcbLayer from bitmap2cmp_gui.cpp -enum BMP2CMP_MOD_LAYER -{ - MOD_LYR_FSILKS = 0, - MOD_LYR_FSOLDERMASK, - MOD_LYR_FAB, - MOD_LYR_DRAWINGS, - MOD_LYR_COMMENTS, - MOD_LYR_ECO1, - MOD_LYR_ECO2, - MOD_LYR_FINAL = MOD_LYR_ECO2 -}; - - /* Helper class to handle useful info to convert a bitmap image to * a polygonal object description */ class BITMAPCONV_INFO { private: - enum OUTPUT_FMT_ID m_Format; // File format - int m_PixmapWidth; - int m_PixmapHeight; // the bitmap size in pixels + enum OUTPUT_FMT_ID m_Format; // File format + int m_PixmapWidth; + int m_PixmapHeight; // the bitmap size in pixels double m_ScaleX; - double m_ScaleY; // the conversion scale - potrace_path_t* m_Paths; // the list of paths, from potrace (list of lines and bezier curves) - std::string m_CmpName; // The string used as cmp/footprint name - std::string& m_Data; // the buffer containing the conversion - std::string m_errors; // a buffer to return error messages + double m_ScaleY; // the conversion scale + potrace_path_t* m_Paths; // the list of paths, from potrace (list of lines and bezier curves) + std::string m_CmpName; // The string used as cmp/footprint name + std::string& m_Data; // the buffer containing the conversion + REPORTER& m_reporter; public: - BITMAPCONV_INFO( std::string& aData ); + BITMAPCONV_INFO( std::string& aData, REPORTER& aReporter ); /** * Run the conversion of the bitmap */ - int ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, - OUTPUT_FMT_ID aFormat, int aDpi_X, int aDpi_Y, - BMP2CMP_MOD_LAYER aModLayer ); - - std::string& GetErrorMessages() {return m_errors; } + int ConvertBitmap( potrace_bitmap_t* aPotrace_bitmap, OUTPUT_FMT_ID aFormat, int aDpi_X, + int aDpi_Y, const wxString& aLayer ); private: /** * Creates the data specified by m_Format */ - void createOutputData( BMP2CMP_MOD_LAYER aModLayer = (BMP2CMP_MOD_LAYER) 0 ); + void createOutputData( const wxString& aBrdLayerName = wxT( "F.SilkS" ) ); /** * Function outputDataHeader * write to file the header depending on file format */ - void outputDataHeader( const char * aBrdLayerName ); + void outputDataHeader( const wxString& aBrdLayerName ); /** * Function outputDataEnd @@ -99,20 +80,12 @@ private: */ void outputDataEnd(); - - /** - * @return the board layer name depending on the board layer selected - * @param aChoice = the choice (MOD_LYR_FSILKS to MOD_LYR_FINAL) - */ - const char * getBoardLayerName( BMP2CMP_MOD_LAYER aChoice ); - /** * Function outputOnePolygon * write one polygon to output file. * Polygon coordinates are expected scaled by the polygon extraction function */ - void outputOnePolygon( SHAPE_LINE_CHAIN & aPolygon, const char* aBrdLayerName ); - + void outputOnePolygon( SHAPE_LINE_CHAIN & aPolygon, const wxString& aBrdLayerName ); }; #endif // BITMAP2COMPONENT_H