Dim other pads when in pad edit mode.

This commit is contained in:
Jeff Young 2023-01-06 11:13:34 +00:00
parent c57e6db79a
commit 2cbb66d70d
3 changed files with 62 additions and 11 deletions

View File

@ -111,7 +111,9 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
m_zoneOpacity = 1.0;
m_imageOpacity = 1.0;
m_ForcePadSketchModeOn = false;
m_ForcePadSketchModeOn = false;
m_PadEditModePad = nullptr;
SetDashLengthRatio( 12 ); // From ISO 128-2
SetGapLengthRatio( 3 ); // From ISO 128-2
@ -307,24 +309,39 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
switch( originalLayer )
{
case LAYER_PADS_TH:
if( !static_cast<const PAD*>( item )->FlashLayer( primary ) )
{
const PAD* pad = static_cast<const PAD*>( item );
if( !pad->FlashLayer( primary ) )
isActive = false;
if( m_PadEditModePad && pad != m_PadEditModePad )
isActive = false;
break;
}
case LAYER_VIA_BBLIND:
case LAYER_VIA_MICROVIA:
{
const PCB_VIA* via = static_cast<const PCB_VIA*>( item );
// Target graphic is active if the via crosses the primary layer
if( static_cast<const PCB_VIA*>( item )->GetLayerSet().test( primary ) == 0 )
if( via->GetLayerSet().test( primary ) == 0 )
isActive = false;
break;
}
case LAYER_VIA_THROUGH:
if( !static_cast<const PCB_VIA*>( item )->FlashLayer( primary ) )
{
const PCB_VIA* via = static_cast<const PCB_VIA*>( item );
if( !via->FlashLayer( primary ) )
isActive = false;
break;
}
case LAYER_PAD_PLATEDHOLES:
case LAYER_PAD_HOLEWALLS:
@ -337,11 +354,14 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
case LAYER_VIA_HOLES:
case LAYER_VIA_HOLEWALLS:
if( static_cast<const PCB_VIA*>( item )->GetViaType() == VIATYPE::BLIND_BURIED
|| static_cast<const PCB_VIA*>( item )->GetViaType() == VIATYPE::MICROVIA )
{
const PCB_VIA* via = static_cast<const PCB_VIA*>( item );
if( via->GetViaType() == VIATYPE::BLIND_BURIED
|| via->GetViaType() == VIATYPE::MICROVIA )
{
// A blind or micro via's hole is active if it crosses the primary layer
if( static_cast<const PCB_VIA*>( item )->GetLayerSet().test( primary ) == 0 )
if( via->GetLayerSet().test( primary ) == 0 )
isActive = false;
}
else
@ -352,6 +372,7 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
}
break;
}
default:
break;

View File

@ -124,6 +124,8 @@ public:
ZONE_DISPLAY_MODE m_ZoneDisplayMode;
HIGH_CONTRAST_MODE m_ContrastModeDisplay;
PAD* m_PadEditModePad; // Pad currently in Pad Edit Mode (if any)
protected:
///< Maximum font size for netnames (and other dynamically shown strings)
static const double MAX_FONT_SIZE;

View File

@ -23,6 +23,7 @@
#include "pad_tool.h"
#include "pcb_painter.h"
#include <macros.h>
#include <class_draw_panel_gal.h>
#include <view/view_controls.h>
@ -43,6 +44,10 @@
#include <dialogs/dialog_enum_pads.h>
#include <widgets/wx_infobar.h>
using KIGFX::PCB_RENDER_SETTINGS;
PAD_TOOL::PAD_TOOL() :
PCB_TOOL_BASE( "pcbnew.PadTool" ),
m_wasHighContrast( false ),
@ -566,10 +571,11 @@ int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
{
PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
WX_INFOBAR* infoBar = frame()->GetInfoBar();
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
wxString msg;
PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
PCB_RENDER_SETTINGS* settings = static_cast<PCB_RENDER_SETTINGS*>( view()->GetPainter()->GetSettings() );
WX_INFOBAR* infoBar = frame()->GetInfoBar();
PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
wxString msg;
if( m_editPad != niluuid )
{
@ -592,6 +598,14 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
m_wasHighContrast = ( opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL );
frame()->SetActiveLayer( layer );
settings->m_PadEditModePad = pad;
canvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT,
[&]( KIGFX::VIEW_ITEM* aItem ) -> bool
{
return dynamic_cast<PAD*>( aItem ) != nullptr;
} );
if( !m_wasHighContrast )
m_toolMgr->RunAction( ACTIONS::highContrastMode, true );
@ -619,6 +633,20 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
if( m_wasHighContrast != highContrast )
m_toolMgr->RunAction( ACTIONS::highContrastMode, true );
settings->m_PadEditModePad = nullptr;
// Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
// they won't be found in the view layer's itemset for re-painting.
canvas()->GetView()->UpdateAllItemsConditionally( KIGFX::ALL,
[&]( KIGFX::VIEW_ITEM* aItem ) -> bool
{
return dynamic_cast<PAD*>( aItem ) != nullptr;
} );
// Refresh now (otherwise there's an uncomfortably long pause while the infoBar
// closes before refresh).
canvas()->ForceRefresh();
infoBar->Dismiss();
}