Ease-of-use for un-commented ERC/DRC exclusions.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18220
This commit is contained in:
Jeff Young 2024-06-19 17:07:38 +01:00
parent 8e349eedf0
commit 31ab276aaf
5 changed files with 60 additions and 28 deletions

View File

@ -31,7 +31,11 @@ WX_TEXT_ENTRY_DIALOG::WX_TEXT_ENTRY_DIALOG( wxWindow* aParent,
bool aExtraWidth ) :
WX_TEXT_ENTRY_DIALOG_BASE( aParent, wxID_ANY, aCaption, wxDefaultPosition, wxDefaultSize )
{
m_label->SetLabel( aFieldLabel );
if( aFieldLabel.IsEmpty() )
m_label->Hide();
else
m_label->SetLabel( aFieldLabel );
m_textCtrl->SetValue( aDefaultValue );
m_textCtrl->SetMinSize( FromDIP( aExtraWidth ? wxSize( 700, -1 ) : wxSize( 300, -1 ) ) );

View File

@ -19,12 +19,12 @@ WX_TEXT_ENTRY_DIALOG_BASE::WX_TEXT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindow
m_label = new wxStaticText( this, wxID_ANY, _("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
m_label->Wrap( -1 );
m_ContentSizer->Add( m_label, 0, wxALL|wxEXPAND, 5 );
m_ContentSizer->Add( m_label, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrl->SetMinSize( wxSize( 300,-1 ) );
m_ContentSizer->Add( m_textCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_ContentSizer->Add( m_textCtrl, 0, wxEXPAND|wxALL, 5 );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );

View File

@ -73,7 +73,7 @@
<property name="permission">public</property>
<object class="sizeritem" expanded="false">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="false">
<property name="BottomDockable">1</property>
@ -135,7 +135,7 @@
</object>
<object class="sizeritem" expanded="false">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="false">
<property name="BottomDockable">1</property>

View File

@ -626,6 +626,7 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
ID_REMOVE_EXCLUSION,
ID_REMOVE_EXCLUSION_ALL,
ID_ADD_EXCLUSION,
ID_ADD_EXCLUSION_WITH_COMMENT,
ID_ADD_EXCLUSION_ALL,
ID_INSPECT_VIOLATION,
ID_EDIT_PIN_CONFLICT_MAP,
@ -638,17 +639,21 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
if( rcItem->GetParent()->IsExcluded() )
{
menu.Append( ID_EDIT_EXCLUSION_COMMENT,
_( "Edit exclusion comment..." ) );
menu.Append( ID_REMOVE_EXCLUSION,
_( "Remove exclusion for this violation" ),
wxString::Format( _( "It will be placed back in the %s list" ), listName ) );
menu.Append( ID_EDIT_EXCLUSION_COMMENT,
_( "Edit exclusion comment..." ) );
}
else
{
menu.Append( ID_ADD_EXCLUSION,
_( "Exclude this violation..." ),
_( "Exclude this violation" ),
wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
menu.Append( ID_ADD_EXCLUSION_WITH_COMMENT,
_( "Exclude with comment..." ),
wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
}
@ -707,13 +712,14 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
}
bool modified = false;
int command = GetPopupMenuSelectionFromUser( menu );
switch( GetPopupMenuSelectionFromUser( menu ) )
switch( command )
{
case ID_EDIT_EXCLUSION_COMMENT:
if( SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() ) )
{
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Optional comment:" ), _( "Exclusion Comment" ),
WX_TEXT_ENTRY_DIALOG dlg( this, wxEmptyString, _( "Exclusion Comment" ),
marker->GetComment(), true );
if( dlg.ShowModal() == wxID_CANCEL )
@ -742,15 +748,23 @@ void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
break;
case ID_ADD_EXCLUSION:
case ID_ADD_EXCLUSION_WITH_COMMENT:
if( SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() ) )
{
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Optional comment:" ), _( "Exclusion Comment" ),
wxEmptyString, true );
wxString comment;
if( dlg.ShowModal() == wxID_CANCEL )
break;
if( command == ID_ADD_EXCLUSION_WITH_COMMENT )
{
WX_TEXT_ENTRY_DIALOG dlg( this, wxEmptyString, _( "Exclusion Comment" ),
wxEmptyString, true );
marker->SetExcluded( true, dlg.GetValue() );
if( dlg.ShowModal() == wxID_CANCEL )
break;
comment = dlg.GetValue();
}
marker->SetExcluded( true, comment );
m_parent->GetCanvas()->GetView()->Update( marker );

View File

@ -646,6 +646,7 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
ID_REMOVE_EXCLUSION,
ID_REMOVE_EXCLUSION_ALL,
ID_ADD_EXCLUSION,
ID_ADD_EXCLUSION_WITH_COMMENT,
ID_ADD_EXCLUSION_ALL,
ID_INSPECT_VIOLATION,
ID_SET_SEVERITY_TO_ERROR,
@ -656,13 +657,13 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
if( rcItem->GetParent()->IsExcluded() )
{
menu.Append( ID_EDIT_EXCLUSION_COMMENT,
_( "Edit exclusion comment..." ) );
menu.Append( ID_REMOVE_EXCLUSION,
_( "Remove exclusion for this violation" ),
wxString::Format( _( "It will be placed back in the %s list" ), listName ) );
menu.Append( ID_EDIT_EXCLUSION_COMMENT,
_( "Edit exclusion comment..." ) );
if( drcItem->GetViolatingRule() && !drcItem->GetViolatingRule()->m_Implicit )
{
menu.Append( ID_REMOVE_EXCLUSION_ALL,
@ -674,7 +675,11 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
else
{
menu.Append( ID_ADD_EXCLUSION,
_( "Exclude this violation..." ),
_( "Exclude this violation" ),
wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
menu.Append( ID_ADD_EXCLUSION_WITH_COMMENT,
_( "Exclude with comment..." ),
wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
if( drcItem->GetViolatingRule() && !drcItem->GetViolatingRule()->m_Implicit )
@ -719,13 +724,14 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
_( "Open the Board Setup... dialog" ) );
bool modified = false;
int command = GetPopupMenuSelectionFromUser( menu );
switch( GetPopupMenuSelectionFromUser( menu ) )
switch( command )
{
case ID_EDIT_EXCLUSION_COMMENT:
if( PCB_MARKER* marker = dynamic_cast<PCB_MARKER*>( node->m_RcItem->GetParent() ) )
{
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Optional comment:" ), _( "Exclusion Comment" ),
WX_TEXT_ENTRY_DIALOG dlg( this, wxEmptyString, _( "Exclusion Comment" ),
marker->GetComment(), true );
if( dlg.ShowModal() == wxID_CANCEL )
@ -771,19 +777,27 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
break;
case ID_ADD_EXCLUSION:
case ID_ADD_EXCLUSION_WITH_COMMENT:
if( PCB_MARKER* marker = dynamic_cast<PCB_MARKER*>( rcItem->GetParent() ) )
{
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Optional comment:" ), _( "Exclusion Comment" ),
wxEmptyString, true );
wxString comment;
if( dlg.ShowModal() == wxID_CANCEL )
break;
if( command == ID_ADD_EXCLUSION_WITH_COMMENT )
{
WX_TEXT_ENTRY_DIALOG dlg( this, wxEmptyString, _( "Exclusion Comment" ),
wxEmptyString, true );
marker->SetExcluded( true, dlg.GetValue() );
if( dlg.ShowModal() == wxID_CANCEL )
break;
comment = dlg.GetValue();
}
marker->SetExcluded( true, comment );
wxString serialized = marker->SerializeToString();
m_frame->GetDesignSettings().m_DrcExclusions.insert( serialized );
m_frame->GetDesignSettings().m_DrcExclusionComments[ serialized ] = dlg.GetValue();
m_frame->GetDesignSettings().m_DrcExclusionComments[ serialized ] = comment;
if( rcItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
{