7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

CHANGED netclass assignments now done via canvas or via patterns.

This commit is contained in:
Jeff Young 2022-08-14 12:03:18 +01:00
parent 18ac169ac7
commit a9536b5de9
82 changed files with 2489 additions and 2610 deletions
3d-viewer/3d_canvas
common
eeschema
include
pcbnew
qa/unittests/pcbnew

View File

@ -644,7 +644,7 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
{
return wxString::Format( _( "Net %s\tNet class %s" ),
aItem->GetNet()->GetNetname(),
aItem->GetNet()->GetNetClassName() );
aItem->GetNet()->GetNetClass()->GetName() );
};
if( rollOverItem )

View File

@ -33,13 +33,14 @@
#include <confirm.h>
#include <grid_tricks.h>
#include <dialogs/panel_setup_netclasses.h>
#include <dialogs/wx_html_report_box.h>
#include <tool/tool_manager.h>
#include <widgets/wx_grid.h>
#include <string_utils.h>
#include <widgets/grid_color_swatch_helpers.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/grid_text_helpers.h>
#include <wx/treebook.h>
#include <project/net_settings.h>
// PCBNEW columns of netclasses grid
@ -73,14 +74,14 @@ wxArrayString g_lineStyleNames;
PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, EDA_DRAW_FRAME* aFrame,
NETCLASSES* aNetclasses,
std::shared_ptr<NET_SETTINGS> aNetSettings,
const std::vector<wxString>& aNetNames,
bool aIsEEschema ) :
PANEL_SETUP_NETCLASSES_BASE( aParent->GetTreebook() ),
m_frame( aFrame ),
m_parent( aParent ),
m_isEEschema( aIsEEschema ),
m_netclasses( aNetclasses ),
m_netSettings( aNetSettings ),
m_netNames( aNetNames ),
m_hoveredCol( -1 )
{
@ -104,7 +105,7 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, EDA_DRAW_
// Prevent Size events from firing before we are ready
Freeze();
m_netclassGrid->BeginBatch();
m_membershipGrid->BeginBatch();
m_assignmentGrid->BeginBatch();
if( m_isEEschema )
{
@ -155,19 +156,13 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, EDA_DRAW_
// Membership combobox editors require a bit more room, so increase the row size of
// all our grids for consistency
m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 );
m_membershipGrid->SetDefaultRowSize( m_membershipGrid->GetDefaultRowSize() + 4 );
m_assignmentGrid->SetDefaultRowSize( m_assignmentGrid->GetDefaultRowSize() + 4 );
m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) );
m_membershipGrid->PushEventHandler( new GRID_TRICKS( m_membershipGrid ) );
m_assignmentGrid->PushEventHandler( new GRID_TRICKS( m_assignmentGrid ) );
m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
m_membershipGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
// Set up the net name column of the netclass membership grid to read-only
wxGridCellAttr* attr = new wxGridCellAttr;
attr->SetReadOnly( true );
attr->SetRenderer( new GRID_CELL_ESCAPED_TEXT_RENDERER );
m_membershipGrid->SetColAttr( 0, attr );
m_assignmentGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
m_splitter->SetSashPosition( cfg->m_NetclassPanel.sash_pos );
@ -175,6 +170,9 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, EDA_DRAW_
m_addButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
m_removeButton->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
m_addAssignmentButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
m_removeAssignmentButton->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
// wxFormBuilder doesn't include this event...
m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ),
@ -188,8 +186,10 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, EDA_DRAW_
m_frame->Bind( UNITS_CHANGED, &PANEL_SETUP_NETCLASSES::onUnitsChanged, this );
m_netclassGrid->EndBatch();
m_membershipGrid->EndBatch();
m_assignmentGrid->EndBatch();
Thaw();
m_matchingNets->SetFont( KIUI::GetInfoFont( this ) );
}
@ -202,7 +202,7 @@ PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES()
// Delete the GRID_TRICKS.
m_netclassGrid->PopEventHandler( true );
m_membershipGrid->PopEventHandler( true );
m_assignmentGrid->PopEventHandler( true );
m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ),
@ -214,75 +214,71 @@ PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES()
void PANEL_SETUP_NETCLASSES::onUnitsChanged( wxCommandEvent& aEvent )
{
NETCLASSES tempNetClasses;
NETCLASSES* saveNetClasses = m_netclasses;
std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>( nullptr, "" );
std::shared_ptr<NET_SETTINGS> saveNetSettings = m_netSettings;
m_netclasses = &tempNetClasses; // No, address of stack var does not escape function
m_netSettings = tempNetSettings;
TransferDataFromWindow();
TransferDataToWindow();
m_netclasses = saveNetClasses;
m_netSettings = saveNetSettings;
aEvent.Skip();
}
static void netclassToGridRow( EDA_UNITS aUnits, wxGrid* aGrid, bool aIsEEschema, int aRow,
const NETCLASSPTR& nc )
{
aGrid->SetCellValue( aRow, GRID_NAME, nc->GetName() );
auto setCell =
[&]( int aCol, int aValue )
{
aGrid->SetCellValue( aRow, aCol, StringFromValue( aUnits, aValue, true ) );
};
if( aIsEEschema )
{
setCell( GRID_WIREWIDTH - EESCHEMA_COL_OFFSET, nc->GetWireWidth() );
setCell( GRID_BUSWIDTH - EESCHEMA_COL_OFFSET, nc->GetBusWidth() );
wxString colorAsString = nc->GetSchematicColor().ToWxString( wxC2S_CSS_SYNTAX );
aGrid->SetCellValue( aRow, GRID_SCHEMATIC_COLOR - EESCHEMA_COL_OFFSET, colorAsString );
int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
if( lineStyleIdx >= (int) g_lineStyleNames.size() )
lineStyleIdx = 0;
aGrid->SetCellValue( aRow, GRID_LINESTYLE - EESCHEMA_COL_OFFSET,
g_lineStyleNames[ lineStyleIdx ] );
}
else
{
setCell( GRID_CLEARANCE, nc->GetClearance() );
setCell( GRID_TRACKSIZE, nc->GetTrackWidth() );
setCell( GRID_VIASIZE, nc->GetViaDiameter() );
setCell( GRID_VIADRILL, nc->GetViaDrill() );
setCell( GRID_uVIASIZE, nc->GetuViaDiameter() );
setCell( GRID_uVIADRILL, nc->GetuViaDrill() );
setCell( GRID_DIFF_PAIR_WIDTH, nc->GetDiffPairWidth() );
setCell( GRID_DIFF_PAIR_GAP, nc->GetDiffPairGap() );
}
}
bool PANEL_SETUP_NETCLASSES::TransferDataToWindow()
{
std::map<wxString, wxString> netToNetclassMap;
std::map<wxString, wxString> staleNetMap;
EDA_UNITS units = m_frame->GetUserUnits();
int row = 0;
for( const wxString& candidate : m_netNames )
netToNetclassMap[ candidate ] = wxEmptyString;
auto setCell =
[&]( int aRow, int aCol, int aValue )
{
m_netclassGrid->SetCellValue( aRow, aCol, StringFromValue( units, aValue, true ) );
};
auto netclassToGridRow =
[&]( int aRow, const std::shared_ptr<NETCLASS>& nc )
{
m_netclassGrid->SetCellValue( aRow, GRID_NAME, nc->GetName() );
if( m_isEEschema )
{
setCell( aRow, GRID_WIREWIDTH - EESCHEMA_COL_OFFSET, nc->GetWireWidth() );
setCell( aRow, GRID_BUSWIDTH - EESCHEMA_COL_OFFSET, nc->GetBusWidth() );
wxString colorAsString = nc->GetSchematicColor().ToWxString( wxC2S_CSS_SYNTAX );
m_netclassGrid->SetCellValue( aRow, GRID_SCHEMATIC_COLOR - EESCHEMA_COL_OFFSET,
colorAsString );
int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
if( lineStyleIdx >= (int) g_lineStyleNames.size() )
lineStyleIdx = 0;
m_netclassGrid->SetCellValue( aRow, GRID_LINESTYLE - EESCHEMA_COL_OFFSET,
g_lineStyleNames[ lineStyleIdx ] );
}
else
{
setCell( aRow, GRID_CLEARANCE, nc->GetClearance() );
setCell( aRow, GRID_TRACKSIZE, nc->GetTrackWidth() );
setCell( aRow, GRID_VIASIZE, nc->GetViaDiameter() );
setCell( aRow, GRID_VIADRILL, nc->GetViaDrill() );
setCell( aRow, GRID_uVIASIZE, nc->GetuViaDiameter() );
setCell( aRow, GRID_uVIADRILL, nc->GetuViaDrill() );
setCell( aRow, GRID_DIFF_PAIR_WIDTH, nc->GetDiffPairWidth() );
setCell( aRow, GRID_DIFF_PAIR_GAP, nc->GetDiffPairGap() );
}
};
m_netclassGrid->ClearRows();
m_netclassGrid->AppendRows((int) m_netclasses->GetCount() + 1 ); // + 1 for default netclass
// enter the Default NETCLASS.
netclassToGridRow( m_frame->GetUserUnits(), m_netclassGrid, m_isEEschema, 0,
m_netclasses->GetDefault() );
m_netclassGrid->AppendRows( 1 );
netclassToGridRow( row++, m_netSettings->m_DefaultNetClass );
// make the Default NETCLASS name read-only
wxGridCellAttr* cellAttr = m_netclassGrid->GetOrCreateCellAttr( 0, GRID_NAME );
@ -290,64 +286,32 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow()
cellAttr->DecRef();
// enter other netclasses
int row = 1;
m_netclassGrid->AppendRows( (int) m_netSettings->m_NetClasses.size() );
for( NETCLASSES::iterator i = m_netclasses->begin(); i != m_netclasses->end(); ++i, ++row )
for( const auto& [ name, netclass ] : m_netSettings->m_NetClasses )
netclassToGridRow( row++, netclass );
m_assignmentGrid->ClearRows();
m_assignmentGrid->AppendRows( m_netSettings->m_NetClassPatternAssignments.size() );
row = 0;
for( const auto& [ matcher, netclassName ] : m_netSettings->m_NetClassPatternAssignments )
{
NETCLASSPTR netclass = i->second;
netclassToGridRow( m_frame->GetUserUnits(), m_netclassGrid, m_isEEschema, row, netclass );
for( const wxString& net : *netclass )
{
if( netToNetclassMap.count( net ) )
netToNetclassMap[ net ] = i->second->GetName();
else
staleNetMap[ net ] = i->second->GetName();
}
m_assignmentGrid->SetCellValue( row, 0, matcher->GetPattern() );
m_assignmentGrid->SetCellValue( row, 1, netclassName );
row++;
}
m_membershipGrid->ClearRows();
// add currently-assigned and candidate netnames to membership lists
for( const std::pair<const wxString, wxString>& ii : netToNetclassMap )
addNet( ii.first, ii.second, false );
for( const std::pair<const wxString, wxString>& ii : staleNetMap )
addNet( ii.first, ii.second, true );
return true;
}
void PANEL_SETUP_NETCLASSES::addNet( const wxString& netName, const wxString& netclass,
bool aStale )
{
int i = m_membershipGrid->GetNumberRows();
m_membershipGrid->AppendRows( 1 );
m_membershipGrid->SetCellValue( i, 0, netName );
if( aStale )
{
wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
m_membershipGrid->SetCellTextColour( i, 0, color );
}
if( netclass.IsEmpty() )
m_membershipGrid->SetCellValue( i, 1, NETCLASS::Default );
else
m_membershipGrid->SetCellValue( i, 1, netclass );
}
/*
* Populates drop-downs with the list of net classes
*/
void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns()
{
m_membershipGrid->CommitPendingChanges( true );
m_assignmentGrid->CommitPendingChanges( true );
wxArrayString netclassNames;
@ -361,49 +325,7 @@ void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns()
wxGridCellAttr* attr = new wxGridCellAttr;
attr->SetEditor( new wxGridCellChoiceEditor( netclassNames ) );
m_membershipGrid->SetColAttr( 1, attr );
m_assignNetClass->Set( netclassNames );
netclassNames.Insert( wxEmptyString, 0 );
m_netClassFilter->Set( netclassNames );
}
static void gridRowToNetclass( EDA_UNITS aUnits, wxGrid* grid, bool aIsEEschema, int row,
const NETCLASSPTR& nc )
{
nc->SetName( grid->GetCellValue( row, GRID_NAME ) );
auto getCell =
[&]( int aCol ) -> long long int
{
return ValueFromString( aUnits, grid->GetCellValue( row, aCol ) );
};
if( aIsEEschema )
{
nc->SetWireWidth( getCell( GRID_WIREWIDTH - EESCHEMA_COL_OFFSET ) );
nc->SetBusWidth( getCell( GRID_BUSWIDTH - EESCHEMA_COL_OFFSET ) );
wxString colorValue = grid->GetCellValue( row, GRID_SCHEMATIC_COLOR - EESCHEMA_COL_OFFSET );
nc->SetSchematicColor( wxColour( colorValue ) );
wxString lineStyle = grid->GetCellValue( row, GRID_LINESTYLE - EESCHEMA_COL_OFFSET );
nc->SetLineStyle( g_lineStyleNames.Index( lineStyle ) );
wxASSERT_MSG( nc->GetLineStyle() >= 0, "Line style name not found." );
}
else
{
nc->SetClearance( getCell( GRID_CLEARANCE ) );
nc->SetTrackWidth( getCell( GRID_TRACKSIZE ) );
nc->SetViaDiameter( getCell( GRID_VIASIZE ) );
nc->SetViaDrill( getCell( GRID_VIADRILL ) );
nc->SetuViaDiameter( getCell( GRID_uVIASIZE ) );
nc->SetuViaDrill( getCell( GRID_uVIADRILL ) );
nc->SetDiffPairWidth( getCell( GRID_DIFF_PAIR_WIDTH ) );
nc->SetDiffPairGap( getCell( GRID_DIFF_PAIR_GAP ) );
}
m_assignmentGrid->SetColAttr( 1, attr );
}
@ -412,34 +334,76 @@ bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow()
if( !Validate() )
return false;
m_netclasses->Clear();
EDA_UNITS units = m_frame->GetUserUnits();
int row = 0;
auto getCell =
[&]( int aRow, int aCol ) -> long long int
{
return ValueFromString( units, m_netclassGrid->GetCellValue( aRow, aCol ) );
};
auto getCellStr =
[&]( int aRow, int aCol ) -> wxString
{
return m_netclassGrid->GetCellValue( aRow, aCol );
};
auto gridRowToNetclass =
[&]( int row, const std::shared_ptr<NETCLASS>& nc )
{
nc->SetName( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
if( m_isEEschema )
{
nc->SetWireWidth( getCell( row, GRID_WIREWIDTH - EESCHEMA_COL_OFFSET ) );
nc->SetBusWidth( getCell( row, GRID_BUSWIDTH - EESCHEMA_COL_OFFSET ) );
wxString color = getCellStr( row, GRID_SCHEMATIC_COLOR - EESCHEMA_COL_OFFSET );
nc->SetSchematicColor( wxColour( color ) );
wxString lineStyle = getCellStr( row, GRID_LINESTYLE - EESCHEMA_COL_OFFSET );
nc->SetLineStyle( g_lineStyleNames.Index( lineStyle ) );
wxASSERT_MSG( nc->GetLineStyle() >= 0, "Line style name not found." );
}
else
{
nc->SetClearance( getCell( row, GRID_CLEARANCE ) );
nc->SetTrackWidth( getCell( row, GRID_TRACKSIZE ) );
nc->SetViaDiameter( getCell( row, GRID_VIASIZE ) );
nc->SetViaDrill( getCell( row, GRID_VIADRILL ) );
nc->SetuViaDiameter( getCell( row, GRID_uVIASIZE ) );
nc->SetuViaDrill( getCell( row, GRID_uVIADRILL ) );
nc->SetDiffPairWidth( getCell( row, GRID_DIFF_PAIR_WIDTH ) );
nc->SetDiffPairGap( getCell( row, GRID_DIFF_PAIR_GAP ) );
}
};
m_netSettings->m_NetClasses.clear();
// Copy the default NetClass:
gridRowToNetclass( m_frame->GetUserUnits(), m_netclassGrid, m_isEEschema, 0,
m_netclasses->GetDefault() );
gridRowToNetclass( row++, m_netSettings->m_DefaultNetClass );
// Copy other NetClasses:
for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
for( row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
{
auto nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
if( m_netclasses->Add( nc ) )
gridRowToNetclass( m_frame->GetUserUnits(), m_netclassGrid, m_isEEschema, row, nc );
gridRowToNetclass( row, nc );
m_netSettings->m_NetClasses[ nc->GetName() ] = nc;
}
// Now read all nets and push them in the corresponding netclass net buffer
for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
m_netSettings->m_NetClassPatternAssignments.clear();
for( row = 0; row < m_assignmentGrid->GetNumberRows(); ++row )
{
const wxString& netname = m_membershipGrid->GetCellValue( row, 0 );
const wxString& classname = m_membershipGrid->GetCellValue( row, 1 );
wxString pattern = m_assignmentGrid->GetCellValue( row, 0 );
wxString netclass = m_assignmentGrid->GetCellValue( row, 1 );
if( classname != NETCLASS::Default )
{
const NETCLASSPTR& nc = m_netclasses->Find( classname );
if( nc )
nc->Add( netname );
}
m_netSettings->m_NetClassPatternAssignments.push_back(
{
std::make_unique<EDA_COMBINED_MATCHER>( pattern, CTX_NETCLASS ),
netclass
} );
}
return true;
@ -486,10 +450,10 @@ void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging( wxGridEvent& event )
if( !oldName.IsEmpty() )
{
for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
for( int row = 0; row < m_assignmentGrid->GetNumberRows(); ++row )
{
if( m_membershipGrid->GetCellValue( row, 1 ) == oldName )
m_membershipGrid->SetCellValue( row, 1, newName );
if( m_assignmentGrid->GetCellValue( row, 1 ) == oldName )
m_assignmentGrid->SetCellValue( row, 1, newName );
}
}
@ -575,7 +539,7 @@ void PANEL_SETUP_NETCLASSES::OnAddNetclassClick( wxCommandEvent& event )
}
else
{
for( int col = GRID_FIRST_PCBNEW; col < GRID_END; col++ )
for( int col = GRID_FIRST_PCBNEW; col < GRID_FIRST_EESCHEMA; col++ )
m_netclassGrid->SetCellValue( row, col, m_netclassGrid->GetCellValue( 0, col ) );
}
@ -609,10 +573,10 @@ void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick( wxCommandEvent& event )
// reset the net class to default for members of the removed class
wxString classname = m_netclassGrid->GetCellValue( curRow, GRID_NAME );
for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
for( int row = 0; row < m_assignmentGrid->GetNumberRows(); ++row )
{
if( m_membershipGrid->GetCellValue( row, 1 ) == classname )
m_membershipGrid->SetCellValue( row, 1, NETCLASS::Default );
if( m_assignmentGrid->GetCellValue( row, 1 ) == classname )
m_assignmentGrid->SetCellValue( row, 1, NETCLASS::Default );
}
m_netclassGrid->DeleteRows( curRow, 1 );
@ -647,98 +611,63 @@ void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid( wxSizeEvent& event )
}
void PANEL_SETUP_NETCLASSES::AdjustMembershipGridColumns( int aWidth )
void PANEL_SETUP_NETCLASSES::OnAddAssignmentClick( wxCommandEvent& event )
{
if( !m_assignmentGrid->CommitPendingChanges() )
return;
int row = m_assignmentGrid->GetNumberRows();
m_assignmentGrid->AppendRows();
m_assignmentGrid->SetCellValue( row, 1, m_netSettings->m_DefaultNetClass->GetName() );
m_assignmentGrid->MakeCellVisible( row, 0 );
m_assignmentGrid->SetGridCursor( row, 0 );
m_assignmentGrid->EnableCellEditControl( true );
m_assignmentGrid->ShowCellEditControl();
}
void PANEL_SETUP_NETCLASSES::OnRemoveAssignmentClick( wxCommandEvent& event )
{
if( !m_assignmentGrid->CommitPendingChanges() )
return;
int curRow = m_assignmentGrid->GetGridCursorRow();
if( curRow < 0 )
{
return;
}
m_assignmentGrid->DeleteRows( curRow, 1 );
m_assignmentGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_assignmentGrid->GetGridCursorCol() );
m_assignmentGrid->SetGridCursor( std::max( 0, curRow-1 ), m_assignmentGrid->GetGridCursorCol() );
}
void PANEL_SETUP_NETCLASSES::AdjustAssignmentGridColumns( int aWidth )
{
// Account for scroll bars
aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x );
aWidth -= ( m_assignmentGrid->GetSize().x - m_assignmentGrid->GetClientSize().x );
// Set className column width to original className width from netclasses grid
int classNameWidth = m_originalColWidths[ 0 ];
m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
m_assignmentGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
}
void PANEL_SETUP_NETCLASSES::onmembershipPanelSize( wxSizeEvent& event )
void PANEL_SETUP_NETCLASSES::OnSizeAssignmentGrid( wxSizeEvent& event )
{
// When a class name choice widget is selected (activated), in
// wxGrid m_membershipGrid, resizing its wxGrid parent is not taken in account
// by the widget until it is deselected and stay in the old position.
// So we deselect it if this is the case
// Note also this is made here, not in OnSizeMembershipGrid because on Linux
// there are a lot of wxSizeEvent send to m_membershipGrid when opening a choice widget
int c_row = m_membershipGrid->GetGridCursorRow();
int c_col = m_membershipGrid->GetGridCursorCol();
if( c_row >= 0 && c_col == 1 ) // this means the class name choice widget is selected (opened)
m_membershipGrid->SetGridCursor( c_row, 0 ); // Close it
AdjustAssignmentGridColumns( event.GetSize().GetX());
event.Skip();
}
void PANEL_SETUP_NETCLASSES::OnSizeMembershipGrid( wxSizeEvent& event )
{
AdjustMembershipGridColumns( event.GetSize().GetX() );
event.Skip();
}
void PANEL_SETUP_NETCLASSES::doApplyFilters( bool aShowAll )
{
if( !m_membershipGrid->CommitPendingChanges() )
return;
wxString netClassFilter = m_netClassFilter->GetStringSelection();
wxString netFilter = m_netNameFilter->GetValue().MakeLower();
if( !netFilter.IsEmpty() )
netFilter = wxT( "*" ) + netFilter + wxT( "*" );
for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
{
wxString net = m_membershipGrid->GetCellValue( row, 0 );
wxString netClass = m_membershipGrid->GetCellValue( row, 1 );
bool show = true;
if( !aShowAll )
{
if( !netFilter.IsEmpty() && !net.MakeLower().Matches( netFilter ) )
show = false;
if( !netClassFilter.IsEmpty() && netClass != netClassFilter )
show = false;
}
if( show )
m_membershipGrid->ShowRow( row );
else
m_membershipGrid->HideRow( row );
}
}
void PANEL_SETUP_NETCLASSES::doAssignments( bool aAssignAll )
{
if( !m_membershipGrid->CommitPendingChanges() )
return;
wxArrayInt selectedRows = m_membershipGrid->GetSelectedRows();
for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
{
if( !m_membershipGrid->IsRowShown( row ) )
continue;
if( !aAssignAll && selectedRows.Index( row ) == wxNOT_FOUND )
continue;
m_membershipGrid->SetCellValue( row, 1, m_assignNetClass->GetStringSelection() );
}
}
void PANEL_SETUP_NETCLASSES::OnUpdateUI( wxUpdateUIEvent& event )
{
if( m_netclassesDirty )
@ -746,12 +675,50 @@ void PANEL_SETUP_NETCLASSES::OnUpdateUI( wxUpdateUIEvent& event )
rebuildNetclassDropdowns();
m_netclassesDirty = false;
}
int row = m_assignmentGrid->GetGridCursorRow();
wxString pattern = m_assignmentGrid->GetCellValue( row, 0 );
if( m_assignmentGrid->GetGridCursorCol() == 0 && m_assignmentGrid->IsCellEditControlShown() )
{
wxGridCellEditor* cellEditor = m_assignmentGrid->GetCellEditor( row, 0 );
if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
pattern = txt->GetValue();
cellEditor->DecRef();
}
if( pattern != m_lastPattern )
{
m_matchingNets->Clear();
if( !pattern.IsEmpty() )
{
EDA_COMBINED_MATCHER matcher( pattern, CTX_NETCLASS );
m_matchingNets->Report( wxString::Format( _( "<b>Nets matching '%s':</b>" ),
pattern ) );
for( const wxString& net : m_netNames )
{
int matches;
int offset;
if( matcher.Find( net, matches, offset ) && offset == 0 )
m_matchingNets->Report( net );
}
}
m_matchingNets->Flush();
m_lastPattern = pattern;
}
}
bool PANEL_SETUP_NETCLASSES::Validate()
{
if( !m_netclassGrid->CommitPendingChanges() || !m_membershipGrid->CommitPendingChanges() )
if( !m_netclassGrid->CommitPendingChanges() || !m_assignmentGrid->CommitPendingChanges() )
return false;
wxString msg;
@ -771,19 +738,19 @@ bool PANEL_SETUP_NETCLASSES::Validate()
}
void PANEL_SETUP_NETCLASSES::ImportSettingsFrom( NETCLASSES* aNetclasses )
void PANEL_SETUP_NETCLASSES::ImportSettingsFrom( const std::shared_ptr<NET_SETTINGS>& aNetSettings )
{
NETCLASSES* savedSettings = m_netclasses;
std::shared_ptr<NET_SETTINGS> savedSettings = m_netSettings;
m_netclasses = aNetclasses;
m_netSettings = aNetSettings;
TransferDataToWindow();
rebuildNetclassDropdowns();
m_netclassGrid->ForceRefresh();
m_membershipGrid->ForceRefresh();
m_assignmentGrid->ForceRefresh();
m_netclasses = savedSettings;
m_netSettings = savedSettings;
}

View File

@ -1,10 +1,11 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialogs/wx_html_report_box.h"
#include "widgets/wx_grid.h"
#include "panel_setup_netclasses_base.h"
@ -29,7 +30,7 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
m_netclassGrid = new WX_GRID( m_netclassesPane, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_DEFAULT|wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL );
// Grid
m_netclassGrid->CreateGrid( 1, 13 );
m_netclassGrid->CreateGrid( 3, 13 );
m_netclassGrid->EnableEditing( true );
m_netclassGrid->EnableGridLines( true );
m_netclassGrid->EnableDragGridSize( false );
@ -70,20 +71,20 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
buttonBoxSizer = new wxBoxSizer( wxHORIZONTAL );
m_addButton = new wxBitmapButton( m_netclassesPane, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
buttonBoxSizer->Add( m_addButton, 0, wxLEFT, 2 );
buttonBoxSizer->Add( m_addButton, 0, wxBOTTOM|wxLEFT, 2 );
buttonBoxSizer->Add( 5, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_removeButton = new wxBitmapButton( m_netclassesPane, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
buttonBoxSizer->Add( m_removeButton, 0, wxRIGHT|wxLEFT, 5 );
buttonBoxSizer->Add( m_removeButton, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
buttonBoxSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_colorDefaultHelpText = new wxStaticText( m_netclassesPane, wxID_ANY, _("Set color to transparent to use KiCad default color."), wxDefaultPosition, wxDefaultSize, 0 );
m_colorDefaultHelpText->Wrap( -1 );
buttonBoxSizer->Add( m_colorDefaultHelpText, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
buttonBoxSizer->Add( m_colorDefaultHelpText, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 10 );
bUpperSizer->Add( buttonBoxSizer, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
@ -94,141 +95,71 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
bUpperSizer->Fit( m_netclassesPane );
m_membershipPane = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bLowerSizer;
bLowerSizer = new wxBoxSizer( wxHORIZONTAL );
bLowerSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bLeft;
bLeft = new wxBoxSizer( wxVERTICAL );
m_staticText5 = new wxStaticText( m_membershipPane, wxID_ANY, _("Netclass assignments:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
bLowerSizer->Add( m_staticText5, 0, wxTOP|wxEXPAND, 8 );
wxStaticBoxSizer* sbFilters;
sbFilters = new wxStaticBoxSizer( new wxStaticBox( m_membershipPane, wxID_ANY, _("Filter Nets") ), wxVERTICAL );
wxBoxSizer* bColumns;
bColumns = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer9;
bSizer9 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer14;
bSizer14 = new wxBoxSizer( wxVERTICAL );
m_ncfilterLabel = new wxStaticText( sbFilters->GetStaticBox(), wxID_ANY, _("Net class filter:"), wxDefaultPosition, wxDefaultSize, 0 );
m_ncfilterLabel->Wrap( -1 );
m_ncfilterLabel->SetMinSize( wxSize( 120,-1 ) );
bSizer9->Add( m_ncfilterLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
wxArrayString m_netClassFilterChoices;
m_netClassFilter = new wxChoice( sbFilters->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_netClassFilterChoices, 0 );
m_netClassFilter->SetSelection( 0 );
bSizer9->Add( m_netClassFilter, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
sbFilters->Add( bSizer9, 0, wxEXPAND, 5 );
wxBoxSizer* bSizer101;
bSizer101 = new wxBoxSizer( wxHORIZONTAL );
m_filterLabel = new wxStaticText( sbFilters->GetStaticBox(), wxID_ANY, _("Net name filter:"), wxDefaultPosition, wxDefaultSize, 0 );
m_filterLabel->Wrap( -1 );
m_filterLabel->SetMinSize( wxSize( 120,-1 ) );
bSizer101->Add( m_filterLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_netNameFilter = new wxTextCtrl( sbFilters->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
bSizer101->Add( m_netNameFilter, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
sbFilters->Add( bSizer101, 0, wxEXPAND, 5 );
wxBoxSizer* bSizer131;
bSizer131 = new wxBoxSizer( wxHORIZONTAL );
m_showAllButton = new wxButton( sbFilters->GetStaticBox(), wxID_ANY, _("Show All Nets"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer131->Add( m_showAllButton, 1, wxLEFT|wxTOP, 5 );
bSizer131->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_filterNetsButton = new wxButton( sbFilters->GetStaticBox(), wxID_ANY, _("Apply Filters"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer131->Add( m_filterNetsButton, 1, wxRIGHT|wxTOP, 5 );
sbFilters->Add( bSizer131, 1, wxEXPAND|wxTOP|wxBOTTOM, 6 );
bLeft->Add( sbFilters, 0, wxEXPAND|wxBOTTOM, 5 );
bLeft->Add( 0, 0, 1, wxEXPAND, 5 );
wxStaticBoxSizer* sbEdit;
sbEdit = new wxStaticBoxSizer( new wxStaticBox( m_membershipPane, wxID_ANY, _("Assign Net Class") ), wxVERTICAL );
wxBoxSizer* bSizer11;
bSizer11 = new wxBoxSizer( wxHORIZONTAL );
m_assignLabel = new wxStaticText( sbEdit->GetStaticBox(), wxID_ANY, _("New net class:"), wxDefaultPosition, wxDefaultSize, 0 );
m_assignLabel->Wrap( -1 );
m_assignLabel->SetMinSize( wxSize( 120,-1 ) );
bSizer11->Add( m_assignLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
wxArrayString m_assignNetClassChoices;
m_assignNetClass = new wxChoice( sbEdit->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_assignNetClassChoices, 0 );
m_assignNetClass->SetSelection( 0 );
bSizer11->Add( m_assignNetClass, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbEdit->Add( bSizer11, 0, wxEXPAND, 5 );
wxBoxSizer* bSizer12;
bSizer12 = new wxBoxSizer( wxHORIZONTAL );
m_assignAllButton = new wxButton( sbEdit->GetStaticBox(), wxID_ANY, _("Assign To All Listed Nets"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer12->Add( m_assignAllButton, 1, wxBOTTOM|wxLEFT|wxTOP, 5 );
bSizer12->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_assignSelectedButton = new wxButton( sbEdit->GetStaticBox(), wxID_ANY, _("Assign To Selected Nets"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer12->Add( m_assignSelectedButton, 1, wxBOTTOM|wxRIGHT|wxTOP, 5 );
sbEdit->Add( bSizer12, 0, wxEXPAND|wxTOP, 6 );
bLeft->Add( sbEdit, 0, wxEXPAND|wxTOP, 8 );
bLowerSizer->Add( bLeft, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
wxBoxSizer* bRight;
bRight = new wxBoxSizer( wxVERTICAL );
m_membershipGrid = new WX_GRID( m_membershipPane, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_DEFAULT );
m_assignmentGrid = new WX_GRID( m_membershipPane, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_DEFAULT );
// Grid
m_membershipGrid->CreateGrid( 0, 2 );
m_membershipGrid->EnableEditing( true );
m_membershipGrid->EnableGridLines( true );
m_membershipGrid->EnableDragGridSize( false );
m_membershipGrid->SetMargins( 0, 0 );
m_assignmentGrid->CreateGrid( 5, 2 );
m_assignmentGrid->EnableEditing( true );
m_assignmentGrid->EnableGridLines( true );
m_assignmentGrid->EnableDragGridSize( false );
m_assignmentGrid->SetMargins( 0, 0 );
// Columns
m_membershipGrid->EnableDragColMove( false );
m_membershipGrid->EnableDragColSize( true );
m_membershipGrid->SetColLabelValue( 0, _("Net") );
m_membershipGrid->SetColLabelValue( 1, _("Net Class") );
m_membershipGrid->SetColLabelSize( 24 );
m_membershipGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
m_assignmentGrid->SetColSize( 0, 400 );
m_assignmentGrid->SetColSize( 1, 160 );
m_assignmentGrid->EnableDragColMove( false );
m_assignmentGrid->EnableDragColSize( true );
m_assignmentGrid->SetColLabelValue( 0, _("Pattern") );
m_assignmentGrid->SetColLabelValue( 1, _("Net Class") );
m_assignmentGrid->SetColLabelSize( 24 );
m_assignmentGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows
m_membershipGrid->EnableDragRowSize( true );
m_membershipGrid->SetRowLabelSize( 0 );
m_membershipGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
m_assignmentGrid->EnableDragRowSize( true );
m_assignmentGrid->SetRowLabelSize( 0 );
m_assignmentGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Label Appearance
// Cell Defaults
m_membershipGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bRight->Add( m_membershipGrid, 1, wxEXPAND|wxBOTTOM|wxLEFT, 5 );
m_assignmentGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bSizer14->Add( m_assignmentGrid, 1, wxEXPAND, 5 );
bLowerSizer->Add( bRight, 1, wxEXPAND|wxTOP|wxLEFT, 5 );
bColumns->Add( bSizer14, 3, wxEXPAND, 5 );
m_matchingNets = new WX_HTML_REPORT_BOX( m_membershipPane, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
bColumns->Add( m_matchingNets, 2, wxEXPAND|wxLEFT, 15 );
bLowerSizer->Add( bColumns, 1, wxEXPAND|wxTOP, 3 );
wxBoxSizer* buttonBoxSizer1;
buttonBoxSizer1 = new wxBoxSizer( wxHORIZONTAL );
m_addAssignmentButton = new wxBitmapButton( m_membershipPane, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
buttonBoxSizer1->Add( m_addAssignmentButton, 0, 0, 2 );
buttonBoxSizer1->Add( 5, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_removeAssignmentButton = new wxBitmapButton( m_membershipPane, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
buttonBoxSizer1->Add( m_removeAssignmentButton, 0, wxRIGHT|wxLEFT, 5 );
bLowerSizer->Add( buttonBoxSizer1, 0, wxEXPAND|wxTOP, 5 );
m_membershipPane->SetSizer( bLowerSizer );
@ -251,12 +182,10 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
m_addButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAddNetclassClick ), NULL, this );
m_removeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnRemoveNetclassClick ), NULL, this );
m_membershipPane->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::onmembershipPanelSize ), NULL, this );
m_netNameFilter->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this );
m_showAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnShowAll ), NULL, this );
m_filterNetsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this );
m_assignAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignAll ), NULL, this );
m_assignSelectedButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignSelected ), NULL, this );
m_membershipGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeMembershipGrid ), NULL, this );
m_assignmentGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeAssignmentGrid ), NULL, this );
m_assignmentGrid->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnUpdateUI ), NULL, this );
m_addAssignmentButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAddAssignmentClick ), NULL, this );
m_removeAssignmentButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnRemoveAssignmentClick ), NULL, this );
}
PANEL_SETUP_NETCLASSES_BASE::~PANEL_SETUP_NETCLASSES_BASE()
@ -267,11 +196,9 @@ PANEL_SETUP_NETCLASSES_BASE::~PANEL_SETUP_NETCLASSES_BASE()
m_addButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAddNetclassClick ), NULL, this );
m_removeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnRemoveNetclassClick ), NULL, this );
m_membershipPane->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::onmembershipPanelSize ), NULL, this );
m_netNameFilter->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this );
m_showAllButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnShowAll ), NULL, this );
m_filterNetsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this );
m_assignAllButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignAll ), NULL, this );
m_assignSelectedButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignSelected ), NULL, this );
m_membershipGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeMembershipGrid ), NULL, this );
m_assignmentGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeAssignmentGrid ), NULL, this );
m_assignmentGrid->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnUpdateUI ), NULL, this );
m_addAssignmentButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAddAssignmentClick ), NULL, this );
m_removeAssignmentButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnRemoveAssignmentClick ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021)
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -11,6 +11,7 @@
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_GRID;
class WX_HTML_REPORT_BOX;
#include <wx/colour.h>
#include <wx/settings.h>
@ -26,9 +27,7 @@ class WX_GRID;
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/choice.h>
#include <wx/textctrl.h>
#include <wx/statbox.h>
#include <wx/html/htmlwin.h>
#include <wx/splitter.h>
///////////////////////////////////////////////////////////////////////////
@ -48,17 +47,11 @@ class PANEL_SETUP_NETCLASSES_BASE : public wxPanel
wxBitmapButton* m_removeButton;
wxStaticText* m_colorDefaultHelpText;
wxPanel* m_membershipPane;
wxStaticText* m_ncfilterLabel;
wxChoice* m_netClassFilter;
wxStaticText* m_filterLabel;
wxTextCtrl* m_netNameFilter;
wxButton* m_showAllButton;
wxButton* m_filterNetsButton;
wxStaticText* m_assignLabel;
wxChoice* m_assignNetClass;
wxButton* m_assignAllButton;
wxButton* m_assignSelectedButton;
WX_GRID* m_membershipGrid;
wxStaticText* m_staticText5;
WX_GRID* m_assignmentGrid;
WX_HTML_REPORT_BOX* m_matchingNets;
wxBitmapButton* m_addAssignmentButton;
wxBitmapButton* m_removeAssignmentButton;
// Virtual event handlers, override them in your derived class
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
@ -66,11 +59,9 @@ class PANEL_SETUP_NETCLASSES_BASE : public wxPanel
virtual void OnAddNetclassClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveNetclassClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onmembershipPanelSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnApplyFilters( wxCommandEvent& event ) { event.Skip(); }
virtual void OnShowAll( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAssignAll( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAssignSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSizeMembershipGrid( wxSizeEvent& event ) { event.Skip(); }
virtual void OnSizeAssignmentGrid( wxSizeEvent& event ) { event.Skip(); }
virtual void OnAddAssignmentClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveAssignmentClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-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 as published by the
@ -28,7 +28,8 @@
WX_HTML_REPORT_BOX::WX_HTML_REPORT_BOX( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style ) :
HTML_WINDOW( parent, id, pos, size, style ),
m_units( EDA_UNITS::MILLIMETRES ), m_immediateMode( false )
m_units( EDA_UNITS::MILLIMETRES ),
m_immediateMode( false )
{
Flush();

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@inpg.fr
* Copyright (C) 2009-2020 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2009-2022 KiCad Developers, see change_log.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
@ -76,90 +76,3 @@ NETCLASS::~NETCLASS()
}
NETCLASSES::NETCLASSES()
{
m_default = std::make_shared<NETCLASS>( NETCLASS::Default );
}
NETCLASSES::~NETCLASSES()
{
}
bool NETCLASSES::Add( const NETCLASSPTR& aNetClass )
{
const wxString& name = aNetClass->GetName();
if( name == NETCLASS::Default )
{
m_default = aNetClass;
return true;
}
// Test for an existing netclass:
if( !Find( name ) )
{
// name not found, take ownership
m_NetClasses[name] = aNetClass;
return true;
}
else
{
// name already exists
// do not "take ownership" and return false telling caller such.
return false;
}
}
NETCLASSPTR NETCLASSES::Remove( const wxString& aNetName )
{
NETCLASS_MAP::iterator found = m_NetClasses.find( aNetName );
if( found != m_NetClasses.end() )
{
std::shared_ptr<NETCLASS> netclass = found->second;
m_NetClasses.erase( found );
return netclass;
}
return NETCLASSPTR();
}
NETCLASSPTR NETCLASSES::Find( const wxString& aName ) const
{
if( aName == NETCLASS::Default )
return GetDefault();
NETCLASS_MAP::const_iterator found = m_NetClasses.find( aName );
if( found == m_NetClasses.end() )
return NETCLASSPTR();
else
return found->second;
}
#if defined(DEBUG)
void NETCLASS::Show( int nestLevel, std::ostream& os ) const
{
// for now, make it look like XML:
//NestedSpace( nestLevel, os )
os << '<' << GetClass().Lower().mb_str() << ">\n";
for( const_iterator i = begin(); i!=end(); ++i )
{
// NestedSpace( nestLevel+1, os ) << *i;
os << TO_UTF8( *i );
}
// NestedSpace( nestLevel, os )
os << "</" << GetClass().Lower().mb_str() << ">\n";
}
#endif

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jon Evans <jon@craftyjon.com>
*
* This program is free software: you can redistribute it and/or modify it
@ -21,7 +21,6 @@
#include <nlohmann/json.hpp>
#include <project/net_settings.h>
#include <settings/parameters.h>
#include <settings/json_settings_internals.h>
@ -32,7 +31,8 @@
// const int netSettingsSchemaVersion = 0;
// const int netSettingsSchemaVersion = 1; // new overbar syntax
const int netSettingsSchemaVersion = 2; // exclude buses from netclass members
// const int netSettingsSchemaVersion = 2; // exclude buses from netclass members
const int netSettingsSchemaVersion = 3; // netclass assignment patterns
static OPT<int> getInPcbUnits( const nlohmann::json& aObj, const std::string& aKey,
@ -55,84 +55,123 @@ static int getInSchUnits( const nlohmann::json& aObj, const std::string& aKey, i
NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
NESTED_SETTINGS( "net_settings", netSettingsSchemaVersion, aParent, aPath ),
m_NetClasses()
NESTED_SETTINGS( "net_settings", netSettingsSchemaVersion, aParent, aPath )
{
m_DefaultNetClass = std::make_shared<NETCLASS>( NETCLASS::Default );
m_DefaultNetClass->SetDescription( _( "This is the default net class." ) );
auto saveNetclass =
[]( nlohmann::json& json_array, const std::shared_ptr<NETCLASS>& nc )
{
// Note: we're in common/, but we do happen to know which of these
// fields are used in which units system.
nlohmann::json nc_json = {
{ "name", nc->GetName().ToUTF8() },
{ "wire_width", SchIu2Mils( nc->GetWireWidth() ) },
{ "bus_width", SchIu2Mils( nc->GetBusWidth() ) },
{ "line_style", nc->GetLineStyle() },
{ "schematic_color", nc->GetSchematicColor() },
{ "pcb_color", nc->GetPcbColor() }
};
auto saveInPcbUnits =
[]( nlohmann::json& json, const std::string& aKey, int aValue )
{
json.push_back( { aKey, PcbIu2mm( aValue ) } );
};
if( nc->HasClearance() )
saveInPcbUnits( nc_json, "clearance", nc->GetClearance() );
if( nc->HasTrackWidth() )
saveInPcbUnits( nc_json, "track_width", nc->GetTrackWidth() );
if( nc->HasViaDiameter() )
saveInPcbUnits( nc_json, "via_diameter", nc->GetViaDiameter() );
if( nc->HasViaDrill() )
saveInPcbUnits( nc_json, "via_drill", nc->GetViaDrill() );
if( nc->HasuViaDiameter() )
saveInPcbUnits( nc_json, "microvia_diameter", nc->GetuViaDiameter() );
if( nc->HasuViaDrill() )
saveInPcbUnits( nc_json, "microvia_drill", nc->GetuViaDrill() );
if( nc->HasDiffPairWidth() )
saveInPcbUnits( nc_json, "diff_pair_width", nc->GetDiffPairWidth() );
if( nc->HasDiffPairGap() )
saveInPcbUnits( nc_json, "diff_pair_gap", nc->GetDiffPairGap() );
if( nc->HasDiffPairViaGap() )
saveInPcbUnits( nc_json, "diff_pair_via_gap", nc->GetDiffPairViaGap() );
json_array.push_back( nc_json );
};
auto readNetClass =
[]( const nlohmann::json& entry )
{
wxString name = entry["name"];
std::shared_ptr<NETCLASS> nc = std::make_shared<NETCLASS>( name );
if( auto value = getInPcbUnits( entry, "clearance" ) )
nc->SetClearance( *value );
if( auto value = getInPcbUnits( entry, "track_width" ) )
nc->SetTrackWidth( *value );
if( auto value = getInPcbUnits( entry, "via_diameter" ) )
nc->SetViaDiameter( *value );
if( auto value = getInPcbUnits( entry, "via_drill" ) )
nc->SetViaDrill( *value );
if( auto value = getInPcbUnits( entry, "microvia_diameter" ) )
nc->SetuViaDiameter( *value );
if( auto value = getInPcbUnits( entry, "microvia_drill" ) )
nc->SetuViaDrill( *value );
if( auto value = getInPcbUnits( entry, "diff_pair_width" ) )
nc->SetDiffPairWidth( *value );
if( auto value = getInPcbUnits( entry, "diff_pair_gap" ) )
nc->SetDiffPairGap( *value );
if( auto value = getInPcbUnits( entry, "diff_pair_via_gap" ) )
nc->SetDiffPairViaGap( *value );
nc->SetWireWidth( getInSchUnits( entry, "wire_width", nc->GetWireWidth() ) );
nc->SetBusWidth( getInSchUnits( entry, "bus_width", nc->GetBusWidth() ) );
if( entry.contains( "line_style" ) && entry["line_style"].is_number() )
nc->SetLineStyle( entry["line_style"].get<int>() );
if( entry.contains( "pcb_color" ) && entry["pcb_color"].is_string() )
nc->SetPcbColor( entry["pcb_color"].get<KIGFX::COLOR4D>() );
if( entry.contains( "schematic_color" )
&& entry["schematic_color"].is_string() )
{
nc->SetSchematicColor( entry["schematic_color"].get<KIGFX::COLOR4D>() );
}
return nc;
};
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "classes",
[&]() -> nlohmann::json
{
nlohmann::json ret = nlohmann::json::array();
NETCLASSPTR nc = m_NetClasses.GetDefault();
NETCLASSES::const_iterator nc_ii = m_NetClasses.begin();
if( m_DefaultNetClass )
saveNetclass( ret, m_DefaultNetClass );
for( unsigned int idx = 0; idx <= m_NetClasses.GetCount(); idx++ )
{
if( idx > 0 )
{
nc = nc_ii->second;
++nc_ii;
}
// Note: we're in common/, but we do happen to know which of these fields
// are used in which units system.
nlohmann::json nc_json = {
{ "name", nc->GetName().ToUTF8() },
{ "wire_width", SchIu2Mils( nc->GetWireWidth() ) },
{ "bus_width", SchIu2Mils( nc->GetBusWidth() ) },
{ "line_style", nc->GetLineStyle() },
{ "schematic_color", nc->GetSchematicColor() },
{ "pcb_color", nc->GetPcbColor() }
};
auto saveInPcbUnits =
[]( nlohmann::json& json, const std::string& aKey, int aValue )
{
json.push_back( { aKey, PcbIu2mm( aValue ) } );
};
if( nc->HasClearance() )
saveInPcbUnits( nc_json, "clearance", nc->GetClearance() );
if( nc->HasTrackWidth() )
saveInPcbUnits( nc_json, "track_width", nc->GetTrackWidth() );
if( nc->HasViaDiameter() )
saveInPcbUnits( nc_json, "via_diameter", nc->GetViaDiameter() );
if( nc->HasViaDrill() )
saveInPcbUnits( nc_json, "via_drill", nc->GetViaDrill() );
if( nc->HasuViaDiameter() )
saveInPcbUnits( nc_json, "microvia_diameter", nc->GetuViaDiameter() );
if( nc->HasuViaDrill() )
saveInPcbUnits( nc_json, "microvia_drill", nc->GetuViaDrill() );
if( nc->HasDiffPairWidth() )
saveInPcbUnits( nc_json, "diff_pair_width", nc->GetDiffPairWidth() );
if( nc->HasDiffPairGap() )
saveInPcbUnits( nc_json, "diff_pair_gap", nc->GetDiffPairGap() );
if( nc->HasDiffPairViaGap() )
saveInPcbUnits( nc_json, "diff_pair_via_gap", nc->GetDiffPairViaGap() );
if( idx > 0 ) // No need to store members of Default nc
{
nlohmann::json membersJson = nlohmann::json::array();
for( const wxString& member : *nc )
{
if( !member.empty() )
membersJson.push_back( member );
}
nc_json["nets"] = membersJson;
}
ret.push_back( nc_json );
}
for( const auto& [ name, netclass ] : m_NetClasses )
saveNetclass( ret, netclass );
return ret;
},
@ -141,95 +180,19 @@ NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
if( !aJson.is_array() )
return;
m_NetClasses.Clear();
m_NetClassAssignments.clear();
NETCLASSPTR nc;
NETCLASSPTR defaultClass = m_NetClasses.GetDefault();
m_NetClasses.clear();
for( const nlohmann::json& entry : aJson )
{
if( !entry.is_object() || !entry.contains( "name" ) )
continue;
wxString name = entry["name"];
std::shared_ptr<NETCLASS> nc = readNetClass( entry );
if( name == defaultClass->GetName() )
nc = defaultClass;
if( nc->GetName() == NETCLASS::Default )
m_DefaultNetClass = nc;
else
nc = std::make_shared<NETCLASS>( name );
if( auto value = getInPcbUnits( entry, "clearance" ) )
nc->SetClearance( *value );
if( auto value = getInPcbUnits( entry, "track_width" ) )
nc->SetTrackWidth( *value );
if( auto value = getInPcbUnits( entry, "via_diameter" ) )
nc->SetViaDiameter( *value );
if( auto value = getInPcbUnits( entry, "via_drill" ) )
nc->SetViaDrill( *value );
if( auto value = getInPcbUnits( entry, "microvia_diameter" ) )
nc->SetuViaDiameter( *value );
if( auto value = getInPcbUnits( entry, "microvia_drill" ) )
nc->SetuViaDrill( *value );
if( auto value = getInPcbUnits( entry, "diff_pair_width" ) )
nc->SetDiffPairWidth( *value );
if( auto value = getInPcbUnits( entry, "diff_pair_gap" ) )
nc->SetDiffPairGap( *value );
if( auto value = getInPcbUnits( entry, "diff_pair_via_gap" ) )
nc->SetDiffPairViaGap( *value );
nc->SetWireWidth( getInSchUnits( entry, "wire_width", nc->GetWireWidth() ) );
nc->SetBusWidth( getInSchUnits( entry, "bus_width", nc->GetBusWidth() ) );
if( entry.contains( "line_style" ) && entry["line_style"].is_number() )
nc->SetLineStyle( entry["line_style"].get<int>() );
if( entry.contains( "nets" ) && entry["nets"].is_array() )
{
for( const auto& net : entry["nets"].items() )
{
wxString netname = net.value().get<wxString>();
if( m_schemaVersion < 2 )
{
// Strip out buses from older 5.99 implementations. They were
// a world of hurt, never fully functional, and are functionally
// replaced by assigning a netclass to a bus on the canvas.
wxString unescaped = UnescapeString( netname );
wxString prefix;
std::vector<wxString> members;
if( ParseBusVector( unescaped, &prefix, &members ) )
continue;
else if( ParseBusGroup( unescaped, &prefix, &members ) )
continue;
}
nc->Add( netname );
}
}
if( entry.contains( "pcb_color" ) && entry["pcb_color"].is_string() )
nc->SetPcbColor( entry["pcb_color"].get<KIGFX::COLOR4D>() );
if( entry.contains( "schematic_color" )
&& entry["schematic_color"].is_string() )
{
nc->SetSchematicColor( entry["schematic_color"].get<KIGFX::COLOR4D>() );
}
if( nc != defaultClass )
m_NetClasses.Add( nc );
for( const wxString& net : *nc )
m_NetClassAssignments[ net ] = nc->GetName();
m_NetClasses[ nc->GetName() ] = nc;
}
},
{} ) );
@ -239,10 +202,10 @@ NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
{
nlohmann::json ret = {};
for( const auto& pair : m_PcbNetColors )
for( const auto& [ netname, color ] : m_NetColorAssignments )
{
std::string key( pair.first.ToUTF8() );
ret[key] = pair.second;
std::string key( netname.ToUTF8() );
ret[key] = color;
}
return ret;
@ -252,17 +215,91 @@ NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
if( !aJson.is_object() )
return;
m_PcbNetColors.clear();
m_NetColorAssignments.clear();
for( const auto& pair : aJson.items() )
{
wxString key( pair.key().c_str(), wxConvUTF8 );
m_PcbNetColors[key] = pair.value().get<KIGFX::COLOR4D>();
m_NetColorAssignments[key] = pair.value().get<KIGFX::COLOR4D>();
}
},
{} ) );
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "netclass_assignments",
[&]() -> nlohmann::json
{
nlohmann::json ret = {};
for( const auto& [ netname, netclassName ] : m_NetClassLabelAssignments )
{
std::string key( netname.ToUTF8() );
ret[key] = netclassName;
}
return ret;
},
[&]( const nlohmann::json& aJson )
{
if( !aJson.is_object() )
return;
m_NetClassLabelAssignments.clear();
for( const auto& pair : aJson.items() )
{
wxString key( pair.key().c_str(), wxConvUTF8 );
m_NetClassLabelAssignments[key] = pair.value().get<wxString>();
}
},
{} ) );
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "netclass_patterns",
[&]() -> nlohmann::json
{
nlohmann::json ret = nlohmann::json::array();
for( const auto& [ matcher, netclassName ] : m_NetClassPatternAssignments )
{
nlohmann::json pattern_json = {
{ "pattern", matcher->GetPattern().ToUTF8() },
{ "netclass", netclassName.ToUTF8() }
};
ret.push_back( pattern_json );
}
return ret;
},
[&]( const nlohmann::json& aJson )
{
if( !aJson.is_array() )
return;
m_NetClassPatternAssignments.clear();
for( const nlohmann::json& entry : aJson )
{
if( !entry.is_object() )
continue;
if( entry.contains( "pattern" ) && entry["pattern"].is_string()
&& entry.contains( "netclass" ) && entry["netclass"].is_string() )
{
wxString pattern = entry["pattern"].get<wxString>();
wxString netclass = entry["netclass"].get<wxString>();
m_NetClassPatternAssignments.push_back(
{
std::make_unique<EDA_COMBINED_MATCHER>( pattern, CTX_NETCLASS ),
netclass
} );
}
}
},
{} ) );
registerMigration( 0, 1, std::bind( &NET_SETTINGS::migrateSchema0to1, this ) );
registerMigration( 2, 3, std::bind( &NET_SETTINGS::migrateSchema2to3, this ) );
}
@ -299,16 +336,67 @@ bool NET_SETTINGS::migrateSchema0to1()
}
const wxString& NET_SETTINGS::GetNetclassName( const wxString& aNetName ) const
bool NET_SETTINGS::migrateSchema2to3()
{
static wxString defaultNetname = NETCLASS::Default;
if( m_internals->contains( "classes" ) && m_internals->At( "classes" ).is_array() )
{
nlohmann::json patterns = nlohmann::json::array();
auto it = m_NetClassAssignments.find( aNetName );
for( auto& netClass : m_internals->At( "classes" ).items() )
{
if( netClass.value().contains( "name" )
&& netClass.value().contains( "nets" )
&& netClass.value()["nets"].is_array() )
{
wxString netClassName = netClass.value()["name"].get<wxString>();
if( it == m_NetClassAssignments.end() )
return defaultNetname;
else
return it->second;
for( auto& net : netClass.value()["nets"].items() )
{
nlohmann::json pattern_json = {
{ "pattern", net.value().get<wxString>() },
{ "netclass", netClassName }
};
patterns.push_back( pattern_json );
}
}
}
m_internals->SetFromString( "netclass_patterns", patterns );
}
return true;
}
std::shared_ptr<NETCLASS> NET_SETTINGS::GetEffectiveNetClass( const wxString& aNetName ) const
{
auto getNetclass =
[&]( const wxString& netclass )
{
auto ii = m_NetClasses.find( netclass );
if( ii == m_NetClasses.end() )
return m_DefaultNetClass;
else
return ii->second;
};
auto it = m_NetClassLabelAssignments.find( aNetName );
if( it != m_NetClassLabelAssignments.end() )
return getNetclass( it->second );
for( const auto& [ matcher, netclassName ] : m_NetClassPatternAssignments )
{
int matches;
int offset;
if( matcher->Find( aNetName, matches, offset ) && offset == 0 )
return getNetclass( netclassName );
}
return m_DefaultNetClass;
}
@ -534,15 +622,3 @@ bool NET_SETTINGS::ParseBusGroup( const wxString& aGroup, wxString* aName,
return false;
}
void NET_SETTINGS::RebuildNetClassAssignments()
{
m_NetClassAssignments.clear();
for( const std::pair<const wxString, NETCLASSPTR>& netclass : m_NetClasses )
{
for( const wxString& net : *netclass.second )
m_NetClassAssignments[ net ] = netclass.second->GetName();
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-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 as published by the
@ -682,7 +682,7 @@ template bool JSON_SETTINGS::fromLegacy<int>( wxConfigBase*, const std::string&,
const std::string& );
template bool JSON_SETTINGS::fromLegacy<double>( wxConfigBase*, const std::string&,
const std::string& );
const std::string& );
template bool JSON_SETTINGS::fromLegacy<bool>( wxConfigBase*, const std::string&,
const std::string& );
@ -749,7 +749,7 @@ void JSON_SETTINGS::AddNestedSettings( NESTED_SETTINGS* aSettings )
void JSON_SETTINGS::ReleaseNestedSettings( NESTED_SETTINGS* aSettings )
{
if( !aSettings )
if( !aSettings || !m_manager )
return;
auto it = std::find_if( m_nested_settings.begin(), m_nested_settings.end(),

View File

@ -57,6 +57,8 @@ set( EESCHEMA_SCH_PLUGINS_CADSTAR
set( EESCHEMA_DLGS
dialogs/dialog_annotate.cpp
dialogs/dialog_annotate_base.cpp
dialogs/dialog_assign_netclass.cpp
dialogs/dialog_assign_netclass_base.cpp
dialogs/dialog_bom.cpp
dialogs/dialog_bom_base.cpp
dialogs/dialog_bus_manager.cpp

View File

@ -41,6 +41,8 @@
#include <sch_text.h>
#include <schematic.h>
#include <connection_graph.h>
#include <project/project_file.h>
#include <project/net_settings.h>
#include <widgets/ui_common.h>
#include <string_utils.h>
#include <thread_pool.h>
@ -332,6 +334,31 @@ const wxString CONNECTION_SUBGRAPH::GetNameForDriver( SCH_ITEM* aItem ) const
}
const wxString CONNECTION_SUBGRAPH::GetNetclassForDriver( SCH_ITEM* aItem ) const
{
wxString netclass;
aItem->RunOnChildren(
[&]( SCH_ITEM* aChild )
{
if( aChild->Type() == SCH_FIELD_T )
{
SCH_FIELD* field = static_cast<SCH_FIELD*>( aChild );
if( field->GetCanonicalName() == wxT( "Netclass" ) )
{
netclass = field->GetText();
return false;
}
}
return true;
} );
return netclass;
}
void CONNECTION_SUBGRAPH::Absorb( CONNECTION_SUBGRAPH* aOther )
{
wxASSERT( m_sheet == aOther->m_sheet );
@ -492,7 +519,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
PROF_TIMER build_graph( "buildConnectionGraph" );
buildConnectionGraph();
buildConnectionGraph( aChangedItemHandler );
if( wxLog::IsAllowedTraceMask( ConnProfileMask ) )
build_graph.Show();
@ -1203,29 +1230,32 @@ void CONNECTION_GRAPH::processSubGraphs()
// Also check the main driving connection
connections_to_check.push_back( std::make_shared<SCH_CONNECTION>( *connection ) );
auto add_connections_to_check = [&] ( CONNECTION_SUBGRAPH* aSubgraph ) {
for( SCH_ITEM* possible_driver : aSubgraph->m_items )
{
if( possible_driver == aSubgraph->m_driver )
continue;
auto c = getDefaultConnection( possible_driver, aSubgraph );
if( c )
auto add_connections_to_check =
[&] ( CONNECTION_SUBGRAPH* aSubgraph )
{
if( c->Type() != aSubgraph->m_driver_connection->Type() )
continue;
for( SCH_ITEM* possible_driver : aSubgraph->m_items )
{
if( possible_driver == aSubgraph->m_driver )
continue;
if( c->Name( true ) == aSubgraph->m_driver_connection->Name( true ) )
continue;
auto c = getDefaultConnection( possible_driver, aSubgraph );
connections_to_check.push_back( c );
wxLogTrace( ConnTrace,
"%lu (%s): Adding secondary driver %s", aSubgraph->m_code,
aSubgraph->m_driver_connection->Name( true ), c->Name( true ) );
}
}
};
if( c )
{
if( c->Type() != aSubgraph->m_driver_connection->Type() )
continue;
if( c->Name( true ) == aSubgraph->m_driver_connection->Name( true ) )
continue;
connections_to_check.push_back( c );
wxLogTrace( ConnTrace,
"%lu (%s): Adding secondary driver %s", aSubgraph->m_code,
aSubgraph->m_driver_connection->Name( true ),
c->Name( true ) );
}
}
};
// Now add other strong drivers
// The actual connection attached to these items will have been overwritten
@ -1354,7 +1384,7 @@ void CONNECTION_GRAPH::processSubGraphs()
// on some portion of the items.
void CONNECTION_GRAPH::buildConnectionGraph()
void CONNECTION_GRAPH::buildConnectionGraph( std::function<void( SCH_ITEM* )>* aChangedItemHandler )
{
// Recache all bus aliases for later use
wxCHECK_RET( m_schematic, wxT( "Connection graph cannot be built without schematic pointer" ) );
@ -1548,62 +1578,62 @@ void CONNECTION_GRAPH::buildConnectionGraph()
auto updateItemConnectionsTask =
[&]( CONNECTION_SUBGRAPH* subgraph ) -> size_t
{
// Make sure weakly-driven single-pin nets get the unconnected_ prefix
if( !subgraph->m_strong_driver && subgraph->m_drivers.size() == 1 &&
subgraph->m_driver->Type() == SCH_PIN_T )
[&]( CONNECTION_SUBGRAPH* subgraph ) -> size_t
{
SCH_PIN* pin = static_cast<SCH_PIN*>( subgraph->m_driver );
wxString name = pin->GetDefaultNetName( subgraph->m_sheet, true );
subgraph->m_driver_connection->ConfigureFromLabel( name );
}
subgraph->m_dirty = false;
subgraph->UpdateItemConnections();
// No other processing to do on buses
if( subgraph->m_driver_connection->IsBus() )
return 0;
// As a visual aid, we can check sheet pins that are driven by themselves to see
// if they should be promoted to buses
if( subgraph->m_driver->Type() == SCH_SHEET_PIN_T )
{
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( subgraph->m_driver );
if( SCH_SHEET* sheet = pin->GetParent() )
// Make sure weakly-driven single-pin nets get the unconnected_ prefix
if( !subgraph->m_strong_driver && subgraph->m_drivers.size() == 1 &&
subgraph->m_driver->Type() == SCH_PIN_T )
{
wxString pinText = pin->GetText();
SCH_SCREEN* screen = sheet->GetScreen();
SCH_PIN* pin = static_cast<SCH_PIN*>( subgraph->m_driver );
wxString name = pin->GetDefaultNetName( subgraph->m_sheet, true );
for( SCH_ITEM* item : screen->Items().OfType( SCH_HIER_LABEL_T ) )
{
SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
if( label->GetText() == pinText )
{
SCH_SHEET_PATH path = subgraph->m_sheet;
path.push_back( sheet );
SCH_CONNECTION* parent_conn = label->Connection( &path );
if( parent_conn && parent_conn->IsBus() )
subgraph->m_driver_connection->SetType( CONNECTION_TYPE::BUS );
break;
}
}
if( subgraph->m_driver_connection->IsBus() )
return 0;
subgraph->m_driver_connection->ConfigureFromLabel( name );
}
}
return 1;
};
subgraph->m_dirty = false;
subgraph->UpdateItemConnections();
// No other processing to do on buses
if( subgraph->m_driver_connection->IsBus() )
return 0;
// As a visual aid, we can check sheet pins that are driven by themselves to see
// if they should be promoted to buses
if( subgraph->m_driver->Type() == SCH_SHEET_PIN_T )
{
SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( subgraph->m_driver );
if( SCH_SHEET* sheet = pin->GetParent() )
{
wxString pinText = pin->GetText();
SCH_SCREEN* screen = sheet->GetScreen();
for( SCH_ITEM* item : screen->Items().OfType( SCH_HIER_LABEL_T ) )
{
SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
if( label->GetText() == pinText )
{
SCH_SHEET_PATH path = subgraph->m_sheet;
path.push_back( sheet );
SCH_CONNECTION* parent_conn = label->Connection( &path );
if( parent_conn && parent_conn->IsBus() )
subgraph->m_driver_connection->SetType( CONNECTION_TYPE::BUS );
break;
}
}
if( subgraph->m_driver_connection->IsBus() )
return 0;
}
}
return 1;
};
GetKiCadThreadPool().parallelize_loop( 0, m_driver_subgraphs.size(),
[&]( const int a, const int b)
@ -1623,6 +1653,51 @@ void CONNECTION_GRAPH::buildConnectionGraph()
m_net_name_to_subgraphs_map[subgraph->m_driver_connection->Name()].push_back( subgraph );
}
std::shared_ptr<NET_SETTINGS>& netSettings = m_schematic->Prj().GetProjectFile().m_NetSettings;
std::map<wxString, wxString> oldAssignments = netSettings->m_NetClassLabelAssignments;
netSettings->m_NetClassLabelAssignments.clear();
auto dirtySubgraphs =
[&]( const std::vector<CONNECTION_SUBGRAPH*>& subgraphs )
{
if( aChangedItemHandler )
{
for( const CONNECTION_SUBGRAPH* subgraph : subgraphs )
{
for( SCH_ITEM* item : subgraph->m_items )
(*aChangedItemHandler)( item );
}
}
};
auto checkNetclassDrivers =
[&]( const std::vector<CONNECTION_SUBGRAPH*>& subgraphs )
{
for( const CONNECTION_SUBGRAPH* subgraph : subgraphs )
{
for( SCH_ITEM* item : subgraph->m_items )
{
const wxString netclass = subgraph->GetNetclassForDriver( item );
if( !netclass.IsEmpty() )
{
const wxString netname = subgraph->GetNetName();
netSettings->m_NetClassLabelAssignments[ netname ] = netclass;
if( oldAssignments[ netname ] != netclass )
dirtySubgraphs( subgraphs );
return;
}
}
}
};
for( const auto& [ netname, subgraphs ] : m_net_name_to_subgraphs_map )
checkNetclassDrivers( subgraphs );
}
@ -2291,6 +2366,15 @@ int CONNECTION_GRAPH::RunERC()
error_count += ercCheckHierSheets();
}
if( settings.IsTestEnabled( ERCE_NETCLASS_CONFLICT ) )
{
for( const auto& [ netname, subgraphs ] : m_net_name_to_subgraphs_map )
{
if( !ercCheckNetclassConflicts( subgraphs ) )
error_count++;
}
}
return error_count;
}
@ -2368,6 +2452,44 @@ bool CONNECTION_GRAPH::ercCheckMultipleDrivers( const CONNECTION_SUBGRAPH* aSubg
}
bool CONNECTION_GRAPH::ercCheckNetclassConflicts( const std::vector<CONNECTION_SUBGRAPH*>& subgraphs )
{
wxString firstNetclass;
SCH_ITEM* firstNetclassDriver = nullptr;
for( const CONNECTION_SUBGRAPH* subgraph : subgraphs )
{
for( SCH_ITEM* item : subgraph->m_items )
{
const wxString netclass = subgraph->GetNetclassForDriver( item );
if( netclass.IsEmpty() )
continue;
if( netclass != firstNetclass )
{
if( !firstNetclassDriver )
{
firstNetclass = netclass;
firstNetclassDriver = item;
continue;
}
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NETCLASS_CONFLICT );
ercItem->SetItems( firstNetclassDriver, item );
SCH_MARKER* marker = new SCH_MARKER( ercItem, item->GetPosition() );
subgraph->m_sheet.LastScreen()->Append( marker );
return false;
}
}
}
return true;
}
bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSubgraph )
{
const SCH_SHEET_PATH& sheet = aSubgraph->m_sheet;

View File

@ -116,6 +116,8 @@ public:
const wxString GetNameForDriver( SCH_ITEM* aItem ) const;
const wxString GetNetclassForDriver( SCH_ITEM* aItem ) const;
/// Combines another subgraph on the same sheet into this one.
void Absorb( CONNECTION_SUBGRAPH* aOther );
@ -390,7 +392,7 @@ private:
* and then the connection for the chosen driver is propagated to all the
* other items in the subgraph.
*/
void buildConnectionGraph();
void buildConnectionGraph( std::function<void( SCH_ITEM* )>* aChangedItemHandler );
/**
* Generates individual item subgraphs on a per-sheet basis
@ -475,6 +477,8 @@ private:
*/
bool ercCheckMultipleDrivers( const CONNECTION_SUBGRAPH* aSubgraph );
bool ercCheckNetclassConflicts( const std::vector<CONNECTION_SUBGRAPH*>& subgraphs );
/**
* Checks one subgraph for conflicting connections between net and bus labels
*

View File

@ -607,42 +607,6 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
}
break;
case MAIL_SCH_CLEAN_NETCLASSES:
{
NET_SETTINGS& netSettings = Prj().GetProjectFile().NetSettings();
netSettings.m_NetClassAssignments.clear();
// Establish the set of nets which is currently valid
for( const wxString& name : Schematic().GetNetClassAssignmentCandidates() )
netSettings.m_NetClassAssignments[ name ] = "Default";
// Copy their netclass assignments, dropping any assignments to non-current nets.
for( auto& ii : netSettings.m_NetClasses )
{
for( const wxString& member : *ii.second )
{
if( netSettings.m_NetClassAssignments.count( member ) )
netSettings.m_NetClassAssignments[ member ] = ii.first;
}
ii.second->Clear();
}
// Update the membership lists to contain only the current nets.
for( const std::pair<const wxString, wxString>& ii : netSettings.m_NetClassAssignments )
{
if( ii.second == "Default" )
continue;
NETCLASSPTR netclass = netSettings.m_NetClasses.Find( ii.second );
if( netclass )
netclass->Add( ii.first );
}
}
break;
case MAIL_IMPORT_FILE:
{
// Extract file format type and path (plugin type and path separated with \n)

View File

@ -0,0 +1,104 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 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
* 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 <dialogs/dialog_assign_netclass.h>
#include <dialogs/wx_html_report_box.h>
#include <sch_edit_frame.h>
#include <project/project_file.h>
#include <project/net_settings.h>
#include <schematic.h>
DIALOG_ASSIGN_NETCLASS::DIALOG_ASSIGN_NETCLASS( SCH_EDIT_FRAME* aParent, const wxString aNetName ) :
DIALOG_ASSIGN_NETCLASS_BASE( aParent ),
m_frame( aParent )
{
std::shared_ptr<NET_SETTINGS>& netSettings = m_frame->Prj().GetProjectFile().m_NetSettings;
m_netclassCtrl->Append( NETCLASS::Default );
for( const auto& [ name, netclass ] : netSettings->m_NetClasses )
m_netclassCtrl->Append( name );
if( m_netclassCtrl->GetCount() > 1 )
m_netclassCtrl->SetSelection( 1 ); // First non-Default netclass
else
m_netclassCtrl->SetSelection( 0 ); // Default netclass
m_patternCtrl->SetValue( aNetName );
m_matchingNets->SetFont( KIUI::GetInfoFont( this ) );
m_info->SetFont( KIUI::GetInfoFont( this ).Italic() );
SetupStandardButtons();
finishDialogSettings();
}
bool DIALOG_ASSIGN_NETCLASS::TransferDataFromWindow()
{
std::shared_ptr<NET_SETTINGS>& netSettings = m_frame->Prj().GetProjectFile().m_NetSettings;
if( m_patternCtrl->GetValue().IsEmpty() )
return true;
netSettings->m_NetClassPatternAssignments.push_back(
{
std::make_unique<EDA_COMBINED_MATCHER>( m_patternCtrl->GetValue(), CTX_NETCLASS ),
m_netclassCtrl->GetStringSelection()
} );
return true;
}
void DIALOG_ASSIGN_NETCLASS::OnUpdateUI( wxUpdateUIEvent& event )
{
wxString pattern = m_patternCtrl->GetValue();
if( pattern != m_lastPattern )
{
m_matchingNets->Clear();
if( !pattern.IsEmpty() )
{
EDA_COMBINED_MATCHER matcher( pattern, CTX_NETCLASS );
m_matchingNets->Report( _( "<b>Currently matching nets:</b>" ) );
for( const wxString& net : m_frame->Schematic().GetNetClassAssignmentCandidates() )
{
int matches;
int offset;
if( matcher.Find( net, matches, offset ) && offset == 0 )
m_matchingNets->Report( net );
}
}
m_matchingNets->Flush();
m_lastPattern = pattern;
}
}

View File

@ -0,0 +1,49 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 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
* 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 DIALOG_ASSIGN_NETCLASS_H
#define DIALOG_ASSIGN_NETCLASS_H
#include <dialogs/dialog_assign_netclass_base.h>
class SCH_EDIT_FRAME;
class DIALOG_ASSIGN_NETCLASS : public DIALOG_ASSIGN_NETCLASS_BASE
{
public:
DIALOG_ASSIGN_NETCLASS( SCH_EDIT_FRAME* aParent, const wxString aNetName );
~DIALOG_ASSIGN_NETCLASS() override {}
private:
void OnUpdateUI( wxUpdateUIEvent &event ) override;
bool TransferDataFromWindow() override;
private:
SCH_EDIT_FRAME* m_frame;
wxString m_lastPattern;
};
#endif //DIALOG_ASSIGN_NETCLASS_H

View File

@ -0,0 +1,95 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialogs/wx_html_report_box.h"
#include "dialog_assign_netclass_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_ASSIGN_NETCLASS_BASE::DIALOG_ASSIGN_NETCLASS_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( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bUpperSizer;
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
stPatternLabel = new wxStaticText( this, wxID_ANY, wxT("Pattern:"), wxDefaultPosition, wxDefaultSize, 0 );
stPatternLabel->Wrap( -1 );
bUpperSizer->Add( stPatternLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
m_patternCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_patternCtrl->SetMinSize( wxSize( 240,-1 ) );
bUpperSizer->Add( m_patternCtrl, 1, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
stNetclassLabel = new wxStaticText( this, wxID_ANY, wxT("Net class:"), wxDefaultPosition, wxDefaultSize, 0 );
stNetclassLabel->Wrap( -1 );
bUpperSizer->Add( stNetclassLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 30 );
m_netclassCtrl = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
bUpperSizer->Add( m_netclassCtrl, 0, wxALL, 5 );
bMainSizer->Add( bUpperSizer, 0, wxEXPAND|wxALL, 5 );
wxBoxSizer* bLowerSizer;
bLowerSizer = new wxBoxSizer( wxVERTICAL );
m_matchingNets = new WX_HTML_REPORT_BOX( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
m_matchingNets->SetMinSize( wxSize( -1,200 ) );
bLowerSizer->Add( m_matchingNets, 2, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_info = new wxStaticText( this, wxID_ANY, wxT("Note: complete netclass assignments can be edited in Schemtaic Setup > Project."), wxDefaultPosition, wxDefaultSize, 0 );
m_info->Wrap( -1 );
bLowerSizer->Add( m_info, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bLowerSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP, 10 );
bMainSizer->Add( bLowerSizer, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 );
wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxHORIZONTAL );
bSizerButtons->Add( 20, 0, 1, wxEXPAND, 5 );
m_sdbSizerStdButtons = new wxStdDialogButtonSizer();
m_sdbSizerStdButtonsOK = new wxButton( this, wxID_OK );
m_sdbSizerStdButtons->AddButton( m_sdbSizerStdButtonsOK );
m_sdbSizerStdButtonsCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizerStdButtons->AddButton( m_sdbSizerStdButtonsCancel );
m_sdbSizerStdButtons->Realize();
bSizerButtons->Add( m_sdbSizerStdButtons, 0, wxALL, 5 );
bMainSizer->Add( bSizerButtons, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_ASSIGN_NETCLASS_BASE::OnUpdateUI ) );
}
DIALOG_ASSIGN_NETCLASS_BASE::~DIALOG_ASSIGN_NETCLASS_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_ASSIGN_NETCLASS_BASE::OnUpdateUI ) );
}

View File

@ -0,0 +1,557 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration">; </property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_assign_netclass_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">0</property>
<property name="name">DIALOG_ASSIGN_NETCLASS_BASE</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_ASSIGN_NETCLASS_BASE</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style">wxDEFAULT_DIALOG_STYLE</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property>
<property name="title">Add Netclass Assignment</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnUpdateUI">OnUpdateUI</event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bMainSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bUpperSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Pattern:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">stPatternLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">240,-1</property>
<property name="moveable">1</property>
<property name="name">m_patternCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">30</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Net class:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">stNetclassLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxComboBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_netclassCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">-1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxCB_READONLY</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bLowerSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">2</property>
<object class="wxHtmlWindow" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,200</property>
<property name="moveable">1</property>
<property name="name">m_matchingNets</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxHW_SCROLLBAR_AUTO</property>
<property name="subclass">WX_HTML_REPORT_BOX; dialogs/wx_html_report_box.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Note: complete netclass assignments can be edited in Schemtaic Setup &gt; Project.</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_info</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticline1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerButtons</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="0">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">20</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="0">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizerStdButtons</property>
<property name="permission">protected</property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -0,0 +1,62 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
class WX_HTML_REPORT_BOX;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/combobox.h>
#include <wx/sizer.h>
#include <wx/html/htmlwin.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_ASSIGN_NETCLASS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_ASSIGN_NETCLASS_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* stPatternLabel;
wxTextCtrl* m_patternCtrl;
wxStaticText* stNetclassLabel;
wxComboBox* m_netclassCtrl;
WX_HTML_REPORT_BOX* m_matchingNets;
wxStaticText* m_info;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizerStdButtons;
wxButton* m_sdbSizerStdButtonsOK;
wxButton* m_sdbSizerStdButtonsCancel;
// Virtual event handlers, override them in your derived class
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
public:
DIALOG_ASSIGN_NETCLASS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Add Netclass Assignment"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_ASSIGN_NETCLASS_BASE();
};

View File

@ -461,6 +461,8 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField ),
m_field( aField )
{
static KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT };
m_isSheetFilename = false;
if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
@ -488,6 +490,10 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
break;
}
}
else if( aField->GetParent() && aField->GetParent()->IsType( labelTypes ) )
{
m_fieldId = LABELUSERFIELD_V;
}
// show text variable cross-references in a human-readable format
m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
@ -496,14 +502,7 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
m_isPower = false;
wxString translated_fieldname;
if( m_field->GetId() < MANDATORY_FIELDS )
translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( m_field->GetId(), DO_TRANSLATE );
else
translated_fieldname = m_field->GetName();
m_textLabel->SetLabel( translated_fieldname + ":" );
m_textLabel->SetLabel( aField->GetName() + ":" );
m_position = m_field->GetPosition();

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-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 as published by the
@ -60,7 +60,7 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
m_textVars = new PANEL_TEXT_VARIABLES( m_treebook, &Prj() );
m_netclasses = new PANEL_SETUP_NETCLASSES( this, aFrame, &project.NetSettings().m_NetClasses,
m_netclasses = new PANEL_SETUP_NETCLASSES( this, aFrame, project.NetSettings(),
schematic.GetNetClassAssignmentCandidates(), true );
/*
@ -152,7 +152,7 @@ void DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
m_severities->ImportSettingsFrom( file.m_ErcSettings->m_Severities );
if( importDlg.m_NetClassesOpt->GetValue() )
m_netclasses->ImportSettingsFrom( &file.m_NetSettings->m_NetClasses );
m_netclasses->ImportSettingsFrom( file.m_NetSettings );
m_frame->GetSettingsManager()->UnloadProject( otherPrj, false );
}

View File

@ -86,8 +86,6 @@ void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
if( dlg.ShowQuasiModal() == wxID_OK )
{
Prj().GetProjectFile().NetSettings().RebuildNetClassAssignments();
SaveProjectSettings();
Kiway().CommonSettingsChanged( false, true );
@ -112,11 +110,11 @@ int SCH_EDIT_FRAME::GetSchematicJunctionSize()
{
std::vector<double>& sizeMultipliers = eeconfig()->m_Drawing.junction_size_mult_list;
NETCLASSPTR defaultNetclass = Prj().GetProjectFile().NetSettings().m_NetClasses.GetDefault();
int sizeChoice = Schematic().Settings().m_JunctionSizeChoice;
int junctionSize = defaultNetclass->GetWireWidth() * sizeMultipliers[ sizeChoice ];
const std::shared_ptr<NET_SETTINGS>& netSettings = Prj().GetProjectFile().NetSettings();
int sizeChoice = Schematic().Settings().m_JunctionSizeChoice;
int dotSize = netSettings->m_DefaultNetClass->GetWireWidth() * sizeMultipliers[ sizeChoice ];
return std::max( junctionSize, 1 );
return std::max( dotSize, 1 );
}

View File

@ -110,6 +110,10 @@ ERC_ITEM ERC_ITEM::multipleNetNames( ERCE_DRIVER_CONFLICT,
_( "More than one name given to this bus or net" ),
wxT( "multiple_net_names" ) );
ERC_ITEM ERC_ITEM::netclassConflict( ERCE_NETCLASS_CONFLICT,
_( "Conflicting netclass assignments" ),
wxT( "conflicting_netclasses" ) );
ERC_ITEM ERC_ITEM::netNotBusMember( ERCE_BUS_ENTRY_CONFLICT,
_( "Net is graphically connected to a bus but not a bus member" ),
wxT( "net_not_bus_member" ) );
@ -219,6 +223,7 @@ std::shared_ptr<ERC_ITEM> ERC_ITEM::Create( int aErrorCode )
case ERCE_BUS_LABEL_ERROR: return std::make_shared<ERC_ITEM>( busLabelSyntax );
case ERCE_BUS_TO_BUS_CONFLICT: return std::make_shared<ERC_ITEM>( busToBusConflict );
case ERCE_BUS_TO_NET_CONFLICT: return std::make_shared<ERC_ITEM>( busToNetConflict );
case ERCE_NETCLASS_CONFLICT: return std::make_shared<ERC_ITEM>( netclassConflict );
case ERCE_GLOBLABEL: return std::make_shared<ERC_ITEM>( globalLabelDangling );
case ERCE_UNRESOLVED_VARIABLE: return std::make_shared<ERC_ITEM>( unresolvedVariable );
case ERCE_WIRE_DANGLING: return std::make_shared<ERC_ITEM>( wireDangling );

View File

@ -88,6 +88,7 @@ private:
static ERC_ITEM differentUnitNet;
static ERC_ITEM busDefinitionConflict;
static ERC_ITEM multipleNetNames;
static ERC_ITEM netclassConflict;
static ERC_ITEM netNotBusMember;
static ERC_ITEM busLabelSyntax;
static ERC_ITEM busToBusConflict;

View File

@ -61,6 +61,7 @@ enum ERCE_T
///< one net.
ERCE_BUS_TO_NET_CONFLICT, ///< A bus wire is graphically connected to a net port/pin
///< (or vice versa).
ERCE_NETCLASS_CONFLICT, ///< Multiple labels assign different netclasses to same net.
ERCE_GLOBLABEL, ///< A global label is unique.
ERCE_UNRESOLVED_VARIABLE, ///< A text variable could not be resolved.
ERCE_WIRE_DANGLING, ///< Some wires are not connected to anything else.

View File

@ -261,12 +261,13 @@ void FIELDS_GRID_TABLE<T>::initGrid( WX_GRID* aGrid )
if( editFrame )
{
// Load the combobox with existing existingNetclassNames
NET_SETTINGS& netSettings = editFrame->Schematic().Prj().GetProjectFile().NetSettings();
PROJECT_FILE& projectFile = editFrame->Prj().GetProjectFile();
const std::shared_ptr<NET_SETTINGS>& settings = projectFile.NetSettings();
existingNetclasses.push_back( netSettings.m_NetClasses.GetDefault()->GetName() );
existingNetclasses.push_back( settings->m_DefaultNetClass->GetName() );
for( const std::pair<const wxString, NETCLASSPTR>& pair : netSettings.m_NetClasses )
existingNetclasses.push_back( pair.second->GetName() );
for( const auto& [ name, netclass ] : settings->m_NetClasses )
existingNetclasses.push_back( name );
}
m_netclassAttr = new wxGridCellAttr;

Some files were not shown because too many files have changed in this diff Show More