Commit 428ecb53 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

dialog_edit_component_in_schematic: moved "Reset to Library Default" Button....

dialog_edit_component_in_schematic: moved "Reset to Library Default" Button. This command is now undoable.
Fixed bug 603481
parents ce0eec89 0d530fb3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ if(WIN32)
        set(BITMAP2COMPONENT_RESOURCES bitmap2component.rc)
    endif(MINGW)
endif(WIN32)

add_executable(bitmap2component WIN32 MACOSX_BUNDLE
                            ${BITMAP2COMPONENT_SRCS}
                            ${BITMAP2COMPONENT_RESOURCES})
@@ -28,6 +29,6 @@ target_link_libraries( bitmap2component
                        kbool )

install(TARGETS bitmap2component
        DESTINATION ${KICAD_PLUGINS}
        DESTINATION ${KICAD_BIN}
        COMPONENT binary)
+28 −18
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ private:
    // Event handlers
    void OnPaint( wxPaintEvent& event );
    void OnLoadFile( wxCommandEvent& event );
    bool LoadFile( wxString& aFullFileName );
    void OnExportEeschema( wxCommandEvent& event );
    void OnExportPcbnew( wxCommandEvent& event );
    void Binarize( double aThreshold );     // aThreshold = 0.0 (black level) to 1.0 (white level)
@@ -94,16 +95,13 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL )
    SetIcon( wxICON( bitmap2component ) );
    #endif

    wxString msg( wxT( "000000" ) );
    m_gridInfo->SetCellValue( 0, 0, msg );
    m_gridInfo->SetCellValue( 1, 0, msg );
    if( GetSizer() )
    {
    GetSizer()->SetSizeHints( this );
    }

    SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );

	m_buttonExportEeschema->Enable( false );
	m_buttonExportPcbnew->Enable( false );

    if ( m_FramePos == wxDefaultPosition )
        Centre();
}
@@ -162,13 +160,24 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event )

    if( diag != wxID_OK )
        return;
    wxString fullFilename = FileDlg.GetPath();
    if( ! LoadFile( fullFilename ) )
        return;

    m_BitmapFileName = FileDlg.GetPath();
	m_buttonExportEeschema->Enable( true );
	m_buttonExportPcbnew->Enable( true );
    SetStatusText( fullFilename );
    Refresh();
}

bool BM2CMP_FRAME::LoadFile( wxString& aFullFileName )
{
    m_BitmapFileName = aFullFileName;

    if( !m_Pict_Image.LoadFile( m_BitmapFileName ) )
    {
        wxMessageBox( _( "Couldn't load image from <%s>" ), m_BitmapFileName.c_str() );
        return;
        return false;
    }

    m_Pict_Bitmap = wxBitmap( m_Pict_Image );
@@ -178,12 +187,12 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event )
    int nb = m_Pict_Bitmap.GetDepth();

    wxString msg;
    msg.Printf( wxT( "%d" ), h );
    m_gridInfo->SetCellValue( 0, 0, msg );
    msg.Printf( wxT( "%d" ), w );
    m_gridInfo->SetCellValue( 1, 0, msg );
    m_SizeXValue->SetLabel(msg);
    msg.Printf( wxT( "%d" ), h );
    m_SizeYValue->SetLabel(msg);
    msg.Printf( wxT( "%d" ), nb );
    m_gridInfo->SetCellValue( 2, 0, msg );
    m_BPPValue->SetLabel(msg);

    m_InitialPicturePanel->SetVirtualSize( w, h );
    m_GreyscalePicturePanel->SetVirtualSize( w, h );
@@ -197,9 +206,9 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event )

    m_NB_Image  = m_Greyscale_Image;
    Binarize( (double)m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() );
    Refresh();
}

    return true;
}

void BM2CMP_FRAME::Binarize( double aThreshold )
{
@@ -261,7 +270,7 @@ void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event )
    if( path.IsEmpty() || !wxDirExists(path) )
        path = ::wxGetCwd();
    wxString     msg = _( "Schematic lib file (*.lib)|*.lib" );
    wxFileDialog FileDlg( this, _( "Create lib file" ), path, wxEmptyString,
    wxFileDialog FileDlg( this, _( "Create a lib file for Eeschema" ), path, wxEmptyString,
                          msg,
                          wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
    int          diag = FileDlg.ShowModal();
@@ -291,8 +300,9 @@ void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event )
    wxString path = fn.GetPath();
    if( path.IsEmpty() || !wxDirExists(path) )
        path = ::wxGetCwd();
    wxString     msg = _( "Footprint export file (*.emp)|*.emp" );
    wxFileDialog FileDlg( this, _( "Create footprint export file" ), path, wxEmptyString,
    wxString     msg = _( "Footprint file (*.mod)|*.mod" );
    wxFileDialog FileDlg( this, _( "Create a footprint file for PcbNew" ),
                          path, wxEmptyString,
                          msg,
                          wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
    int          diag = FileDlg.ShowModal();
+52 −31
Original line number Diff line number Diff line
@@ -36,45 +36,65 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
	wxBoxSizer* brightSizer;
	brightSizer = new wxBoxSizer( wxVERTICAL );
	
	m_gridInfo = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
	
	// Grid
	m_gridInfo->CreateGrid( 3, 1 );
	m_gridInfo->EnableEditing( false );
	m_gridInfo->EnableGridLines( true );
	m_gridInfo->EnableDragGridSize( false );
	m_gridInfo->SetMargins( 0, 0 );
	
	// Columns
	m_gridInfo->SetColSize( 0, 80 );
	m_gridInfo->EnableDragColMove( false );
	m_gridInfo->EnableDragColSize( true );
	m_gridInfo->SetColLabelSize( 30 );
	m_gridInfo->SetColLabelValue( 0, _("Value") );
	m_gridInfo->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
	
	// Rows
	m_gridInfo->AutoSizeRows();
	m_gridInfo->EnableDragRowSize( true );
	m_gridInfo->SetRowLabelSize( 80 );
	m_gridInfo->SetRowLabelValue( 0, _("Size X") );
	m_gridInfo->SetRowLabelValue( 1, _("Size Y") );
	m_gridInfo->SetRowLabelValue( 2, _("BPP") );
	m_gridInfo->SetRowLabelAlignment( wxALIGN_RIGHT, wxALIGN_CENTRE );
	
	// Label Appearance
	
	// Cell Defaults
	m_gridInfo->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
	brightSizer->Add( m_gridInfo, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
	wxStaticBoxSizer* sbSizerInfo;
	sbSizerInfo = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Bitmap info:") ), wxVERTICAL );
	
	wxFlexGridSizer* fgSizerInfo;
	fgSizerInfo = new wxFlexGridSizer( 3, 3, 0, 0 );
	fgSizerInfo->SetFlexibleDirection( wxBOTH );
	fgSizerInfo->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	
	m_staticTextSizeX = new wxStaticText( this, wxID_ANY, _("Size X:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticTextSizeX->Wrap( -1 );
	fgSizerInfo->Add( m_staticTextSizeX, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	m_SizeXValue = new wxStaticText( this, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 );
	m_SizeXValue->Wrap( -1 );
	fgSizerInfo->Add( m_SizeXValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	m_SizeXunits = new wxStaticText( this, wxID_ANY, _("pixels"), wxDefaultPosition, wxDefaultSize, 0 );
	m_SizeXunits->Wrap( -1 );
	fgSizerInfo->Add( m_SizeXunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	m_staticTextSizeY = new wxStaticText( this, wxID_ANY, _("Size Y:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticTextSizeY->Wrap( -1 );
	fgSizerInfo->Add( m_staticTextSizeY, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	m_SizeYValue = new wxStaticText( this, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 );
	m_SizeYValue->Wrap( -1 );
	fgSizerInfo->Add( m_SizeYValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	m_SizeYunits = new wxStaticText( this, wxID_ANY, _("pixels"), wxDefaultPosition, wxDefaultSize, 0 );
	m_SizeYunits->Wrap( -1 );
	fgSizerInfo->Add( m_SizeYunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	m_staticTextBPP = new wxStaticText( this, wxID_ANY, _("BPP:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticTextBPP->Wrap( -1 );
	fgSizerInfo->Add( m_staticTextBPP, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	m_BPPValue = new wxStaticText( this, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 );
	m_BPPValue->Wrap( -1 );
	fgSizerInfo->Add( m_BPPValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	m_BPPunits = new wxStaticText( this, wxID_ANY, _("bits"), wxDefaultPosition, wxDefaultSize, 0 );
	m_BPPunits->Wrap( -1 );
	fgSizerInfo->Add( m_BPPunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	
	sbSizerInfo->Add( fgSizerInfo, 0, wxEXPAND|wxBOTTOM, 5 );
	
	brightSizer->Add( sbSizerInfo, 0, wxEXPAND|wxALL, 5 );
	
	m_buttonLoad = new wxButton( this, wxID_ANY, _("Load Bitmap"), wxDefaultPosition, wxDefaultSize, 0 );
	brightSizer->Add( m_buttonLoad, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
	
	m_buttonExportEeschema = new wxButton( this, wxID_ANY, _("Export to eeschema"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonExportEeschema->SetToolTip( _("Create a lib file for Eeschema") );
	
	brightSizer->Add( m_buttonExportEeschema, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
	
	m_buttonExportPcbnew = new wxButton( this, wxID_ANY, _("Export to Pcbnew"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonExportPcbnew->SetToolTip( _("Create a footprint file for PcbNew") );
	
	brightSizer->Add( m_buttonExportPcbnew, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
	
	wxString m_rbOptionsChoices[] = { _("Normal"), _("Negative") };
@@ -94,6 +114,7 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS
	
	this->SetSizer( bMainSizer );
	this->Layout();
	m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
	
	// Connect Events
	m_InitialPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this );
+530 −105

File changed.

Preview size limit exceeded, changes collapsed.

+14 −4
Original line number Diff line number Diff line
@@ -20,12 +20,13 @@
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/notebook.h>
#include <wx/grid.h>
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/button.h>
#include <wx/radiobox.h>
#include <wx/stattext.h>
#include <wx/slider.h>
#include <wx/sizer.h>
#include <wx/statusbr.h>
#include <wx/frame.h>

///////////////////////////////////////////////////////////////////////////
@@ -43,13 +44,22 @@ class BM2CMP_FRAME_BASE : public wxFrame
		wxScrolledWindow* m_InitialPicturePanel;
		wxScrolledWindow* m_GreyscalePicturePanel;
		wxScrolledWindow* m_BNPicturePanel;
		wxGrid* m_gridInfo;
		wxStaticText* m_staticTextSizeX;
		wxStaticText* m_SizeXValue;
		wxStaticText* m_SizeXunits;
		wxStaticText* m_staticTextSizeY;
		wxStaticText* m_SizeYValue;
		wxStaticText* m_SizeYunits;
		wxStaticText* m_staticTextBPP;
		wxStaticText* m_BPPValue;
		wxStaticText* m_BPPunits;
		wxButton* m_buttonLoad;
		wxButton* m_buttonExportEeschema;
		wxButton* m_buttonExportPcbnew;
		wxRadioBox* m_rbOptions;
		wxStaticText* m_ThresholdText;
		wxSlider* m_sliderThreshold;
		wxStatusBar* m_statusBar;
		
		// Virtual event handlers, overide them in your derived class
		virtual void OnPaint( wxPaintEvent& event ){ event.Skip(); }
Loading