diff --git a/common/layer_id.cpp b/common/layer_id.cpp index 9dcc8f1cda..f250e1219a 100644 --- a/common/layer_id.cpp +++ b/common/layer_id.cpp @@ -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" ); diff --git a/common/marker_base.cpp b/common/marker_base.cpp index 9acdc03e62..cbc56fa82a 100644 --- a/common/marker_base.cpp +++ b/common/marker_base.cpp @@ -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 ); diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index c6692a102e..db60bbcfd5 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -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 diff --git a/include/marker_base.h b/include/marker_base.h index dfd5963c45..f344a8b0d0 100644 --- a/include/marker_base.h +++ b/include/marker_base.h @@ -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 diff --git a/pcbnew/class_marker_pcb.cpp b/pcbnew/class_marker_pcb.cpp index 423f6fe928..e33fc72399 100644 --- a/pcbnew/class_marker_pcb.cpp +++ b/pcbnew/class_marker_pcb.cpp @@ -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() ) { diff --git a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp index 5df106a502..a1d0c7d26f 100644 --- a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp @@ -363,7 +363,8 @@ std::set g_excludedLayers = LAYER_MOD_TEXT_BK, LAYER_PADS_PLATEDHOLES, LAYER_GP_OVERLAY, - LAYER_DRAW_BITMAPS + LAYER_DRAW_BITMAPS, + LAYER_MARKER_SHADOWS }; diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index c4d4bd8b4d..894c1a5aa9 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -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 ); } @@ -573,13 +574,22 @@ void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps() m_view->SetRequired( LAYER_MOD_TEXT_BK, LAYER_MOD_BK ); m_view->SetRequired( LAYER_PAD_BK_NETNAMES, LAYER_PAD_BK ); - m_view->SetLayerTarget( LAYER_SELECT_OVERLAY , KIGFX::TARGET_OVERLAY ); + m_view->SetLayerTarget( LAYER_SELECT_OVERLAY, KIGFX::TARGET_OVERLAY ); m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY ) ; - m_view->SetLayerTarget( LAYER_GP_OVERLAY , KIGFX::TARGET_OVERLAY ); + m_view->SetLayerTarget( LAYER_GP_OVERLAY, KIGFX::TARGET_OVERLAY ); m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ; 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 ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 92318e58fd..557688befa 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -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( item ) ); + draw( static_cast( 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 ); - m_gal->SetIsFill( true ); - m_gal->SetIsStroke( false ); + + 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->DrawPolygon( polygon ); m_gal->Restore(); } diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 40f621f512..e0d48b3da1 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -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()