78 std::shared_ptr<NET_SETTINGS> aNetSettings,
79 const std::set<wxString>& aNetNames,
83 m_isEEschema( aIsEEschema ),
84 m_netSettings(
std::
move( aNetSettings ) ),
85 m_netNames( aNetNames ),
86 m_lastCheckedTicker( 0 ),
88 m_lastNetclassGridWidth( -1 )
123 int const min_best_width =
m_netclassGrid->GetTextExtent(
"555,555555 mils" ).x;
131 int const weighted_min_best_width = ( i ==
GRID_LINESTYLE ) ? min_best_width * 3 / 2
165 wxGridCellAttr* attr =
new wxGridCellAttr;
171 attr =
new wxGridCellAttr;
177 attr =
new wxGridCellAttr;
189 _(
"Set color to transparent to use layer default color." ) );
247 [
this]( wxIdleEvent& aEvent )
253 wxWindow* dialog = wxGetTopLevelParent( this );
254 wxWindow* topLevelFocus = wxGetTopLevelParent( wxWindow::FindFocus() );
256 if( topLevelFocus == dialog && m_lastLoaded != m_netSettings->m_NetClasses )
293 auto netclassToGridRow = [&](
int aRow,
const std::shared_ptr<NETCLASS>& nc,
bool isDefault )
300 wxString colorAsString = nc->GetSchematicColor().ToCSSString();
303 int lineStyleIdx = std::max( 0, nc->GetLineStyle() );
322 colorAsString = nc->GetPcbColor().ToCSSString();
328 if( netclassColors.find( nc->GetName() ) != netclassColors.end() )
330 colorAsString = netclassColors[nc->GetName()].ToCSSString();
347 netclassToGridRow( row++,
m_netSettings->m_DefaultNetClass,
true );
351 cellAttr->SetReadOnly();
358 netclassToGridRow( row++, netclass,
false );
364 for(
const auto& [ matcher, netclassName ] :
m_netSettings->m_NetClassPatternAssignments )
379 if(
IsOK( m_parent,
_(
"The netclasses have been changed outside the Setup dialog.\n"
380 "Do you wish to reload them?" ) ) )
390 std::shared_ptr<NET_SETTINGS> tempNetSettings = std::make_shared<NET_SETTINGS>(
nullptr,
"" );
391 std::shared_ptr<NET_SETTINGS> saveNetSettings =
m_netSettings;
424 wxArrayString netclassNames;
430 if( !netclassName.IsEmpty() )
431 netclassNames.push_back( netclassName );
434 wxGridCellAttr* attr =
new wxGridCellAttr;
435 attr->SetEditor(
new wxGridCellChoiceEditor( netclassNames ) );
447 auto gridRowToNetclass = [&](
int aRow,
const std::shared_ptr<NETCLASS>& nc,
bool isDefault )
455 nc->SetSchematicColor( wxColour(
color ) );
459 wxASSERT_MSG( nc->GetLineStyle() >= 0,
"Line style name not found." );
477 nc->SetPcbColor( newPcbColor );
486 if( newPcbColor != COLOR4D::UNSPECIFIED )
488 netclassColors[nc->GetName()] = newPcbColor;
492 netclassColors.erase( nc->GetName() );
501 gridRowToNetclass( row++,
m_netSettings->m_DefaultNetClass,
true );
507 gridRowToNetclass( row, nc,
false );
520 std::make_unique<EDA_COMBINED_MATCHER>( pattern,
CTX_NETCLASS ),
534 wxString tmp = aName;
541 wxString msg =
_(
"Netclass must have a name." );
550 wxString msg =
_(
"Netclass name already in use." );
568 wxString newName =
event.GetString();
570 if( !oldName.IsEmpty() )
593 if( aEvent.Moving() || aEvent.Entering() )
597 if( col == wxNOT_FOUND )
617 case GRID_uVIADRILL: tip =
_(
"Microvia plated hole diameter" );
break;
630 else if( aEvent.Leaving() )
673 else if( curRow == 0 )
675 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
767 std::map<wxString, std::shared_ptr<NETCLASS>>& netclasses =
m_netSettings->m_NetClasses;
773 if( netclasses.find( netclassName ) != netclasses.end() )
775 const KIGFX::COLOR4D ncColor = netclasses[netclassName]->GetSchematicColor();
787 int classNameWidth = 160;
789 m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
823 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
824 pattern = txt->GetValue();
826 cellEditor->DecRef();
833 if( !pattern.IsEmpty() )
864 netclassName.Trim(
true );
865 netclassName.Trim(
false );
constexpr EDA_IU_SCALE schIUScale
constexpr EDA_IU_SCALE pcbIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
NETCLASS_PANEL m_NetclassPanel
bool StartsWith(const wxString &aTerm)
The base class for create windows for drawing purpose.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
A color representation with 4 components: red, green, blue, alpha.
wxString ToCSSString() const
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
std::map< wxString, KIGFX::COLOR4D > & GetNetclassColorMap()
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static const char Default[]
the name of the default NETCLASS
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
Class PANEL_SETUP_NETCLASSES_BASE.
wxStaticText * m_colorDefaultHelpText
STD_BITMAP_BUTTON * m_removeAssignmentButton
STD_BITMAP_BUTTON * m_addAssignmentButton
STD_BITMAP_BUTTON * m_removeButton
WX_PANEL * m_netclassesPane
wxButton * m_importColorsButton
WX_PANEL * m_membershipPane
WX_HTML_REPORT_BOX * m_matchingNets
STD_BITMAP_BUTTON * m_addButton
WX_GRID * m_assignmentGrid
wxSplitterWindow * m_splitter
void OnImportColorsClick(wxCommandEvent &event) override
std::map< int, int > m_originalColWidths
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnSizeAssignmentGrid(wxSizeEvent &event) override
PANEL_SETUP_NETCLASSES(wxWindow *aParentWindow, EDA_DRAW_FRAME *aFrame, std::shared_ptr< NET_SETTINGS > aSettings, const std::set< wxString > &aNetNames, bool isEEschema)
int m_lastNetclassGridWidth
void OnRemoveNetclassClick(wxCommandEvent &event) override
void OnRemoveAssignmentClick(wxCommandEvent &event) override
std::map< wxString, std::shared_ptr< NETCLASS > > m_lastLoaded
void ImportSettingsFrom(const std::shared_ptr< NET_SETTINGS > &aNetSettings)
void onUnitsChanged(wxCommandEvent &aEvent)
void rebuildNetclassDropdowns()
~PANEL_SETUP_NETCLASSES() override
void OnNetclassGridCellChanging(wxGridEvent &event)
bool TransferDataToWindow() override
bool validateNetclassName(int aRow, const wxString &aName, bool focusFirst=true)
std::unique_ptr< UNITS_PROVIDER > m_pcbUnitsProvider
void OnNetclassGridMouseEvent(wxMouseEvent &event)
void OnAddAssignmentClick(wxCommandEvent &event) override
void AdjustAssignmentGridColumns(int aWidth)
std::set< wxString > m_netNames
void OnAddNetclassClick(wxCommandEvent &event) override
bool TransferDataFromWindow() override
std::unique_ptr< UNITS_PROVIDER > m_schUnitsProvider
void OnSizeNetclassGrid(wxSizeEvent &event) override
void AdjustNetclassGridColumns(int aWidth)
std::shared_ptr< NET_SETTINGS > m_netSettings
int GetNetclassesTicker() const
int GetTextVarsTicker() const
EDA_UNITS GetUserUnits() const
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculates the specified column based on the actual size of the text on screen.
void SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
void SetAutoEvalCols(const std::vector< int > &aCols)
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a UNITS_PROVIDER to enable use of unit- and eval-based Getters.
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
void Clear()
Delete the stored messages.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void Flush()
Build the HTML messages page.
void SetBorders(bool aLeft, bool aRight, bool aTop, bool aBottom)
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
wxFont GetInfoFont(wxWindow *aWindow)
std::vector< BITMAPS > g_lineStyleIcons
wxArrayString g_lineStyleNames
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.