diff --git a/pcbnew/dialogs/dialog_select_net_from_list.cpp b/pcbnew/dialogs/dialog_select_net_from_list.cpp index 00ff759016..19c550138b 100644 --- a/pcbnew/dialogs/dialog_select_net_from_list.cpp +++ b/pcbnew/dialogs/dialog_select_net_from_list.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -58,7 +59,7 @@ private: void onSelChanged( wxDataViewEvent& event ) override; void onFilterChange( wxCommandEvent& event ) override; void onListSize( wxSizeEvent& event ) override; - void onExport( wxMouseEvent& event ) override; + void onReport( wxCommandEvent& event ) override; void buildNetsList(); wxString getListColumnHeaderNet() { return _( "Net" ); }; @@ -187,18 +188,18 @@ void DIALOG_SELECT_NET_FROM_LIST::buildNetsList() } } - dataLine.push_back( wxVariant( wxString::Format( wxT( "%u" ), viaCount ) ) ); + dataLine.push_back( wxVariant( wxString::Format( "%u", viaCount ) ) ); dataLine.push_back( wxVariant( MessageTextFromValue( units, len ) ) ); dataLine.push_back( wxVariant( MessageTextFromValue( units, lenPadToDie ) ) ); dataLine.push_back( wxVariant( MessageTextFromValue( units, len + lenPadToDie ) ) ); } else // For the net 0 (unconnected pads), the pad count is not known { - dataLine.push_back( wxVariant( wxT( "---" ) ) ); - dataLine.push_back( wxVariant( wxT( "---" ) ) ); // vias - dataLine.push_back( wxVariant( wxT( "---" ) ) ); // board - dataLine.push_back( wxVariant( wxT( "---" ) ) ); // die - dataLine.push_back( wxVariant( wxT( "---" ) ) ); // length + dataLine.push_back( wxVariant( "---" ) ); + dataLine.push_back( wxVariant( "---" ) ); // vias + dataLine.push_back( wxVariant( "---" ) ); // board + dataLine.push_back( wxVariant( "---" ) ); // die + dataLine.push_back( wxVariant( "---" ) ); // length } m_netsList->AppendItem( dataLine ); @@ -210,12 +211,11 @@ void DIALOG_SELECT_NET_FROM_LIST::buildNetsList() void DIALOG_SELECT_NET_FROM_LIST::HighlightNet( const wxString& aNetName ) { - NETINFO_ITEM* net = nullptr; int netCode = -1; if( !aNetName.IsEmpty() ) { - net = m_brd->FindNet( aNetName ); + NETINFO_ITEM* net = m_brd->FindNet( aNetName ); if( net ) netCode = net->GetNet(); @@ -287,7 +287,7 @@ void DIALOG_SELECT_NET_FROM_LIST::adjustListColumns() */ wxClientDC dc( GetParent() ); - int h, minw; + int h, minw, minw_col0; dc.GetTextExtent( getListColumnHeaderNet()+"MM", &w0, &h ); dc.GetTextExtent( getListColumnHeaderCount()+"MM", &w2, &h ); @@ -296,10 +296,11 @@ void DIALOG_SELECT_NET_FROM_LIST::adjustListColumns() dc.GetTextExtent( getListColumnHeaderDie()+"MM", &w5, &h ); dc.GetTextExtent( getListColumnHeaderLength()+"MM", &w6, &h ); dc.GetTextExtent( "M00000,000 mmM", &minw, &h ); + dc.GetTextExtent( "M00000M", &minw_col0, &h ); // Considering left and right margins. // For wxRenderGeneric it is 5px. - w0 = std::max( w0+10, minw); + w0 = std::max( w0+10, minw_col0); w2 = std::max( w2+10, minw); w3 = std::max( w3+10, minw); w4 = std::max( w4+10, minw); @@ -317,7 +318,13 @@ void DIALOG_SELECT_NET_FROM_LIST::adjustListColumns() int width = m_netsList->GetClientSize().x; w1 = width - w0 - w2 - w3 - w4 - w5 - w6; + // Column 1 (net names) need a minimal width to display net names + dc.GetTextExtent( "MMMMMMMMMMMMMMMMMMMM", &minw, &h ); + w1 = std::max( w1, minw ); + m_netsList->GetColumn( 1 )->SetWidth( w1 ); + + m_netsList->Refresh(); } @@ -335,31 +342,42 @@ bool DIALOG_SELECT_NET_FROM_LIST::GetNetName( wxString& aName ) } -void DIALOG_SELECT_NET_FROM_LIST::onExport( wxMouseEvent& aEvent ) +void DIALOG_SELECT_NET_FROM_LIST::onReport( wxCommandEvent& aEvent ) { - wxFileDialog dlg( this, _( "Export file" ), "", "", "Text files (*.txt)|*.txt", - wxFD_SAVE|wxFD_OVERWRITE_PROMPT ); + wxFileDialog dlg( this, _( "Report file" ), "", "", + _( "Report file" ) + AddFileExtListToFilter( { "csv" } ), + wxFD_SAVE ); - if( dlg.ShowModal() == wxID_CANCEL ) + if( dlg.ShowModal() == wxID_CANCEL ) return; - wxTextFile f( dlg.GetPath() ); + wxTextFile f( dlg.GetPath() ); + + f.Create(); - f.Create(); + int rows = m_netsList->GetItemCount(); + wxString txt; - int rows = m_netsList->GetItemCount(); + // Print Header: + txt.Printf( "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";", + _( "Net Id" ), _( "Net name" ), + _( "Pad count" ), _( "Via count" ), + _( "Board length" ), _( "Die length" ), _( "Net length" ) ); + f.AddLine( txt ); - for( int row = 0; row < rows; row++ ) + // Print list of nets: + for( int row = 1; row < rows; row++ ) { - wxString txt = m_netsList->GetTextValue( row, 0 ) + ";" + - m_netsList->GetTextValue( row, 1 ) + ";" + - m_netsList->GetTextValue( row, 2 ) + ";" + - m_netsList->GetTextValue( row, 3 ) + ";" + - m_netsList->GetTextValue( row, 4 ) + ";" + - m_netsList->GetTextValue( row, 5 ) + ";" + - m_netsList->GetTextValue( row, 6 ) + ";"; - - f.AddLine( txt ); + txt.Printf( "%s;\"%s\";%s;%s;%s;%s;%s;", + m_netsList->GetTextValue( row, 0 ), // net id + m_netsList->GetTextValue( row, 1 ), // net name + m_netsList->GetTextValue( row, 2 ), // Pad count + m_netsList->GetTextValue( row, 3 ), // Via count + m_netsList->GetTextValue( row, 4 ), // Board length + m_netsList->GetTextValue( row, 5 ), // Die length + m_netsList->GetTextValue( row, 6 ) ); // net length + + f.AddLine( txt ); } f.Write(); diff --git a/pcbnew/dialogs/dialog_select_net_from_list_base.cpp b/pcbnew/dialogs/dialog_select_net_from_list_base.cpp index ee52ad53e3..4b90a12692 100644 --- a/pcbnew/dialogs/dialog_select_net_from_list_base.cpp +++ b/pcbnew/dialogs/dialog_select_net_from_list_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Dec 1 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -12,69 +12,68 @@ DIALOG_SELECT_NET_FROM_LIST_BASE::DIALOG_SELECT_NET_FROM_LIST_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); - + wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); - + wxBoxSizer* bTopSizer; bTopSizer = new wxBoxSizer( wxHORIZONTAL ); - + m_staticTextFilter = new wxStaticText( this, wxID_ANY, _("Net name filter:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextFilter->Wrap( -1 ); bTopSizer->Add( m_staticTextFilter, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - + m_textCtrlFilter = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bTopSizer->Add( m_textCtrlFilter, 1, wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP, 5 ); - - + + bTopSizer->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - + m_cbShowZeroPad = new wxCheckBox( this, wxID_ANY, _("Show zero pad nets"), wxDefaultPosition, wxDefaultSize, 0 ); - m_cbShowZeroPad->SetValue(true); + m_cbShowZeroPad->SetValue(true); bTopSizer->Add( m_cbShowZeroPad, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - + + bSizerMain->Add( bTopSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_netsList = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - m_netsList->SetMinSize( wxSize( 400,300 ) ); - + + m_netsList = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_HORIZ_RULES ); + m_netsList->SetMinSize( wxSize( 500,300 ) ); + bSizerMain->Add( m_netsList, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - + wxBoxSizer* bSizerBottom; bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); - - m_Export = new wxButton( this, wxID_ANY, _("Export..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerBottom->Add( m_Export, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - + + m_ReportButt = new wxButton( this, wxID_ANY, _("Create Report..."), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerBottom->Add( m_ReportButt, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizerBottom->Add( 0, 0, 1, wxEXPAND, 5 ); - + m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); m_sdbSizer->AddButton( m_sdbSizerOK ); m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->Realize(); - + bSizerBottom->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 ); - - + + bSizerMain->Add( bSizerBottom, 0, wxEXPAND|wxLEFT, 5 ); - - + + this->SetSizer( bSizerMain ); this->Layout(); - bSizerMain->Fit( this ); - + this->Centre( wxBOTH ); - + // Connect Events m_textCtrlFilter->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onFilterChange ), NULL, this ); m_cbShowZeroPad->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onFilterChange ), NULL, this ); m_netsList->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onSelChanged ), NULL, this ); m_netsList->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onListSize ), NULL, this ); - m_Export->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onExport ), NULL, this ); + m_ReportButt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onReport ), NULL, this ); } DIALOG_SELECT_NET_FROM_LIST_BASE::~DIALOG_SELECT_NET_FROM_LIST_BASE() @@ -84,6 +83,6 @@ DIALOG_SELECT_NET_FROM_LIST_BASE::~DIALOG_SELECT_NET_FROM_LIST_BASE() m_cbShowZeroPad->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onFilterChange ), NULL, this ); m_netsList->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onSelChanged ), NULL, this ); m_netsList->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onListSize ), NULL, this ); - m_Export->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onExport ), NULL, this ); - + m_ReportButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_NET_FROM_LIST_BASE::onReport ), NULL, this ); + } diff --git a/pcbnew/dialogs/dialog_select_net_from_list_base.fbp b/pcbnew/dialogs/dialog_select_net_from_list_base.fbp index f8b6495337..d7f7dc5a53 100644 --- a/pcbnew/dialogs/dialog_select_net_from_list_base.fbp +++ b/pcbnew/dialogs/dialog_select_net_from_list_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_select_net_from_list_base 1000 none + 1 dialog_select_net_from_list_base @@ -44,7 +45,7 @@ -1,-1 DIALOG_SELECT_NET_FROM_LIST_BASE - -1,-1 + 584,397 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Nets @@ -52,42 +53,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerMain @@ -135,6 +100,7 @@ 0 wxID_ANY Net name filter: + 0 0 @@ -160,29 +126,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -247,33 +190,7 @@ - - - - - - - - - - - - - - - - - - - - - - onFilterChange - - - - @@ -348,30 +265,7 @@ - onFilterChange - - - - - - - - - - - - - - - - - - - - - - @@ -390,58 +284,19 @@ 0 wxID_ANY - 400,300 + 500,300 m_netsList protected - + wxDV_HORIZ_RULES ; forward_declare - - - - - - - - - - - - - - - - - - onSelChanged - - - - - - - - - - - - - - - - - - - - onListSize - @@ -468,25 +323,31 @@ + 1 0 1 1 + 0 0 + Dock 0 Left 1 1 + 0 0 wxID_ANY - Export... + Create Report... + + 0 0 @@ -494,13 +355,15 @@ 0 1 - m_Export + m_ReportButt 1 protected 1 + + Resizable 1 @@ -515,30 +378,7 @@ - - - - - - - - - - - onExport - - - - - - - - - - - - - + onReport @@ -567,14 +407,6 @@ m_sdbSizer protected - - - - - - - - diff --git a/pcbnew/dialogs/dialog_select_net_from_list_base.h b/pcbnew/dialogs/dialog_select_net_from_list_base.h index a49334fdf2..5507c5e585 100644 --- a/pcbnew/dialogs/dialog_select_net_from_list_base.h +++ b/pcbnew/dialogs/dialog_select_net_from_list_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Dec 1 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_SELECT_NET_FROM_LIST_BASE_H__ -#define __DIALOG_SELECT_NET_FROM_LIST_BASE_H__ +#pragma once #include #include @@ -22,6 +21,9 @@ #include #include #include +#include +#include +#include #include #include @@ -34,29 +36,28 @@ class DIALOG_SELECT_NET_FROM_LIST_BASE : public DIALOG_SHIM { private: - + protected: wxStaticText* m_staticTextFilter; wxTextCtrl* m_textCtrlFilter; wxCheckBox* m_cbShowZeroPad; wxDataViewListCtrl* m_netsList; - wxButton* m_Export; + wxButton* m_ReportButt; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; - + // Virtual event handlers, overide them in your derived class virtual void onFilterChange( wxCommandEvent& event ) { event.Skip(); } virtual void onSelChanged( wxDataViewEvent& event ) { event.Skip(); } virtual void onListSize( wxSizeEvent& event ) { event.Skip(); } - virtual void onExport( wxMouseEvent& event ) { event.Skip(); } - - + virtual void onReport( wxCommandEvent& event ) { event.Skip(); } + + public: - - DIALOG_SELECT_NET_FROM_LIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Nets"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + DIALOG_SELECT_NET_FROM_LIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Nets"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 584,397 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_SELECT_NET_FROM_LIST_BASE(); - + }; -#endif //__DIALOG_SELECT_NET_FROM_LIST_BASE_H__