PcbNew: Improved DRC marker display
Add shadows and slightly reduce size Fixes https://gitlab.com/kicad/code/kicad/-/issues/5936
This commit is contained in:
parent
a1c75748a0
commit
4b436fa573
|
@ -161,6 +161,7 @@ wxString LayerName( int aLayer )
|
|||
case LAYER_DRC_WARNING: return _( "DRC Warnings" );
|
||||
case LAYER_DRC_ERROR: return _( "DRC Errors" );
|
||||
case LAYER_DRC_EXCLUSION: return _( "DRC Exclusions" );
|
||||
case LAYER_MARKER_SHADOWS: return _( "DRC Marker Shadows" );
|
||||
case LAYER_ANCHOR: return _( "Anchors" );
|
||||
case LAYER_WORKSHEET: return _( "Worksheet" );
|
||||
case LAYER_CURSOR: return _( "Cursor" );
|
||||
|
|
|
@ -106,10 +106,13 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& aHitPosition, int aAccuracy ) co
|
|||
}
|
||||
|
||||
|
||||
void MARKER_BASE::ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon) const
|
||||
void MARKER_BASE::ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon, int aScale ) const
|
||||
{
|
||||
if( aScale < 0 )
|
||||
aScale = MarkerScale();
|
||||
|
||||
for( const VECTOR2I& corner : MarkerShapeCorners )
|
||||
aPolygon.Append( corner * MarkerScale() );
|
||||
aPolygon.Append( corner * aScale );
|
||||
|
||||
// Be sure aPolygon is seen as a closed polyline:
|
||||
aPolygon.SetClosed( true );
|
||||
|
|
|
@ -205,6 +205,7 @@ enum GAL_LAYER_ID: int
|
|||
LAYER_DRC_ERROR, ///< layer for drc markers with SEVERITY_ERROR
|
||||
LAYER_DRC_WARNING, ///< layer for drc markers with SEVERITY_WARNING
|
||||
LAYER_DRC_EXCLUSION, ///< layer for drc markers which have been individually excluded
|
||||
LAYER_MARKER_SHADOWS, ///< shadows for drc markers
|
||||
LAYER_WORKSHEET, ///< worksheet frame
|
||||
LAYER_GP_OVERLAY, ///< general purpose overlay
|
||||
LAYER_SELECT_OVERLAY, ///< currently selected items overlay
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
* the coordinates are relatives to the marker position (are not absolute)
|
||||
* @param aPolygon is the SHAPE_LINE_CHAIN to fill with the shape
|
||||
*/
|
||||
void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon) const;
|
||||
void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon, int aScale = -1 ) const;
|
||||
|
||||
/**
|
||||
* Function PrintMarker
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
|
||||
/// Factor to convert the maker unit shape to internal units:
|
||||
#define SCALING_FACTOR Millimeter2iu( 0.1 )
|
||||
#define SCALING_FACTOR Millimeter2iu( 0.075 )
|
||||
|
||||
|
||||
|
||||
|
@ -144,7 +144,9 @@ BITMAP_DEF MARKER_PCB::GetMenuImage() const
|
|||
|
||||
void MARKER_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 1;
|
||||
aCount = 2;
|
||||
|
||||
aLayers[1] = LAYER_MARKER_SHADOWS;
|
||||
|
||||
if( IsExcluded() )
|
||||
{
|
||||
|
|
|
@ -363,7 +363,8 @@ std::set<int> g_excludedLayers =
|
|||
LAYER_MOD_TEXT_BK,
|
||||
LAYER_PADS_PLATEDHOLES,
|
||||
LAYER_GP_OVERLAY,
|
||||
LAYER_DRAW_BITMAPS
|
||||
LAYER_DRAW_BITMAPS,
|
||||
LAYER_MARKER_SHADOWS
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ const LAYER_NUM GAL_LAYER_ORDER[] =
|
|||
{
|
||||
LAYER_GP_OVERLAY,
|
||||
LAYER_SELECT_OVERLAY,
|
||||
LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION,
|
||||
LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION, LAYER_MARKER_SHADOWS,
|
||||
LAYER_PADS_NETNAMES, LAYER_VIAS_NETNAMES,
|
||||
Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts,
|
||||
|
||||
|
@ -279,7 +279,7 @@ void PCB_DRAW_PANEL_GAL::SetHighContrastLayer( PCB_LAYER_ID aLayer )
|
|||
LAYER_PADS_TH, LAYER_PADS_PLATEDHOLES, LAYER_PADS_NETNAMES,
|
||||
LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION,
|
||||
LAYER_NON_PLATEDHOLES, LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY,
|
||||
LAYER_RATSNEST, LAYER_CURSOR, LAYER_ANCHOR
|
||||
LAYER_RATSNEST, LAYER_CURSOR, LAYER_ANCHOR, LAYER_MARKER_SHADOWS
|
||||
};
|
||||
|
||||
for( unsigned int i : layers )
|
||||
|
@ -315,7 +315,7 @@ void PCB_DRAW_PANEL_GAL::SetTopLayer( PCB_LAYER_ID aLayer )
|
|||
LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, LAYER_VIAS_NETNAMES, LAYER_PADS_TH,
|
||||
LAYER_PADS_PLATEDHOLES, LAYER_PADS_NETNAMES, LAYER_NON_PLATEDHOLES,
|
||||
LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY, LAYER_RATSNEST, LAYER_DRC_ERROR,
|
||||
LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION
|
||||
LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION, LAYER_MARKER_SHADOWS
|
||||
};
|
||||
|
||||
for( auto layer : layers )
|
||||
|
@ -406,6 +406,7 @@ void PCB_DRAW_PANEL_GAL::SyncLayersVisibility( const BOARD* aBoard )
|
|||
m_view->SetLayerVisible( LAYER_GP_OVERLAY, true );
|
||||
m_view->SetLayerVisible( LAYER_SELECT_OVERLAY, true );
|
||||
m_view->SetLayerVisible( LAYER_RATSNEST, true );
|
||||
m_view->SetLayerVisible( LAYER_MARKER_SHADOWS, true );
|
||||
}
|
||||
|
||||
|
||||
|
@ -580,6 +581,15 @@ void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
|
|||
m_view->SetLayerTarget( LAYER_RATSNEST, KIGFX::TARGET_OVERLAY );
|
||||
m_view->SetLayerDisplayOnly( LAYER_RATSNEST );
|
||||
|
||||
m_view->SetLayerTarget( LAYER_DRC_ERROR, KIGFX::TARGET_OVERLAY );
|
||||
m_view->SetLayerDisplayOnly( LAYER_DRC_ERROR );
|
||||
m_view->SetLayerTarget( LAYER_DRC_WARNING, KIGFX::TARGET_OVERLAY );
|
||||
m_view->SetLayerDisplayOnly( LAYER_DRC_WARNING );
|
||||
m_view->SetLayerTarget( LAYER_DRC_EXCLUSION, KIGFX::TARGET_OVERLAY );
|
||||
m_view->SetLayerDisplayOnly( LAYER_DRC_EXCLUSION );
|
||||
m_view->SetLayerTarget( LAYER_MARKER_SHADOWS, KIGFX::TARGET_OVERLAY );
|
||||
m_view->SetLayerDisplayOnly( LAYER_MARKER_SHADOWS );
|
||||
|
||||
m_view->SetLayerTarget( LAYER_WORKSHEET, KIGFX::TARGET_NONCACHED );
|
||||
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ;
|
||||
m_view->SetLayerDisplayOnly( LAYER_GRID );
|
||||
|
|
|
@ -240,6 +240,17 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
|
|||
if( m_hiContrastEnabled && IsNetnameLayer( aLayer ) && m_highContrastLayers.count( aLayer ) == 0 )
|
||||
return COLOR4D::CLEAR;
|
||||
|
||||
// Marker shadows
|
||||
if( aLayer == LAYER_MARKER_SHADOWS )
|
||||
{
|
||||
COLOR4D shadowColor = m_backgroundColor.WithAlpha( 0.6 );
|
||||
|
||||
if( item && item->IsSelected() )
|
||||
shadowColor.Brighten( m_selectFactor );
|
||||
|
||||
return shadowColor;
|
||||
}
|
||||
|
||||
// Normal path: get the layer base color
|
||||
COLOR4D color = m_layerColors[aLayer];
|
||||
|
||||
|
@ -461,7 +472,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
|||
break;
|
||||
|
||||
case PCB_MARKER_T:
|
||||
draw( static_cast<const MARKER_PCB*>( item ) );
|
||||
draw( static_cast<const MARKER_PCB*>( item ), aLayer );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1555,18 +1566,39 @@ void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
|
|||
}
|
||||
|
||||
|
||||
void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
|
||||
void PCB_PAINTER::draw( const MARKER_PCB* aMarker, int aLayer )
|
||||
{
|
||||
bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
|
||||
|
||||
// Don't paint shadows for invisible markers.
|
||||
// It would be nice to do this through layer dependencies but we can't do an "or" there today
|
||||
if( isShadow && aMarker->GetBoard() &&
|
||||
!aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
|
||||
return;
|
||||
|
||||
SHAPE_LINE_CHAIN polygon;
|
||||
aMarker->ShapeToPolygon( polygon );
|
||||
|
||||
auto strokeColor = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() );
|
||||
|
||||
|
||||
COLOR4D color = m_pcbSettings.GetColor( aMarker, isShadow ? LAYER_MARKER_SHADOWS
|
||||
: aMarker->GetColorLayer() );
|
||||
|
||||
m_gal->Save();
|
||||
m_gal->Translate( aMarker->GetPosition() );
|
||||
m_gal->SetFillColor( strokeColor );
|
||||
|
||||
if( isShadow )
|
||||
{
|
||||
m_gal->SetStrokeColor( color );
|
||||
m_gal->SetIsStroke( true );
|
||||
m_gal->SetLineWidth( aMarker->MarkerScale() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gal->SetFillColor( color );
|
||||
m_gal->SetIsFill( true );
|
||||
m_gal->SetIsStroke( false );
|
||||
}
|
||||
|
||||
m_gal->DrawPolygon( polygon );
|
||||
m_gal->Restore();
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ protected:
|
|||
void draw( const ZONE_CONTAINER* aZone, int aLayer );
|
||||
void draw( const DIMENSION* aDimension, int aLayer );
|
||||
void draw( const PCB_TARGET* aTarget );
|
||||
void draw( const MARKER_PCB* aMarker );
|
||||
void draw( const MARKER_PCB* aMarker, int aLayer );
|
||||
|
||||
/**
|
||||
* Function getLineThickness()
|
||||
|
|
Loading…
Reference in New Issue