Give the Image Converter a more standard presentation.

Adds a close box, Quit menu item and Open... menu item, as well as
platform-specific menus.

Fixes https://gitlab.com/kicad/code/kicad/issues/12927
This commit is contained in:
Jeff Young 2022-11-19 19:39:32 +00:00
parent c5fe265eb4
commit 79e9e6b01e
5 changed files with 1758 additions and 1896 deletions

View File

@ -32,17 +32,18 @@
#include <kiway.h>
#include <potracelib.h>
#include <wildcards_and_files_ext.h>
#include <tool/tool_manager.h>
#include <tool/common_control.h>
#include <wx/clipbrd.h>
#include <wx/rawbmp.h>
#include <wx/filedlg.h>
#include <wx/rawbmp.h>
#include <wx/msgdlg.h>
#include <wx/dcclient.h>
#include <wx/log.h>
#include "bitmap2cmp_gui_base.h"
#include "pgm_base.h"
#define DEFAULT_DPI 300 // the image DPI used in formats that do not define a DPI
@ -62,18 +63,11 @@ void IMAGE_SIZE::SetOutputSizeFromInitialImageSize()
// Set the m_outputSize value from the m_originalSizePixels and the selected unit
if( m_unit == EDA_UNITS::MILLIMETRES )
{
m_outputSize = (double)GetOriginalSizePixels() / m_originalDPI * 25.4;
}
else if( m_unit == EDA_UNITS::INCHES )
{
m_outputSize = (double)GetOriginalSizePixels() / m_originalDPI;
}
else
{
m_outputSize = m_originalDPI;
}
}
@ -82,17 +76,11 @@ int IMAGE_SIZE::GetOutputDPI()
int outputDPI;
if( m_unit == EDA_UNITS::MILLIMETRES )
{
outputDPI = GetOriginalSizePixels() / ( m_outputSize / 25.4 );
}
else if( m_unit == EDA_UNITS::INCHES )
{
outputDPI = GetOriginalSizePixels() / m_outputSize;
}
else
{
outputDPI = KiROUND( m_outputSize );
}
// Zero is not a DPI, and may cause divide-by-zero errors...
outputDPI = std::max( 1, outputDPI );
@ -150,6 +138,11 @@ void IMAGE_SIZE::SetUnit( EDA_UNITS aUnit )
}
BEGIN_EVENT_TABLE( BM2CMP_FRAME, BM2CMP_FRAME_BASE )
EVT_MENU( wxID_EXIT, BM2CMP_FRAME::OnExit )
EVT_MENU( wxID_OPEN, BM2CMP_FRAME::OnLoadFile )
END_EVENT_TABLE()
BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
BM2CMP_FRAME_BASE( aParent )
@ -169,11 +162,6 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_UnitSizeX->ChangeValue( FormatOutputSize( m_outputSizeX.GetOutputSize() ) );
m_UnitSizeY->ChangeValue( FormatOutputSize( m_outputSizeY.GetOutputSize() ) );
//Set icon for aspect ratio
m_AspectRatioLocked = true;
m_AspectRatio = 1;
m_AspectRatioLockButton->SetBitmap( KiBitmap( BITMAPS::locked ) );
// Give an icon
wxIcon icon;
wxIconBundle icon_bundle;
@ -187,6 +175,8 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SetIcons( icon_bundle );
ReCreateMenuBar();
GetSizer()->SetSizeHints( this );
m_buttonExportFile->Enable( false );
@ -216,6 +206,46 @@ wxWindow* BM2CMP_FRAME::GetToolCanvas() const
}
void BM2CMP_FRAME::ReCreateMenuBar()
{
// wxWidgets handles the Mac Application menu behind the scenes, but that means
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
wxMenuBar* menuBar = new wxMenuBar();
wxMenu* fileMenu = new wxMenu;
wxMenuItem* item = new wxMenuItem( fileMenu, wxID_OPEN, _( "Open..." ) + wxT( "\tCtrl+O" ),
_( "Load source image" ) );
fileMenu->Append( item );
#ifndef __WXMAC__
// Mac moves Quit to the App menu so we don't need a separator on Mac
fileMenu->AppendSeparator();
#endif
item = new wxMenuItem( fileMenu, wxID_EXIT, _( "Quit" ) + wxT( "\tCtrl+Q" ),
_( "Quit Image Converter" ) );
if( Pgm().GetCommonSettings()->m_Appearance.use_icons_in_menus )
item->SetBitmap( KiBitmap( BITMAPS::exit ) );
fileMenu->Append( item );
menuBar->Append( fileMenu, _( "&File" ) );
SetMenuBar( menuBar );
delete oldMenuBar;
}
void BM2CMP_FRAME::OnExit( wxCommandEvent& event )
{
Destroy();
}
void BM2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
EDA_BASE_FRAME::LoadSettings( aCfg );
@ -236,8 +266,9 @@ void BM2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
m_Negative = cfg->m_Negative;
m_checkNegative->SetValue( cfg->m_Negative );
m_exportToClipboard = false;
m_AspectRatioLocked = false;
m_AspectRatio = 1.0;
m_aspectRatioCheckbox->SetValue( true );
int format = cfg->m_LastFormat;
@ -459,26 +490,19 @@ wxString BM2CMP_FRAME::FormatOutputSize( double aSize )
wxString text;
if( getUnitFromSelection() == EDA_UNITS::MILLIMETRES )
{
text.Printf( "%.1f", aSize );
}
else if( getUnitFromSelection() == EDA_UNITS::INCHES )
{
text.Printf( "%.2f", aSize );
}
else
{
text.Printf( wxT( "%d" ), KiROUND( aSize ) );
}
return text;
}
void BM2CMP_FRAME::updateImageInfo()
{
// Note: the image resolution text controls are not modified
// here, to avoid a race between text change when entered by user and
// a text change if it is modified here.
// Note: the image resolution text controls are not modified here, to avoid a race between
// text change when entered by user and a text change if it is modified here.
if( m_Pict_Bitmap.IsOk() )
{
@ -498,18 +522,11 @@ EDA_UNITS BM2CMP_FRAME::getUnitFromSelection()
// return the EDA_UNITS from the m_PixelUnit choice
switch( m_PixelUnit->GetSelection() )
{
case 1:
return EDA_UNITS::INCHES;
case 2:
return EDA_UNITS::UNSCALED;
case 1: return EDA_UNITS::INCHES;
case 2: return EDA_UNITS::UNSCALED;
case 0:
default:
break;
default: return EDA_UNITS::MILLIMETRES;
}
return EDA_UNITS::MILLIMETRES;
}
@ -519,7 +536,7 @@ void BM2CMP_FRAME::OnSizeChangeX( wxCommandEvent& event )
if( m_UnitSizeX->GetValue().ToDouble( &new_size ) )
{
if( m_AspectRatioLocked )
if( m_aspectRatioCheckbox->GetValue() )
{
double calculatedY = new_size / m_AspectRatio;
@ -548,7 +565,7 @@ void BM2CMP_FRAME::OnSizeChangeY( wxCommandEvent& event )
if( m_UnitSizeY->GetValue().ToDouble( &new_size ) )
{
if( m_AspectRatioLocked )
if( m_aspectRatioCheckbox->GetValue() )
{
double calculatedX = new_size * m_AspectRatio;
@ -584,20 +601,12 @@ void BM2CMP_FRAME::OnSizeUnitChange( wxCommandEvent& event )
void BM2CMP_FRAME::ToggleAspectRatioLock( wxCommandEvent& event )
{
m_AspectRatioLocked = !m_AspectRatioLocked;
if( m_AspectRatioLocked )
if( m_aspectRatioCheckbox->GetValue() )
{
m_AspectRatioLockButton->SetBitmap( KiBitmap( BITMAPS::locked ) );
//Force display update when aspect ratio is locked
// Force display update when aspect ratio is locked
wxCommandEvent dummy;
OnSizeChangeX( dummy );
}
else
{
m_AspectRatioLockButton->SetBitmap( KiBitmap( BITMAPS::unlocked ) );
}
}
@ -623,12 +632,10 @@ void BM2CMP_FRAME::Binarize( double aThreshold )
pixout = 255;
m_NB_Image.SetRGB( x, y, pixout, pixout, pixout );
}
}
m_BN_Bitmap = wxBitmap( m_NB_Image );
}
@ -674,8 +681,6 @@ void BM2CMP_FRAME::OnThresholdChange( wxScrollEvent& event )
void BM2CMP_FRAME::OnExportToFile( wxCommandEvent& event )
{
m_exportToClipboard = false;
// 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();
@ -685,8 +690,6 @@ void BM2CMP_FRAME::OnExportToFile( wxCommandEvent& event )
void BM2CMP_FRAME::OnExportToClipboard( wxCommandEvent& event )
{
m_exportToClipboard = true;
// 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();
@ -716,26 +719,15 @@ void BM2CMP_FRAME::exportBitmap( OUTPUT_FMT_ID aFormat )
{
switch( aFormat )
{
case EESCHEMA_FMT:
exportEeschemaFormat();
break;
case PCBNEW_KICAD_MOD:
exportPcbnewFormat();
break;
case POSTSCRIPT_FMT:
exportPostScriptFormat();
break;
case KICAD_WKS_LOGO:
OnExportLogo();
break;
case EESCHEMA_FMT: exportEeschemaFormat(); break;
case PCBNEW_KICAD_MOD: exportPcbnewFormat(); break;
case POSTSCRIPT_FMT: exportPostScriptFormat(); break;
case KICAD_WKS_LOGO: exportLogo(); break;
}
}
void BM2CMP_FRAME::OnExportLogo()
void BM2CMP_FRAME::exportLogo()
{
wxFileName fn( m_ConvertedFileName );
wxString path = fn.GetPath();

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2019-2021 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019-2022 Kicad Developers, see AUTHORS.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
@ -91,12 +91,16 @@ public:
// overload KIWAY_PLAYER virtual
bool OpenProjectFiles( const std::vector<wxString>& aFilenames, int aCtl = 0 ) override;
void OnExit( wxCommandEvent& event );
void OnLoadFile( wxCommandEvent& event ) override;
DECLARE_EVENT_TABLE()
private:
// Event handlers
void OnPaintInit( wxPaintEvent& event ) override;
void OnPaintGreyscale( wxPaintEvent& event ) override;
void OnPaintBW( wxPaintEvent& event ) override;
void OnLoadFile( wxCommandEvent& event ) override;
void OnExportToFile( wxCommandEvent& event ) override;
void OnExportToClipboard( wxCommandEvent& event ) override;
@ -125,7 +129,7 @@ private:
/**
* Generate a file suitable to be copied into a drawing sheet (.kicad_wks) file
*/
void OnExportLogo();
void exportLogo();
void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level)
void OnNegativeClicked( wxCommandEvent& event ) override;
@ -137,7 +141,6 @@ private:
void ToggleAspectRatioLock( wxCommandEvent& event ) override;
void NegateGreyscaleImage();
/**
* generate a export data of the current bitmap.
@ -155,6 +158,8 @@ private:
wxWindow* GetToolCanvas() const override;
void ReCreateMenuBar() override;
private:
wxImage m_Pict_Image;
wxBitmap m_Pict_Bitmap;
@ -167,8 +172,6 @@ private:
bool m_Negative;
wxString m_BitmapFileName;
wxString m_ConvertedFileName;
bool m_exportToClipboard;
bool m_AspectRatioLocked;
double m_AspectRatio;
};
#endif// BITMOP2CMP_GUI_H_

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -17,28 +17,25 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
bMainSizer = new wxBoxSizer( wxHORIZONTAL );
m_Notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_Notebook->SetMinSize( wxSize( 500,-1 ) );
m_InitialPicturePanel = new wxScrolledWindow( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
m_InitialPicturePanel->SetScrollRate( 5, 5 );
m_InitialPicturePanel->SetMinSize( wxSize( 400,300 ) );
m_Notebook->AddPage( m_InitialPicturePanel, _("Original Picture"), true );
m_GreyscalePicturePanel = new wxScrolledWindow( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
m_GreyscalePicturePanel->SetScrollRate( 5, 5 );
m_GreyscalePicturePanel->SetMinSize( wxSize( 400,300 ) );
m_Notebook->AddPage( m_GreyscalePicturePanel, _("Greyscale Picture"), false );
m_BNPicturePanel = new wxScrolledWindow( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
m_BNPicturePanel->SetScrollRate( 5, 5 );
m_Notebook->AddPage( m_BNPicturePanel, _("Black&&White Picture"), false );
m_Notebook->AddPage( m_BNPicturePanel, _("Black && White Picture"), false );
bMainSizer->Add( m_Notebook, 1, wxEXPAND, 5 );
bMainSizer->Add( m_Notebook, 1, wxEXPAND|wxBOTTOM|wxLEFT, 5 );
m_panelRight = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* brightSizer;
brightSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbSizerInfo;
sbSizerInfo = new wxStaticBoxSizer( new wxStaticBox( m_panelRight, wxID_ANY, _("Bitmap Information") ), wxVERTICAL );
sbSizerInfo = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Image Information") ), wxVERTICAL );
wxFlexGridSizer* fgSizerInfo;
fgSizerInfo = new wxFlexGridSizer( 0, 4, 0, 0 );
@ -47,13 +44,13 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
fgSizerInfo->SetFlexibleDirection( wxBOTH );
fgSizerInfo->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticTextISize = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("Bitmap size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextISize = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("Image size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextISize->Wrap( -1 );
fgSizerInfo->Add( m_staticTextISize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_SizeXValue = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeXValue->Wrap( -1 );
fgSizerInfo->Add( m_SizeXValue, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
fgSizerInfo->Add( m_SizeXValue, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_SizeYValue = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeYValue->Wrap( -1 );
@ -63,13 +60,13 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
m_SizePixUnits->Wrap( -1 );
fgSizerInfo->Add( m_SizePixUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_staticTextDPI = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("Bitmap PPI:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDPI = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("Image PPI:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDPI->Wrap( -1 );
fgSizerInfo->Add( m_staticTextDPI, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_InputXValueDPI = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 );
m_InputXValueDPI->Wrap( -1 );
fgSizerInfo->Add( m_InputXValueDPI, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
fgSizerInfo->Add( m_InputXValueDPI, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_InputYValueDPI = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 );
m_InputYValueDPI->Wrap( -1 );
@ -85,11 +82,11 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
m_BPPValue = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 );
m_BPPValue->Wrap( -1 );
fgSizerInfo->Add( m_BPPValue, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
fgSizerInfo->Add( m_BPPValue, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_BPPunits = new wxStaticText( sbSizerInfo->GetStaticBox(), wxID_ANY, _("bits"), wxDefaultPosition, wxDefaultSize, 0 );
m_BPPunits->Wrap( -1 );
fgSizerInfo->Add( m_BPPunits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizerInfo->Add( m_BPPunits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
fgSizerInfo->Add( 0, 0, 0, 0, 5 );
@ -100,28 +97,24 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
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( 0, 10, 1, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerImgPrms;
sbSizerImgPrms = new wxStaticBoxSizer( new wxStaticBox( m_panelRight, wxID_ANY, _("Output Parameters") ), wxVERTICAL );
sbSizerImgPrms = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Output Size") ), wxVERTICAL );
wxBoxSizer* bSizerLock;
bSizerLock = new wxBoxSizer( wxHORIZONTAL );
m_textLock = new wxStaticText( sbSizerImgPrms->GetStaticBox(), wxID_ANY, _("Lock height/width ratio"), wxDefaultPosition, wxDefaultSize, 0 );
m_textLock->Wrap( -1 );
bSizerLock->Add( m_textLock, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_AspectRatioLockButton = new wxBitmapButton( sbSizerImgPrms->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bSizerLock->Add( m_AspectRatioLockButton, 0, wxALL, 5 );
sbSizerImgPrms->Add( bSizerLock, 0, wxEXPAND, 5 );
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|wxALL, 5 );
bSizerRes->Add( m_staticTextOSize, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_UnitSizeX = new wxTextCtrl( sbSizerImgPrms->GetStaticBox(), wxID_ANY, _("300"), wxDefaultPosition, wxDefaultSize, 0 );
m_UnitSizeX->SetMinSize( wxSize( 60,-1 ) );
@ -138,60 +131,54 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
m_PixelUnit->SetSelection( 0 );
m_PixelUnit->SetMinSize( wxSize( 80,-1 ) );
bSizerRes->Add( m_PixelUnit, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
bSizerRes->Add( m_PixelUnit, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 );
sbSizerImgPrms->Add( bSizerRes, 0, wxEXPAND, 5 );
brightSizer->Add( sbSizerImgPrms, 0, wxEXPAND|wxALL, 5 );
m_buttonLoad = new wxButton( m_panelRight, wxID_ANY, _("Load Bitmap"), wxDefaultPosition, wxDefaultSize, 0 );
brightSizer->Add( m_buttonLoad, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_buttonExportFile = new wxButton( m_panelRight, wxID_ANY, _("Export to File"), wxDefaultPosition, wxDefaultSize, 0 );
brightSizer->Add( m_buttonExportFile, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_buttonExportClipboard = new wxButton( m_panelRight, wxID_ANY, _("Export to Clipboard"), wxDefaultPosition, wxDefaultSize, 0 );
brightSizer->Add( m_buttonExportClipboard, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 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( m_panelRight, 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 );
brightSizer->Add( sbSizerImgPrms, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer2;
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( m_panelRight, wxID_ANY, _("Image Options") ), wxVERTICAL );
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL );
m_ThresholdText = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Black / White Threshold:"), wxDefaultPosition, wxDefaultSize, 0 );
m_ThresholdText = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Black / white threshold:"), wxDefaultPosition, wxDefaultSize, 0 );
m_ThresholdText->Wrap( -1 );
sbSizer2->Add( m_ThresholdText, 0, wxTOP|wxLEFT, 5 );
sbSizer2->Add( m_ThresholdText, 0, 0, 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.") );
sbSizer2->Add( m_sliderThreshold, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbSizer2->Add( m_sliderThreshold, 0, wxEXPAND|wxBOTTOM, 5 );
m_checkNegative = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Negative"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizer2->Add( m_checkNegative, 0, wxTOP|wxBOTTOM, 10 );
sbSizer2->Add( m_checkNegative, 0, wxTOP|wxBOTTOM, 5 );
brightSizer->Add( sbSizer2, 0, wxALL|wxEXPAND, 5 );
wxString m_rbPCBLayerChoices[] = { _("Front silk screen"), _("Front solder mask"), _("User layer Eco1"), _("User layer Eco2") };
int m_rbPCBLayerNChoices = sizeof( m_rbPCBLayerChoices ) / sizeof( wxString );
m_rbPCBLayer = new wxRadioBox( m_panelRight, wxID_ANY, _("Board Layer for Outline"), wxDefaultPosition, wxDefaultSize, m_rbPCBLayerNChoices, m_rbPCBLayerChoices, 1, wxRA_SPECIFY_COLS );
m_rbPCBLayer = new wxRadioBox( this, wxID_ANY, _("Board Layer for Outline"), wxDefaultPosition, wxDefaultSize, m_rbPCBLayerNChoices, m_rbPCBLayerChoices, 1, wxRA_SPECIFY_COLS );
m_rbPCBLayer->SetSelection( 1 );
m_rbPCBLayer->SetToolTip( _("Choose the board layer to place the outline.\nThe reference designator and value are always placed on the silk screen layer (but will be marked invisible).") );
brightSizer->Add( m_rbPCBLayer, 0, wxALL|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_panelRight->SetSizer( brightSizer );
m_panelRight->Layout();
brightSizer->Fit( m_panelRight );
bMainSizer->Add( m_panelRight, 0, wxEXPAND, 0 );
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 );
brightSizer->Add( m_buttonExportClipboard, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( brightSizer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
this->SetSizer( bMainSizer );
@ -203,17 +190,17 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
m_InitialPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintInit ), NULL, this );
m_GreyscalePicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintGreyscale ), NULL, this );
m_BNPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintBW ), NULL, this );
m_AspectRatioLockButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::ToggleAspectRatioLock ), NULL, this );
m_buttonLoad->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this );
m_aspectRatioCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::ToggleAspectRatioLock ), NULL, this );
m_UnitSizeX->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeChangeX ), NULL, this );
m_UnitSizeY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeChangeY ), NULL, this );
m_PixelUnit->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeUnitChange ), NULL, this );
m_buttonLoad->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this );
m_buttonExportFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToFile ), NULL, this );
m_buttonExportClipboard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToClipboard ), NULL, this );
m_rbOutputFormat->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnFormatChange ), NULL, this );
m_sliderThreshold->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this );
m_sliderThreshold->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this );
m_checkNegative->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnNegativeClicked ), NULL, this );
m_rbOutputFormat->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnFormatChange ), NULL, this );
m_buttonExportFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToFile ), NULL, this );
m_buttonExportClipboard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToClipboard ), NULL, this );
}
BM2CMP_FRAME_BASE::~BM2CMP_FRAME_BASE()
@ -222,16 +209,16 @@ BM2CMP_FRAME_BASE::~BM2CMP_FRAME_BASE()
m_InitialPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintInit ), NULL, this );
m_GreyscalePicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintGreyscale ), NULL, this );
m_BNPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaintBW ), NULL, this );
m_AspectRatioLockButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::ToggleAspectRatioLock ), NULL, this );
m_buttonLoad->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this );
m_aspectRatioCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::ToggleAspectRatioLock ), NULL, this );
m_UnitSizeX->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeChangeX ), NULL, this );
m_UnitSizeY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeChangeY ), NULL, this );
m_PixelUnit->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnSizeUnitChange ), NULL, this );
m_buttonLoad->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this );
m_buttonExportFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToFile ), NULL, this );
m_buttonExportClipboard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToClipboard ), NULL, this );
m_rbOutputFormat->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnFormatChange ), NULL, this );
m_sliderThreshold->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this );
m_sliderThreshold->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this );
m_checkNegative->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnNegativeClicked ), NULL, this );
m_rbOutputFormat->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnFormatChange ), NULL, this );
m_buttonExportFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToFile ), NULL, this );
m_buttonExportClipboard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportToClipboard ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -24,15 +24,13 @@
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/checkbox.h>
#include <wx/textctrl.h>
#include <wx/valtext.h>
#include <wx/choice.h>
#include <wx/radiobox.h>
#include <wx/slider.h>
#include <wx/checkbox.h>
#include <wx/panel.h>
#include <wx/radiobox.h>
#include <wx/statusbr.h>
#include <wx/frame.h>
@ -51,7 +49,6 @@ class BM2CMP_FRAME_BASE : public KIWAY_PLAYER
wxScrolledWindow* m_InitialPicturePanel;
wxScrolledWindow* m_GreyscalePicturePanel;
wxScrolledWindow* m_BNPicturePanel;
wxPanel* m_panelRight;
wxStaticText* m_staticTextISize;
wxStaticText* m_SizeXValue;
wxStaticText* m_SizeYValue;
@ -63,41 +60,40 @@ class BM2CMP_FRAME_BASE : public KIWAY_PLAYER
wxStaticText* m_staticTextBPP;
wxStaticText* m_BPPValue;
wxStaticText* m_BPPunits;
wxStaticText* m_textLock;
wxBitmapButton* m_AspectRatioLockButton;
wxButton* m_buttonLoad;
wxCheckBox* m_aspectRatioCheckbox;
wxStaticText* m_staticTextOSize;
wxTextCtrl* m_UnitSizeX;
wxTextCtrl* m_UnitSizeY;
wxChoice* m_PixelUnit;
wxButton* m_buttonLoad;
wxButton* m_buttonExportFile;
wxButton* m_buttonExportClipboard;
wxRadioBox* m_rbOutputFormat;
wxStaticText* m_ThresholdText;
wxSlider* m_sliderThreshold;
wxCheckBox* m_checkNegative;
wxRadioBox* m_rbPCBLayer;
wxRadioBox* m_rbOutputFormat;
wxButton* m_buttonExportFile;
wxButton* m_buttonExportClipboard;
wxStatusBar* m_statusBar;
// Virtual event handlers, override them in your derived class
virtual void OnPaintInit( wxPaintEvent& event ) { event.Skip(); }
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 OnLoadFile( wxCommandEvent& event ) { event.Skip(); }
virtual void OnExportToFile( wxCommandEvent& event ) { event.Skip(); }
virtual void OnExportToClipboard( wxCommandEvent& event ) { event.Skip(); }
virtual void OnFormatChange( 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(); }
virtual void OnExportToFile( wxCommandEvent& event ) { event.Skip(); }
virtual void OnExportToClipboard( wxCommandEvent& 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( -1,-1 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Image Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCLOSE_BOX|wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
~BM2CMP_FRAME_BASE();