Commit 0e4bb20e authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Minor dialog and footprint ID class fixes.

* Make Pcbnew net list dialog honor escape key on Linux.
* Make Pcbnew swap layers dialog honor escape key on Linux.
* Layout and UI policy fixes for Pcbnew swap layer and net list dialogs.
* Layout and UI policy fixes for Eeschema plot dialog.
* Rename fpip.h to fpid.h.
* Fix FPID class compiler errors.
* Restore fpid.cpp to Pcbnew static library source list.
parent 74540cb4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ set(PCB_COMMON_SRCS
    pcb_keywords.cpp
    ../pcbnew/pcb_parser.cpp
    fp_lib_table_keywords.cpp
#    fpid.cpp
    fpid.cpp
    fp_lib_table.cpp
)

+30 −16
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
 */

#include <cstring>
#include <memory>
#include <wx/wx.h>      // _()

#include <fpid.h>
@@ -95,7 +96,7 @@ static int okRevision( const std::string& aField )
        strcpy( rev, "x/" );
        strcat( rev, aField.c_str() );

        if( EndsWithRev( rev, rev + strlen(rev) ) == rev+2 )
        if( EndsWithRev( rev, rev + strlen(rev), '/' ) == rev+2 )
            return -1;    // success
    }

@@ -108,8 +109,8 @@ static int okRevision( const std::string& aField )

void FPID::clear()
{
    logical.clear();
    footprintName.clear();
    nickname.clear();
    footprint.clear();
    revision.clear();
}

@@ -118,7 +119,12 @@ int FPID::Parse( const std::string& aId )
{
    clear();

    const char* rev = EndsWithRev( aId );
    size_t      cnt = aId.length() + 1;
    char        tmp[cnt];  // C string for speed

    std::strcpy( tmp, aId.c_str() );

    const char* rev = EndsWithRev( tmp, tmp+aId.length(), '/' );
    size_t      revNdx;
    size_t      partNdx;
    int         offset;
@@ -137,10 +143,10 @@ int FPID::Parse( const std::string& aId )
        revNdx = aId.size();
    }

    //=====<logical>==========================================
    //=====<nickname>==========================================
    if( ( partNdx = aId.find( ':' ) ) != aId.npos )
    {
        offset = SetLogicalLib( aId.substr( 0, partNdx ) );
        offset = SetLibNickname( aId.substr( 0, partNdx ) );

        if( offset > -1 )
        {
@@ -154,6 +160,12 @@ int FPID::Parse( const std::string& aId )
        partNdx = 0;
    }

    //=====<footprint name>====================================
    if( partNdx >= revNdx )
        return partNdx;

    SetFootprintName( aId.substr( partNdx, revNdx ) );

    return -1;
}

@@ -173,13 +185,13 @@ FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
}


int FPID::SetLogicalLib( const std::string& aLogical )
int FPID::SetLibNickname( const std::string& aLogical )
{
    int offset = okLogical( aLogical );

    if( offset == -1 )
    {
        logical = aLogical;
        nickname = aLogical;
    }

    return offset;
@@ -192,12 +204,12 @@ int FPID::SetFootprintName( const std::string& aFootprintName )

    if( separation != -1 )
    {
        logical = aFootprintName.substr( separation+1 );
        return separation + (int) logical.size() + 1;
        nickname = aFootprintName.substr( separation+1 );
        return separation + (int) nickname.size() + 1;
    }
    else
    {
        footprintName = aFootprintName;
        footprint = aFootprintName;
    }

    return -1;
@@ -221,12 +233,14 @@ std::string FPID::Format() const
{
    std::string  ret;

    if( logical.size() )
    if( nickname.size() )
    {
        ret += logical;
        ret += nickname;
        ret += ':';
    }

    ret += footprint;

    if( revision.size() )
    {
        ret += '/';
@@ -315,10 +329,10 @@ void FPID::Test()
        FPID lpid( lpids[i] );  // parse

        // format
        printf( "input:'%s'  full:'%s'  logical: %s  footprintName:'%s' rev:'%s'\n",
        printf( "input:'%s'  full:'%s'  nickname: %s  footprint:'%s' rev:'%s'\n",
                lpids[i],
                lpid.Format().c_str(),
                lpid.GetLogicalLib().c_str(),
                lpid.GetLibNickname().c_str(),
                lpid.GetFootprintName().c_str(),
                lpid.GetRevision().c_str() );
    }
+85 −77
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
// static members (static to remember last state):
int DIALOG_PLOT_SCHEMATIC::m_pageSizeSelect = PAGE_SIZE_AUTO;


void SCH_EDIT_FRAME::PlotSchematic( wxCommandEvent& event )
{
    DIALOG_PLOT_SCHEMATIC dlg( this );
@@ -72,6 +73,7 @@ DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent ) :
}



// Initialize the dialog options:
void DIALOG_PLOT_SCHEMATIC::initDlg()
{
@@ -103,6 +105,7 @@ void DIALOG_PLOT_SCHEMATIC::initDlg()
    // Switch to the last save plot format
    long plotfmt;
    m_config->Read( PLOT_FORMAT_KEY, &plotfmt, 0 );

    switch( plotfmt )
    {
    default:
@@ -142,6 +145,7 @@ void DIALOG_PLOT_SCHEMATIC::initDlg()
    OnPlotFormatSelection( cmd_event );
}


PlotFormat DIALOG_PLOT_SCHEMATIC::GetPlotFileFormat()
{
    switch( m_plotFormatOpt->GetSelection() )
@@ -159,7 +163,7 @@ PlotFormat DIALOG_PLOT_SCHEMATIC::GetPlotFileFormat()
void DIALOG_PLOT_SCHEMATIC::OnButtonCancelClick( wxCommandEvent& event )
{
    getPlotOptions();
    EndModal( 0 );
    EndModal( wxID_CANCEL );
}


@@ -178,6 +182,7 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions()
    SetDefaultLineThickness( ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl ) );
}


void DIALOG_PLOT_SCHEMATIC::OnPlotFormatSelection( wxCommandEvent& event )
{

@@ -235,9 +240,11 @@ void DIALOG_PLOT_SCHEMATIC::OnButtonPlotAllClick( wxCommandEvent& event )
    PlotSchematic( true );
}


void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll )
{
    getPlotOptions();

    switch( GetPlotFileFormat() )
    {
    case PLOT_FORMAT_HPGL:
@@ -245,6 +252,7 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll )
        break;

    default:
        // Fall through.  Default to Postscript.
    case PLOT_FORMAT_POST:
        createPSFile( aPlotAll, getPlotFrameRef() );
        break;
@@ -261,6 +269,6 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll )
        createSVGFile( aPlotAll, getPlotFrameRef() );
        break;
    }

    m_MessagesBox->AppendText( wxT( "****\n" ) );
}
+35 −31
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Oct  8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -22,13 +22,13 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind
	
	wxString m_PaperSizeOptionChoices[] = { _("Schematic size"), _("Force size A4"), _("Force size A") };
	int m_PaperSizeOptionNChoices = sizeof( m_PaperSizeOptionChoices ) / sizeof( wxString );
	m_PaperSizeOption = new wxRadioBox( this, wxID_ANY, _("Plot Page Size:"), wxDefaultPosition, wxDefaultSize, m_PaperSizeOptionNChoices, m_PaperSizeOptionChoices, 1, wxRA_SPECIFY_COLS );
	m_PaperSizeOption = new wxRadioBox( this, wxID_ANY, _("Page Size:"), wxDefaultPosition, wxDefaultSize, m_PaperSizeOptionNChoices, m_PaperSizeOptionChoices, 1, wxRA_SPECIFY_COLS );
	m_PaperSizeOption->SetSelection( 0 );
	m_paperOptionsSizer->Add( m_PaperSizeOption, 0, wxALL|wxEXPAND, 5 );
	
	m_paperHPGLSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("HPGL Options:") ), wxVERTICAL );
	m_paperHPGLSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("HPGL Options") ), wxVERTICAL );
	
	m_staticText4 = new wxStaticText( this, wxID_ANY, _("Plot Page Size:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText4 = new wxStaticText( this, wxID_ANY, _("Page Size:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText4->Wrap( -1 );
	m_paperHPGLSizer->Add( m_staticText4, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	
@@ -40,95 +40,99 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind
	
	wxString m_plotOriginOptChoices[] = { _("Bottom left corner"), _("Center of the page") };
	int m_plotOriginOptNChoices = sizeof( m_plotOriginOptChoices ) / sizeof( wxString );
	m_plotOriginOpt = new wxRadioBox( this, wxID_ANY, _("Plot Origin:"), wxDefaultPosition, wxDefaultSize, m_plotOriginOptNChoices, m_plotOriginOptChoices, 1, wxRA_SPECIFY_COLS );
	m_plotOriginOpt = new wxRadioBox( this, wxID_ANY, _("Origin"), wxDefaultPosition, wxDefaultSize, m_plotOriginOptNChoices, m_plotOriginOptChoices, 1, wxRA_SPECIFY_COLS );
	m_plotOriginOpt->SetSelection( 0 );
	m_paperHPGLSizer->Add( m_plotOriginOpt, 0, wxALL, 5 );
	
	m_penHPLGWidthTitle = new wxStaticText( this, wxID_ANY, _("Pen Width"), wxDefaultPosition, wxDefaultSize, 0 );
	m_penHPLGWidthTitle = new wxStaticText( this, wxID_ANY, _("Pen Width:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_penHPLGWidthTitle->Wrap( -1 );
	m_paperHPGLSizer->Add( m_penHPLGWidthTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	
	m_penHPGLWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_penHPGLWidthCtrl->SetMaxLength( 0 ); 
	m_paperHPGLSizer->Add( m_penHPGLWidthCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
	
	
	m_paperOptionsSizer->Add( m_paperHPGLSizer, 1, wxEXPAND, 5 );
	
	
	m_optionsSizer->Add( m_paperOptionsSizer, 1, wxEXPAND, 5 );
	
	wxStaticBoxSizer* sbSizerPlotFormat;
	sbSizerPlotFormat = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General options") ), wxVERTICAL );
	m_optionsSizer->Add( m_paperOptionsSizer, 0, wxEXPAND, 5 );
	
	wxString m_plotFormatOptChoices[] = { _("Postscript"), _("PDF"), _("SVG"), _("DXF"), _("HPGL") };
	int m_plotFormatOptNChoices = sizeof( m_plotFormatOptChoices ) / sizeof( wxString );
	m_plotFormatOpt = new wxRadioBox( this, wxID_ANY, _("Plot format:"), wxDefaultPosition, wxDefaultSize, m_plotFormatOptNChoices, m_plotFormatOptChoices, 1, wxRA_SPECIFY_COLS );
	m_plotFormatOpt = new wxRadioBox( this, wxID_ANY, _("Format"), wxDefaultPosition, wxDefaultSize, m_plotFormatOptNChoices, m_plotFormatOptChoices, 1, wxRA_SPECIFY_COLS );
	m_plotFormatOpt->SetSelection( 0 );
	sbSizerPlotFormat->Add( m_plotFormatOpt, 0, wxALL|wxEXPAND, 5 );
	
	
	m_optionsSizer->Add( sbSizerPlotFormat, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
	m_optionsSizer->Add( m_plotFormatOpt, 0, wxEXPAND|wxLEFT, 5 );
	
	wxStaticBoxSizer* sbOptionsSizer;
	sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Plot options:") ), wxVERTICAL );
	wxStaticBoxSizer* sbSizerPlotFormat;
	sbSizerPlotFormat = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General Options") ), wxVERTICAL );
	
	m_defaultLineWidthTitle = new wxStaticText( this, wxID_ANY, _("Default Thickness"), wxDefaultPosition, wxDefaultSize, 0 );
	m_defaultLineWidthTitle = new wxStaticText( this, wxID_ANY, _("Default Line Thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_defaultLineWidthTitle->Wrap( -1 );
	sbOptionsSizer->Add( m_defaultLineWidthTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	sbSizerPlotFormat->Add( m_defaultLineWidthTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	
	m_DefaultLineSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
	m_DefaultLineSizeCtrl->SetMaxLength( 0 ); 
	m_DefaultLineSizeCtrl->SetToolTip( _("Selection of the default pen thickness used to draw items, when their thickness is set to 0.") );
	
	sbOptionsSizer->Add( m_DefaultLineSizeCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
	sbSizerPlotFormat->Add( m_DefaultLineSizeCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
	
	wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") };
	int m_ModeColorOptionNChoices = sizeof( m_ModeColorOptionChoices ) / sizeof( wxString );
	m_ModeColorOption = new wxRadioBox( this, wxID_ANY, _("Plot mode"), wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 1, wxRA_SPECIFY_COLS );
	m_ModeColorOption = new wxRadioBox( this, wxID_ANY, _("Mode"), wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 1, wxRA_SPECIFY_COLS );
	m_ModeColorOption->SetSelection( 1 );
	m_ModeColorOption->SetToolTip( _("Choose if you want to draw the sheet like it appears on screen,\nor in black and white mode, better to print it when using  black and white printers") );
	
	sbOptionsSizer->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 );
	sbSizerPlotFormat->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 );
	
	m_PlotFrameRefOpt = new wxCheckBox( this, wxID_ANY, _("Plot frame ref"), wxDefaultPosition, wxDefaultSize, 0 );
	m_PlotFrameRefOpt = new wxCheckBox( this, wxID_ANY, _("Plot border and title block"), wxDefaultPosition, wxDefaultSize, 0 );
	m_PlotFrameRefOpt->SetValue(true); 
	m_PlotFrameRefOpt->SetToolTip( _("Print (or not) the Frame references.") );
	
	sbOptionsSizer->Add( m_PlotFrameRefOpt, 0, wxALL, 5 );
	sbSizerPlotFormat->Add( m_PlotFrameRefOpt, 0, wxALL, 5 );
	
	
	m_optionsSizer->Add( sbOptionsSizer, 1, 0, 5 );
	m_optionsSizer->Add( sbSizerPlotFormat, 0, wxEXPAND|wxLEFT, 5 );
	
	m_ButtonsSizer = new wxBoxSizer( wxVERTICAL );
	
	m_buttonPlotCurrent = new wxButton( this, wxID_PRINT_CURRENT, _("Plot Current"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonPlotCurrent = new wxButton( this, wxID_PRINT_CURRENT, _("Plot Current Page"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonPlotCurrent->SetDefault(); 
	m_ButtonsSizer->Add( m_buttonPlotCurrent, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
	
	m_buttonPlotAll = new wxButton( this, wxID_PRINT_ALL, _("Plot All"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonPlotAll = new wxButton( this, wxID_PRINT_ALL, _("Plot All Pages"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonPlotAll->SetDefault(); 
	m_ButtonsSizer->Add( m_buttonPlotAll, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
	
	m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Quit"), wxDefaultPosition, wxDefaultSize, 0 );
	m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
	m_ButtonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
	
	
	m_optionsSizer->Add( m_ButtonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
	
	
	bMainSizer->Add( m_optionsSizer, 0, wxEXPAND, 5 );
	bMainSizer->Add( m_optionsSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
	
	wxBoxSizer* bSizer4;
	bSizer4 = new wxBoxSizer( wxVERTICAL );
	
	m_staticText2 = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText2->Wrap( -1 );
	bMainSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	bSizer4->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
	
	m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
	m_MessagesBox->SetMaxLength( 0 ); 
	m_MessagesBox->SetMinSize( wxSize( -1,80 ) );
	
	bMainSizer->Add( m_MessagesBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
	bSizer4->Add( m_MessagesBox, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
	
	
	bMainSizer->Add( bSizer4, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
	
	
	this->SetSizer( bMainSizer );
	this->Layout();
	bMainSizer->Fit( this );
	
	// Connect Events
	this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnCloseWindow ) );
Loading