diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 93a05ac8ef..d4ed48a180 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -214,6 +214,7 @@ set( COMMON_WIDGET_SRCS widgets/widget_hotkey_list.cpp widgets/wx_busy_indicator.cpp widgets/wx_grid.cpp + widgets/wx_angle_text.cpp ) set( COMMON_PAGE_LAYOUT_SRCS diff --git a/common/widgets/wx_angle_text.cpp b/common/widgets/wx_angle_text.cpp new file mode 100644 index 0000000000..625bdbafd3 --- /dev/null +++ b/common/widgets/wx_angle_text.cpp @@ -0,0 +1,77 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2020 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include + +WX_ANGLE_TEXT::WX_ANGLE_TEXT( wxWindow* aParent, wxWindowID aId, const wxString& aLabel, + const wxPoint& aPos, double aAngle ) : + wxPanel( aParent, aId, aPos, wxDefaultSize ), + m_label( aLabel ), + m_angle( aAngle ) +{ + wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); + font.SetPointSize( font.GetPointSize() + 2 ); // rotated text looks visually smaller + SetFont( font ); + + wxPoint pos = GetPosition(); + wxSize size = GetTextExtent( m_label ); + EDA_RECT rect( wxPoint( 0, 0 ), size ); + EDA_RECT bbox = rect.GetBoundingBoxRotated( rect.GetPosition(), m_angle ); + + pos.y += bbox.GetTop() + ( rect.GetBottom() - bbox.GetBottom() ); + size.y = bbox.GetHeight(); + size.x = bbox.GetWidth(); + + Move( pos ); + SetSize( size ); + + Bind( wxEVT_ERASE_BACKGROUND, &WX_ANGLE_TEXT::OnEraseBackground, this ); + Bind( wxEVT_PAINT, &WX_ANGLE_TEXT::OnPaint, this ); +} + + +void WX_ANGLE_TEXT::OnEraseBackground( wxEraseEvent& WXUNUSED( aEvent ) ) +{ + // NOP so that we don't erase other labels which intersect +} + + +void WX_ANGLE_TEXT::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) ) +{ + wxPaintDC dc( this ); + + dc.SetFont( GetFont() ); + dc.SetTextForeground( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) ); + dc.SetTextBackground( wxTransparentColor ); + + wxSize size = GetTextExtent( m_label ); + EDA_RECT rect( wxPoint( 0, 0 ), size ); + EDA_RECT bbox = rect.GetBoundingBoxRotated( rect.GetPosition(), m_angle ); + wxPoint pos( 0, -bbox.GetTop() ); + + dc.DrawRotatedText( m_label, pos, m_angle / 10 ); +} + + diff --git a/common/widgets/wx_angle_text.h b/common/widgets/wx_angle_text.h new file mode 100644 index 0000000000..8a037b2652 --- /dev/null +++ b/common/widgets/wx_angle_text.h @@ -0,0 +1,44 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2020 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _WX_ANGLE_TEXT_ +#define _WX_ANGLE_TEXT_ + +#include + + +class WX_ANGLE_TEXT : public wxPanel +{ +public: + WX_ANGLE_TEXT( wxWindow* aParent, wxWindowID aId, const wxString& aLabel, + const wxPoint& aPos, double aAngle ); + +protected: + void OnEraseBackground( wxEraseEvent& WXUNUSED( aEvent ) ); + void OnPaint( wxPaintEvent& WXUNUSED( aEvent ) ); + + wxString m_label; + double m_angle; +}; + +#endif /*_WX_ANGLE_TEXT_*/ diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index b9d7a9a0d8..78153c85d3 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -110,6 +110,8 @@ set( EESCHEMA_DLGS dialogs/panel_libedit_color_settings_base.cpp dialogs/panel_setup_formatting.cpp dialogs/panel_setup_formatting_base.cpp + dialogs/panel_setup_pinmap.cpp + dialogs/panel_setup_pinmap_base.cpp dialogs/panel_sym_lib_table.cpp dialogs/panel_sym_lib_table_base.cpp ) diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 4386728a2f..cd31cc2b54 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -37,8 +37,6 @@ #include #include #include -#include -#include #include #include #include @@ -48,25 +46,8 @@ #include -extern int DiagErc[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; -extern int DefaultDiagErc[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; - - -bool DIALOG_ERC::m_diagErcTableInit = false; // saved only for the current session - -// Control identifiers for events -#define ID_MATRIX_0 1800 - - -BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE ) - EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( ELECTRICAL_PINTYPES_TOTAL * ELECTRICAL_PINTYPES_TOTAL ) - 1, - wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel ) -END_EVENT_TABLE() - - DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : DIALOG_ERC_BASE( parent, ID_DIALOG_ERC ), // parent looks for this ID explicitly - m_buttonList(), m_initialized( false ) { m_parent = parent; @@ -96,27 +77,10 @@ void DIALOG_ERC::Init() { m_initialized = false; - for( auto& buttonRow : m_buttonList ) - { - for( auto& button : buttonRow ) - button = NULL; - } - SCH_SCREENS screens; updateMarkerCounts( &screens ); DisplayERC_MarkersList(); - - // Init Panel Matrix - ReBuildMatrixPanel(); -} - - -void DIALOG_ERC::OnUpdateUI( wxUpdateUIEvent& event ) -{ - m_buttondelmarkers->Show( m_NoteBook->GetSelection() == 0 ); - m_ResetOptButton->Show( m_NoteBook->GetSelection() == 1 ); - m_buttonsSizer->Layout(); } @@ -168,12 +132,6 @@ void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& event ) } -void DIALOG_ERC::OnResetMatrixClick( wxCommandEvent& event ) -{ - ResetDefaultERCDiag( event ); -} - - void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event ) { wxBusyCursor busy; @@ -271,125 +229,6 @@ void DIALOG_ERC::OnLeftDblClickMarkersList( wxMouseEvent& event ) } -void DIALOG_ERC::ReBuildMatrixPanel() -{ - // Try to know the size of bitmap button used in drc matrix - wxBitmapButton * dummy = new wxBitmapButton( m_matrixPanel, wxID_ANY, KiBitmap( ercerr_xpm ) ); - wxSize bitmap_size = dummy->GetSize(); - delete dummy; - - if( !m_diagErcTableInit ) - { - memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) ); - m_diagErcTableInit = true; - } - - wxPoint pos; - // Get the current text size:use a dummy text. - wxStaticText* text = new wxStaticText( m_matrixPanel, -1, wxT( "W" ), pos ); - int text_height = text->GetRect().GetHeight(); - bitmap_size.y = std::max( bitmap_size.y, text_height ); - delete text; - - // compute the Y pos interval: - pos.y = text_height; - - if( !m_initialized ) - { - std::vector labels; - - // Print row labels - for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) - { - int y = pos.y + (ii * bitmap_size.y); - text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii], - wxPoint( 5, y + ( bitmap_size.y / 2) - (text_height / 2) ) ); - labels.push_back( text ); - - int x = text->GetRect().GetRight(); - pos.x = std::max( pos.x, x ); - } - - // Right-align - for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) - { - wxPoint labelPos = labels[ ii ]->GetPosition(); - labelPos.x = pos.x - labels[ ii ]->GetRect().GetWidth(); - labels[ ii ]->SetPosition( labelPos ); - } - - pos.x += 5; - } - else - pos = m_buttonList[0][0]->GetPosition(); - - for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) - { - int y = pos.y + (ii * bitmap_size.y); - - for( int jj = 0; jj <= ii; jj++ ) - { - // Add column labels (only once) - int diag = DiagErc[ii][jj]; - int x = pos.x + (jj * bitmap_size.x); - - if( (ii == jj) && !m_initialized ) - { - wxPoint txtpos; - txtpos.x = x + (bitmap_size.x / 2); - txtpos.y = y - text_height; - text = new wxStaticText( m_matrixPanel, -1, CommentERC_V[ii], txtpos ); - } - - int event_id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL ); - BITMAP_DEF bitmap_butt = erc_green_xpm; - - delete m_buttonList[ii][jj]; - m_buttonList[ii][jj] = new wxBitmapButton( m_matrixPanel, - event_id, - KiBitmap( bitmap_butt ), - wxPoint( x, y ) ); - setDRCMatrixButtonState( m_buttonList[ii][jj], diag ); - } - } - - m_initialized = true; -} - - -void DIALOG_ERC::setDRCMatrixButtonState( wxBitmapButton *aButton, int aState ) -{ - BITMAP_DEF bitmap_butt = nullptr; - wxString tooltip; - - switch( aState ) - { - case OK: - bitmap_butt = erc_green_xpm; - tooltip = _( "No error or warning" ); - break; - - case WAR: - bitmap_butt = ercwarn_xpm; - tooltip = _( "Generate warning" ); - break; - - case ERR: - bitmap_butt = ercerr_xpm; - tooltip = _( "Generate error" ); - break; - - default: - break; - } - - if( bitmap_butt ) - { - aButton->SetBitmap( KiBitmap( bitmap_butt ) ); - aButton->SetToolTip( tooltip ); - } -} - void DIALOG_ERC::DisplayERC_MarkersList() { @@ -411,29 +250,6 @@ void DIALOG_ERC::DisplayERC_MarkersList() } -void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event ) -{ - memcpy( DiagErc, DefaultDiagErc, sizeof( DiagErc ) ); - ReBuildMatrixPanel(); -} - - -void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event ) -{ - int id = event.GetId(); - int ii = id - ID_MATRIX_0; - int x = ii / ELECTRICAL_PINTYPES_TOTAL; - int y = ii % ELECTRICAL_PINTYPES_TOTAL; - wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject(); - - int level = ( DiagErc[y][x] + 1 ) % 3; - - setDRCMatrixButtonState( butt, level ); - - DiagErc[y][x] = DiagErc[x][y] = level; -} - - void DIALOG_ERC::TestErc( REPORTER& aReporter ) { wxFileName fn; diff --git a/eeschema/dialogs/dialog_erc.h b/eeschema/dialogs/dialog_erc.h index a9ca18f93b..337785380c 100644 --- a/eeschema/dialogs/dialog_erc.h +++ b/eeschema/dialogs/dialog_erc.h @@ -37,14 +37,10 @@ class DIALOG_ERC : public DIALOG_ERC_BASE { - DECLARE_EVENT_TABLE() - private: SCH_EDIT_FRAME* m_parent; - wxBitmapButton* m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; bool m_initialized; const SCH_MARKER* m_lastMarkerFound; - static bool m_diagErcTableInit; // go to true after DiagErc init public: DIALOG_ERC( SCH_EDIT_FRAME* parent ); @@ -57,8 +53,6 @@ private: void OnErcCmpClick( wxCommandEvent& event ) override; void OnEraseDrcMarkersClick( wxCommandEvent& event ) override; void OnButtonCloseClick( wxCommandEvent& event ) override; - void OnResetMatrixClick( wxCommandEvent& event ) override; - void OnUpdateUI( wxUpdateUIEvent& event ) override; void RedrawDrawPanel(); @@ -70,10 +64,6 @@ private: void TestErc( REPORTER& aReporter ); void DisplayERC_MarkersList(); - void ResetDefaultERCDiag( wxCommandEvent& event ); - void ChangeErrorLevel( wxCommandEvent& event ); - void ReBuildMatrixPanel(); - void setDRCMatrixButtonState( wxBitmapButton *aButton, int aState ); void updateMarkerCounts( SCH_SCREENS *screens ); }; diff --git a/eeschema/dialogs/dialog_erc_base.cpp b/eeschema/dialogs/dialog_erc_base.cpp index db9981de97..2a4bf86eab 100644 --- a/eeschema/dialogs/dialog_erc_base.cpp +++ b/eeschema/dialogs/dialog_erc_base.cpp @@ -18,8 +18,6 @@ DIALOG_ERC_BASE::DIALOG_ERC_BASE( wxWindow* parent, wxWindowID id, const wxStrin wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxVERTICAL ); - m_NoteBook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - m_PanelERC = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bercSizer; bercSizer = new wxBoxSizer( wxVERTICAL ); @@ -27,34 +25,36 @@ DIALOG_ERC_BASE::DIALOG_ERC_BASE( wxWindow* parent, wxWindowID id, const wxStrin bupperSizer = new wxBoxSizer( wxHORIZONTAL ); wxStaticBoxSizer* sdiagSizer; - sdiagSizer = new wxStaticBoxSizer( new wxStaticBox( m_PanelERC, wxID_ANY, _("ERC Report:") ), wxVERTICAL ); + sdiagSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("ERC Report:") ), wxVERTICAL ); - wxGridSizer* gSizeDiag; - gSizeDiag = new wxGridSizer( 3, 2, 5, 5 ); + wxFlexGridSizer* fgSizer1; + fgSizer1 = new wxFlexGridSizer( 0, 2, 5, 5 ); + fgSizer1->SetFlexibleDirection( wxBOTH ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_ErcTotalErrorsText = new wxStaticText( sdiagSizer->GetStaticBox(), wxID_ANY, _("Total:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ErcTotalErrorsText->Wrap( -1 ); - gSizeDiag->Add( m_ErcTotalErrorsText, 1, wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_ErcTotalErrorsText, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_TotalErrCount = new wxTextCtrl( sdiagSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - gSizeDiag->Add( m_TotalErrCount, 0, wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_TotalErrCount, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_WarnErcErrorsText = new wxStaticText( sdiagSizer->GetStaticBox(), wxID_ANY, _("Warnings:"), wxDefaultPosition, wxDefaultSize, 0 ); m_WarnErcErrorsText->Wrap( -1 ); - gSizeDiag->Add( m_WarnErcErrorsText, 1, wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_WarnErcErrorsText, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_LastWarningCount = new wxTextCtrl( sdiagSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - gSizeDiag->Add( m_LastWarningCount, 0, wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_LastWarningCount, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_LastErrCountText = new wxStaticText( sdiagSizer->GetStaticBox(), wxID_ANY, _("Errors:"), wxDefaultPosition, wxDefaultSize, 0 ); m_LastErrCountText->Wrap( -1 ); - gSizeDiag->Add( m_LastErrCountText, 1, wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_LastErrCountText, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_LastErrCount = new wxTextCtrl( sdiagSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - gSizeDiag->Add( m_LastErrCount, 0, wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer1->Add( m_LastErrCount, 0, wxALIGN_CENTER_VERTICAL, 5 ); - sdiagSizer->Add( gSizeDiag, 0, wxALL|wxEXPAND, 5 ); + sdiagSizer->Add( fgSizer1, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 ); bupperSizer->Add( sdiagSizer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); @@ -62,13 +62,13 @@ DIALOG_ERC_BASE::DIALOG_ERC_BASE( wxWindow* parent, wxWindowID id, const wxStrin wxBoxSizer* bSizerMessages; bSizerMessages = new wxBoxSizer( wxVERTICAL ); - m_titleMessages = new wxStaticText( m_PanelERC, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_titleMessages = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); m_titleMessages->Wrap( -1 ); m_titleMessages->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); bSizerMessages->Add( m_titleMessages, 0, wxRIGHT|wxLEFT, 12 ); - m_MessagesList = new wxTextCtrl( m_PanelERC, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + m_MessagesList = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); m_MessagesList->SetMinSize( wxSize( 180,-1 ) ); bSizerMessages->Add( m_MessagesList, 1, wxEXPAND|wxBOTTOM|wxLEFT, 5 ); @@ -79,49 +79,25 @@ DIALOG_ERC_BASE::DIALOG_ERC_BASE( wxWindow* parent, wxWindowID id, const wxStrin bercSizer->Add( bupperSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 ); - m_textMarkers = new wxStaticText( m_PanelERC, wxID_ANY, _("Error List:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textMarkers = new wxStaticText( this, wxID_ANY, _("Error List:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textMarkers->Wrap( -1 ); m_textMarkers->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); bercSizer->Add( m_textMarkers, 0, wxLEFT|wxRIGHT, 20 ); - m_MarkersList = new ERC_HTML_LISTFRAME( m_PanelERC, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxBORDER_SIMPLE ); - bercSizer->Add( m_MarkersList, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 8 ); + m_MarkersList = new ERC_HTML_LISTFRAME( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxBORDER_SIMPLE ); + m_MarkersList->SetMinSize( wxSize( 460,200 ) ); + + bercSizer->Add( m_MarkersList, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); - m_PanelERC->SetSizer( bercSizer ); - m_PanelERC->Layout(); - bercSizer->Fit( m_PanelERC ); - m_NoteBook->AddPage( m_PanelERC, _("ERC"), true ); - m_PanelERCOptions = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* m_panelMatrixSizer; - m_panelMatrixSizer = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* sbSizer3; - sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_PanelERCOptions, wxID_ANY, _("Pin to Pin Connections") ), wxVERTICAL ); - - m_matrixPanel = new wxPanel( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - sbSizer3->Add( m_matrixPanel, 1, wxEXPAND | wxALL, 5 ); - - - m_panelMatrixSizer->Add( sbSizer3, 0, wxALL|wxEXPAND, 5 ); - - - m_PanelERCOptions->SetSizer( m_panelMatrixSizer ); - m_PanelERCOptions->Layout(); - m_panelMatrixSizer->Fit( m_PanelERCOptions ); - m_NoteBook->AddPage( m_PanelERCOptions, _("Options"), false ); - - bSizer1->Add( m_NoteBook, 1, wxEXPAND | wxALL, 5 ); + bSizer1->Add( bercSizer, 1, wxEXPAND, 5 ); m_buttonsSizer = new wxBoxSizer( wxHORIZONTAL ); m_buttondelmarkers = new wxButton( this, ID_ERASE_DRC_MARKERS, _("Delete Markers"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonsSizer->Add( m_buttondelmarkers, 0, wxALL|wxEXPAND, 5 ); - m_ResetOptButton = new wxButton( this, ID_RESET_MATRIX, _("Reset to Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonsSizer->Add( m_ResetOptButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_buttonsSizer->Add( 0, 0, 1, wxEXPAND, 5 ); @@ -144,11 +120,9 @@ DIALOG_ERC_BASE::DIALOG_ERC_BASE( wxWindow* parent, wxWindowID id, const wxStrin // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_ERC_BASE::OnCloseErcDialog ) ); - m_NoteBook->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_ERC_BASE::OnUpdateUI ), NULL, this ); m_MarkersList->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_ERC_BASE::OnLeftClickMarkersList ), NULL, this ); m_MarkersList->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_ERC_BASE::OnLeftDblClickMarkersList ), NULL, this ); m_buttondelmarkers->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ERC_BASE::OnEraseDrcMarkersClick ), NULL, this ); - m_ResetOptButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ERC_BASE::OnResetMatrixClick ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ERC_BASE::OnButtonCloseClick ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ERC_BASE::OnErcCmpClick ), NULL, this ); } @@ -157,11 +131,9 @@ DIALOG_ERC_BASE::~DIALOG_ERC_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_ERC_BASE::OnCloseErcDialog ) ); - m_NoteBook->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_ERC_BASE::OnUpdateUI ), NULL, this ); m_MarkersList->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_ERC_BASE::OnLeftClickMarkersList ), NULL, this ); m_MarkersList->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_ERC_BASE::OnLeftDblClickMarkersList ), NULL, this ); m_buttondelmarkers->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ERC_BASE::OnEraseDrcMarkersClick ), NULL, this ); - m_ResetOptButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ERC_BASE::OnResetMatrixClick ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ERC_BASE::OnButtonCloseClick ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ERC_BASE::OnErcCmpClick ), NULL, this ); diff --git a/eeschema/dialogs/dialog_erc_base.fbp b/eeschema/dialogs/dialog_erc_base.fbp index d8475ea658..1c7efb3bd5 100644 --- a/eeschema/dialogs/dialog_erc_base.fbp +++ b/eeschema/dialogs/dialog_erc_base.fbp @@ -61,801 +61,633 @@ none 5 - wxEXPAND | wxALL + wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 + - 1 - m_NoteBook - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - OnUpdateUI - - - ERC - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 + bercSizer + wxVERTICAL + none + + 8 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + - 1 - m_PanelERC - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxTAB_TRAVERSAL - - - bercSizer - wxVERTICAL - none - - 8 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - - bupperSizer - wxHORIZONTAL - none - - 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT - 0 - - wxID_ANY - ERC Report: - - sdiagSizer - wxVERTICAL - 1 - none - - 5 - wxALL|wxEXPAND - 0 - - 2 - 5 - - gSizeDiag - none - 3 - 5 - - 5 - wxALIGN_CENTER_VERTICAL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Total: - 0 - - 0 - - - 0 - - 1 - m_ErcTotalErrorsText - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_TotalErrCount - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Warnings: - 0 - - 0 - - - 0 - - 1 - m_WarnErcErrorsText - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_LastWarningCount - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Errors: - 0 - - 0 - - - 0 - - 1 - m_LastErrCountText - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_LastErrCount - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - + bupperSizer + wxHORIZONTAL + none + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + 0 + + wxID_ANY + ERC Report: + + sdiagSizer + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT + 0 + + 2 + wxBOTH + + + 5 + + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 5 + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Total: + 0 + + 0 + + + 0 + + 1 + m_ErcTotalErrorsText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 - - - 3 - wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP - 1 - - - bSizerMessages - wxVERTICAL - none - - 12 - wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,90,-1,70,0 - 0 - 0 - wxID_ANY - Messages: - 0 - - 0 - - - 0 - - 1 - m_titleMessages - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_TotalErrCount + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + - - 5 - wxEXPAND|wxBOTTOM|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - 180,-1 - 1 - m_MessagesList - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_MULTILINE|wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Warnings: + 0 + + 0 + + + 0 + + 1 + m_WarnErcErrorsText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_LastWarningCount + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Errors: + 0 + + 0 + + + 0 + + 1 + m_LastErrCountText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_LastErrCount + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + - - 20 - wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,90,-1,70,0 - 0 - 0 - wxID_ANY - Error List: - 0 - - 0 - - - 0 - - 1 - m_textMarkers - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 + + + 3 + wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP + 1 + + + bSizerMessages + wxVERTICAL + none + + 12 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,90,-1,70,0 + 0 + 0 + wxID_ANY + Messages: + 0 + + 0 + + + 0 + + 1 + m_titleMessages + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + - - - 8 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_MarkersList - 1 - - - protected - 1 - - Resizable - 1 - - wxHW_SCROLLBAR_AUTO - ERC_HTML_LISTFRAME; dialog_erc_listbox.h - 0 - - - - wxBORDER_SIMPLE - OnLeftClickMarkersList - OnLeftDblClickMarkersList + + 5 + wxEXPAND|wxBOTTOM|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + 180,-1 + 1 + m_MessagesList + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE|wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + - - - Options - 0 - + + 20 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,90,-1,70,0 + 0 + 0 + wxID_ANY + Error List: + 0 + + 0 + + + 0 + + 1 + m_textMarkers + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 10 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + 1 1 1 @@ -888,9 +720,9 @@ 0 - + 460,200 1 - m_PanelERCOptions + m_MarkersList 1 @@ -900,89 +732,15 @@ Resizable 1 - + wxHW_SCROLLBAR_AUTO + ERC_HTML_LISTFRAME; dialog_erc_listbox.h 0 - wxTAB_TRAVERSAL - - - m_panelMatrixSizer - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - wxID_ANY - Pin to Pin Connections - - sbSizer3 - wxVERTICAL - 1 - none - - 5 - wxEXPAND | wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_matrixPanel - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxTAB_TRAVERSAL - - - - - + wxBORDER_SIMPLE + OnLeftClickMarkersList + OnLeftDblClickMarkersList @@ -1069,79 +827,6 @@ OnEraseDrcMarkersClick - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - ID_RESET_MATRIX - Reset to Defaults - - 0 - - 0 - - - 0 - - 1 - m_ResetOptButton - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnResetMatrixClick - - 5 wxEXPAND diff --git a/eeschema/dialogs/dialog_erc_base.h b/eeschema/dialogs/dialog_erc_base.h index ad160b65df..19b034a74c 100644 --- a/eeschema/dialogs/dialog_erc_base.h +++ b/eeschema/dialogs/dialog_erc_base.h @@ -23,18 +23,15 @@ class ERC_HTML_LISTFRAME; #include #include #include -#include #include #include #include -#include #include #include /////////////////////////////////////////////////////////////////////////// #define ID_ERASE_DRC_MARKERS 1000 -#define ID_RESET_MATRIX 1001 /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_ERC_BASE @@ -44,8 +41,6 @@ class DIALOG_ERC_BASE : public DIALOG_SHIM private: protected: - wxNotebook* m_NoteBook; - wxPanel* m_PanelERC; wxStaticText* m_ErcTotalErrorsText; wxTextCtrl* m_TotalErrCount; wxStaticText* m_WarnErcErrorsText; @@ -56,22 +51,17 @@ class DIALOG_ERC_BASE : public DIALOG_SHIM wxTextCtrl* m_MessagesList; wxStaticText* m_textMarkers; ERC_HTML_LISTFRAME* m_MarkersList; - wxPanel* m_PanelERCOptions; - wxPanel* m_matrixPanel; wxBoxSizer* m_buttonsSizer; wxButton* m_buttondelmarkers; - wxButton* m_ResetOptButton; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; // Virtual event handlers, overide them in your derived class virtual void OnCloseErcDialog( wxCloseEvent& event ) { event.Skip(); } - virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnLeftClickMarkersList( wxHtmlLinkEvent& event ) { event.Skip(); } virtual void OnLeftDblClickMarkersList( wxMouseEvent& event ) { event.Skip(); } virtual void OnEraseDrcMarkersClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnResetMatrixClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonCloseClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnErcCmpClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_schematic_setup.cpp b/eeschema/dialogs/dialog_schematic_setup.cpp index 4c9bc3576d..065dbb29bf 100644 --- a/eeschema/dialogs/dialog_schematic_setup.cpp +++ b/eeschema/dialogs/dialog_schematic_setup.cpp @@ -22,7 +22,7 @@ #include #include #include - +#include #include "dialog_schematic_setup.h" #include "panel_eeschema_template_fieldnames.h" @@ -38,6 +38,7 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) : { m_formatting = new PANEL_SETUP_FORMATTING( this, aFrame ); m_fieldNameTemplates = new PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( aFrame, this, false ); + m_pinMap = new PANEL_SETUP_PINMAP( this, aFrame ); m_severities = new PANEL_SETUP_SEVERITIES( this, aFrame->GetErcSettings().m_Severities, ERCE_FIRST, ERCE_LAST ); /* @@ -49,6 +50,7 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) : m_treebook->AddSubPage( m_fieldNameTemplates, _( "Field Name Templates" ) ); m_treebook->AddPage( new wxPanel( this ), _( "Electrical Rules" ) ); + m_treebook->AddSubPage( m_pinMap, _( "Pin Map" ) ); m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) ); // Connect Events diff --git a/eeschema/dialogs/dialog_schematic_setup.h b/eeschema/dialogs/dialog_schematic_setup.h index 3fe2e8525c..5d3acf0209 100644 --- a/eeschema/dialogs/dialog_schematic_setup.h +++ b/eeschema/dialogs/dialog_schematic_setup.h @@ -27,6 +27,7 @@ class SCH_EDIT_FRAME; class PANEL_SETUP_SEVERITIES; class PANEL_EESCHEMA_TEMPLATE_FIELDNAMES; class PANEL_SETUP_FORMATTING; +class PANEL_SETUP_PINMAP; class DIALOG_SCHEMATIC_SETUP : public PAGED_DIALOG @@ -42,6 +43,7 @@ protected: PANEL_SETUP_FORMATTING* m_formatting; PANEL_EESCHEMA_TEMPLATE_FIELDNAMES* m_fieldNameTemplates; + PANEL_SETUP_PINMAP* m_pinMap; PANEL_SETUP_SEVERITIES* m_severities; // event handlers diff --git a/eeschema/dialogs/panel_setup_pinmap.cpp b/eeschema/dialogs/panel_setup_pinmap.cpp new file mode 100644 index 0000000000..74e2b84447 --- /dev/null +++ b/eeschema/dialogs/panel_setup_pinmap.cpp @@ -0,0 +1,241 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern int PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; +extern int DefaultPinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; + + +bool PANEL_SETUP_PINMAP::m_diagErcTableInit = false; // saved only for the current session + +// Control identifiers for events +#define ID_MATRIX_0 1800 + + +BEGIN_EVENT_TABLE( PANEL_SETUP_PINMAP, PANEL_SETUP_PINMAP_BASE ) + EVT_COMMAND_RANGE( ID_MATRIX_0, + ID_MATRIX_0 + ( ELECTRICAL_PINTYPES_TOTAL * ELECTRICAL_PINTYPES_TOTAL ) - 1, + wxEVT_COMMAND_BUTTON_CLICKED, PANEL_SETUP_PINMAP::ChangeErrorLevel ) +END_EVENT_TABLE() + + +PANEL_SETUP_PINMAP::PANEL_SETUP_PINMAP( wxWindow* aWindow, SCH_EDIT_FRAME* parent ) : + PANEL_SETUP_PINMAP_BASE( aWindow ), + m_buttonList(), + m_initialized( false ) +{ + m_parent = parent; + + wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); + infoFont.SetSymbolicSize( wxFONTSIZE_SMALL ); + + ReBuildMatrixPanel(); +} + + +void PANEL_SETUP_PINMAP::OnResetMatrixClick( wxCommandEvent& aEvent ) +{ + memcpy( PinMap, DefaultPinMap, sizeof( PinMap ) ); + ReBuildMatrixPanel(); +} + + +void PANEL_SETUP_PINMAP::ReBuildMatrixPanel() +{ + // Try to know the size of bitmap button used in drc matrix + wxBitmapButton * dummy = new wxBitmapButton( m_matrixPanel, wxID_ANY, KiBitmap( ercerr_xpm ) ); + wxSize bitmap_size = dummy->GetSize(); + delete dummy; + + if( !m_diagErcTableInit ) + { + memcpy( PinMap, DefaultPinMap, sizeof(DefaultPinMap) ); + m_diagErcTableInit = true; + } + + wxPoint pos; + // Get the current text size using a dummy text. + wxStaticText* text = new wxStaticText( m_matrixPanel, -1, CommentERC_V[0], pos ); + int text_width = text->GetRect().GetWidth(); + int text_height = text->GetRect().GetHeight(); + + bitmap_size.y = std::max( bitmap_size.y, text_height ); + delete text; + + // compute the Y pos interval: + pos.y = text_height + ( text_width / 2 ); + + if( !m_initialized ) + { + std::vector labels; + + // Print row labels + for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) + { + int y = pos.y + (ii * bitmap_size.y); + text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii], + wxPoint( 5, y + ( bitmap_size.y / 2) - (text_height / 2) ) ); + labels.push_back( text ); + + int x = text->GetRect().GetRight(); + pos.x = std::max( pos.x, x ); + } + + // Right-align + for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) + { + wxPoint labelPos = labels[ ii ]->GetPosition(); + labelPos.x = pos.x - labels[ ii ]->GetRect().GetWidth(); + labels[ ii ]->SetPosition( labelPos ); + } + + pos.x += 5; + } + else + pos = m_buttonList[0][0]->GetPosition(); + + for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ ) + { + int y = pos.y + (ii * bitmap_size.y); + + for( int jj = 0; jj <= ii; jj++ ) + { + // Add column labels (only once) + int diag = PinMap[ii][jj]; + int x = pos.x + ( jj * ( bitmap_size.x + 4 ) ); + + if( (ii == jj) && !m_initialized ) + { + wxPoint txtpos; + txtpos.x = x + (bitmap_size.x / 2); + txtpos.y = y - text_height; + WX_ANGLE_TEXT* txt = new WX_ANGLE_TEXT( m_matrixPanel, wxID_ANY, CommentERC_V[ii], + txtpos, 450 ); + } + + int event_id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL ); + BITMAP_DEF bitmap_butt = erc_green_xpm; + + delete m_buttonList[ii][jj]; + wxBitmapButton* btn = new wxBitmapButton( m_matrixPanel, event_id, + KiBitmap( bitmap_butt ), wxPoint( x, y ) ); + btn->SetSize( btn->GetSize().x + 4, btn->GetSize().y ); + m_buttonList[ii][jj] = btn; + setDRCMatrixButtonState( m_buttonList[ii][jj], diag ); + } + } + + m_initialized = true; +} + + +bool PANEL_SETUP_PINMAP::Show( bool show ) +{ + wxPanel::Show( show ); + + // For some reason the angle text doesn't get drawn if the paint events are fired while + // it's not the active tab. + if( show ) + { + for( wxWindow* win : m_matrixPanel->GetChildren() ) + { + WX_ANGLE_TEXT* angleText = dynamic_cast( win ); + + if( angleText ) + angleText->Refresh(); + } + } + + return true; +} + + +void PANEL_SETUP_PINMAP::setDRCMatrixButtonState( wxBitmapButton *aButton, int aState ) +{ + BITMAP_DEF bitmap_butt = nullptr; + wxString tooltip; + + switch( aState ) + { + case OK: + bitmap_butt = erc_green_xpm; + tooltip = _( "No error or warning" ); + break; + + case WAR: + bitmap_butt = ercwarn_xpm; + tooltip = _( "Generate warning" ); + break; + + case ERR: + bitmap_butt = ercerr_xpm; + tooltip = _( "Generate error" ); + break; + + default: + break; + } + + if( bitmap_butt ) + { + aButton->SetBitmap( KiBitmap( bitmap_butt ) ); + aButton->SetToolTip( tooltip ); + } +} + + +void PANEL_SETUP_PINMAP::ChangeErrorLevel( wxCommandEvent& event ) +{ + int id = event.GetId(); + int ii = id - ID_MATRIX_0; + int x = ii / ELECTRICAL_PINTYPES_TOTAL; + int y = ii % ELECTRICAL_PINTYPES_TOTAL; + wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject(); + + int level = ( PinMap[y][x] + 1 ) % 3; + + setDRCMatrixButtonState( butt, level ); + + PinMap[y][x] = PinMap[x][y] = level; +} + + diff --git a/eeschema/dialogs/panel_setup_pinmap.h b/eeschema/dialogs/panel_setup_pinmap.h new file mode 100644 index 0000000000..7e54f32e7a --- /dev/null +++ b/eeschema/dialogs/panel_setup_pinmap.h @@ -0,0 +1,63 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 1992-2014 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _PANEL_SETUP_PINMAP_H_ +#define _PANEL_SETUP_PINMAP_H_ + +#include +#include // For PINTYPE_COUNT definition +#include +#include "panel_setup_pinmap_base.h" + + +class SCH_EDIT_FRAME; + + +class PANEL_SETUP_PINMAP : public PANEL_SETUP_PINMAP_BASE +{ + DECLARE_EVENT_TABLE() + +private: + SCH_EDIT_FRAME* m_parent; + wxBitmapButton* m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; + bool m_initialized; + static bool m_diagErcTableInit; // go to true after DiagErc init + +public: + PANEL_SETUP_PINMAP( wxWindow* aWindow, SCH_EDIT_FRAME* aParent ); + + bool Show( bool show ) override; + +private: + void OnResetMatrixClick( wxCommandEvent& aEvent ) override; + + void ChangeErrorLevel( wxCommandEvent& event ); + void ReBuildMatrixPanel(); + void setDRCMatrixButtonState( wxBitmapButton *aButton, int aState ); +}; + + +#endif + +// _PANEL_SETUP_PINMAP_H_ diff --git a/eeschema/dialogs/panel_setup_pinmap_base.cpp b/eeschema/dialogs/panel_setup_pinmap_base.cpp new file mode 100644 index 0000000000..aff5b2aa82 --- /dev/null +++ b/eeschema/dialogs/panel_setup_pinmap_base.cpp @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "panel_setup_pinmap_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_SETUP_PINMAP_BASE::PANEL_SETUP_PINMAP_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* m_panelMatrixSizer; + m_panelMatrixSizer = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbSizer3; + sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pin to Pin Connections") ), wxVERTICAL ); + + m_matrixPanel = new wxPanel( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_matrixPanel->SetMinSize( wxSize( 500,420 ) ); + + sbSizer3->Add( m_matrixPanel, 1, wxEXPAND | wxALL, 5 ); + + + m_panelMatrixSizer->Add( sbSizer3, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + + + m_panelMatrixSizer->Add( 0, 0, 0, wxEXPAND|wxTOP, 5 ); + + m_ResetOptButton = new wxButton( this, ID_RESET_MATRIX, _("Reset to Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); + m_panelMatrixSizer->Add( m_ResetOptButton, 0, wxRIGHT|wxLEFT, 10 ); + + + bSizer2->Add( m_panelMatrixSizer, 1, wxEXPAND|wxLEFT, 10 ); + + + this->SetSizer( bSizer2 ); + this->Layout(); + bSizer2->Fit( this ); + + // Connect Events + m_ResetOptButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_PINMAP_BASE::OnResetMatrixClick ), NULL, this ); +} + +PANEL_SETUP_PINMAP_BASE::~PANEL_SETUP_PINMAP_BASE() +{ + // Disconnect Events + m_ResetOptButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_PINMAP_BASE::OnResetMatrixClick ), NULL, this ); + +} diff --git a/eeschema/dialogs/panel_setup_pinmap_base.fbp b/eeschema/dialogs/panel_setup_pinmap_base.fbp new file mode 100644 index 0000000000..6376051f51 --- /dev/null +++ b/eeschema/dialogs/panel_setup_pinmap_base.fbp @@ -0,0 +1,225 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + panel_setup_pinmap_base + 1000 + none + + 1 + PanelSetupPinMap + + . + + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_SETUP_PINMAP_BASE + + -1,-1 + ; forward_declare + + + + wxTAB_TRAVERSAL + + + bSizer2 + wxHORIZONTAL + none + + 10 + wxEXPAND|wxLEFT + 1 + + + m_panelMatrixSizer + wxVERTICAL + none + + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + + wxID_ANY + Pin to Pin Connections + + sbSizer3 + wxVERTICAL + 1 + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 500,420 + 1 + m_matrixPanel + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + 5 + wxEXPAND|wxTOP + 0 + + 0 + protected + 0 + + + + 10 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + ID_RESET_MATRIX + Reset to Defaults + + 0 + + 0 + + + 0 + + 1 + m_ResetOptButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnResetMatrixClick + + + + + + + + diff --git a/eeschema/dialogs/panel_setup_pinmap_base.h b/eeschema/dialogs/panel_setup_pinmap_base.h new file mode 100644 index 0000000000..cccd889638 --- /dev/null +++ b/eeschema/dialogs/panel_setup_pinmap_base.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_SETUP_PINMAP_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_SETUP_PINMAP_BASE : public wxPanel +{ + private: + + protected: + enum + { + ID_RESET_MATRIX = 1000 + }; + + wxPanel* m_matrixPanel; + wxButton* m_ResetOptButton; + + // Virtual event handlers, overide them in your derived class + virtual void OnResetMatrixClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + PANEL_SETUP_PINMAP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_SETUP_PINMAP_BASE(); + +}; + diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 0d00e94fb4..7875da15ab 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -101,7 +101,7 @@ const wxString CommentERC_V[] = * at start up: must be loaded by DefaultDiagErc * Can be modified in dialog ERC */ -int DiagErc[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; +int PinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; /** * Default Look up table which gives the ERC error level for a pair of connected pins @@ -110,7 +110,7 @@ int DiagErc[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL]; * note also, to avoid inconsistancy: * DefaultDiagErc[i][j] = DefaultDiagErc[j][i] */ -int DefaultDiagErc[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL] = +int DefaultPinMap[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL] = { /* I, O, Bi, 3S, Pas, UnS, PwrI, PwrO, OC, OE, NC */ /* I */ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, ERR }, @@ -508,7 +508,7 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned if( erc == OK ) { - erc = DiagErc[static_cast( ref_elect_type )][static_cast( jj )]; + erc = PinMap[static_cast( ref_elect_type )][static_cast( jj )]; if( erc != OK ) {