From 5e1a16e821e20e28f014a3f170643092a87943ea Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 3 Jun 2024 12:48:38 +0100 Subject: [PATCH] Regularize DNP printing & plotting with painting. --- eeschema/sch_sheet.cpp | 47 +++++++++++++++++++++++++++++++++++++++++ eeschema/sch_symbol.cpp | 24 +++++++++++++++++---- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index a8a9996711..53cbe84688 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -1266,6 +1267,30 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& // Plot the fields for( SCH_FIELD& field : m_fields ) field.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed ); + + if( GetDNP() ) + { + COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings(); + BOX2I bbox = GetBodyBoundingBox(); + BOX2I pins = GetBoundingBox(); + VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(), + pins.GetEnd().x - bbox.GetEnd().x ), + std::max( bbox.GetY() - pins.GetY(), + pins.GetEnd().y - bbox.GetEnd().y ) ); + int strokeWidth = 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ); + + margins.x = std::max( margins.x * 0.6, margins.y * 0.3 ); + margins.y = std::max( margins.y * 0.6, margins.x * 0.3 ); + bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) ); + + aPlotter->SetColor( colors->GetColor( LAYER_DNP_MARKER ) ); + + aPlotter->ThickSegment( bbox.GetOrigin(), bbox.GetEnd(), strokeWidth, FILLED, nullptr ); + + aPlotter->ThickSegment( bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ), + bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ), + strokeWidth, FILLED, nullptr ); + } } @@ -1297,6 +1322,28 @@ void SCH_SHEET::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod for( SCH_SHEET_PIN* sheetPin : m_pins ) sheetPin->Print( aSettings, aUnit, aBodyStyle, aOffset, aForceNoFill, aDimmed ); + + if( GetDNP() ) + { + BOX2I bbox = GetBodyBoundingBox(); + BOX2I pins = GetBoundingBox(); + COLOR4D dnp_color = aSettings->GetLayerColor( LAYER_DNP_MARKER ); + VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(), pins.GetEnd().x - bbox.GetEnd().x ), + std::max( bbox.GetY() - pins.GetY(), pins.GetEnd().y - bbox.GetEnd().y ) ); + + margins.x = std::max( margins.x * 0.6, margins.y * 0.3 ); + margins.y = std::max( margins.y * 0.6, margins.x * 0.3 ); + bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) ); + + GRFilledSegment( DC, bbox.GetOrigin(), bbox.GetEnd(), + 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), + dnp_color ); + + GRFilledSegment( DC, bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ), + bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ), + 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), + dnp_color ); + } } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index bce8ab4cf6..5421586879 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -542,9 +542,16 @@ void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo if( m_DNP ) { - BOX2I bbox = GetBodyAndPinsBoundingBox(); - wxDC* DC = localRenderSettings.GetPrintDC(); - COLOR4D dnp_color = localRenderSettings.GetLayerColor( LAYER_DNP_MARKER ); + wxDC* DC = localRenderSettings.GetPrintDC(); + BOX2I bbox = GetBodyBoundingBox(); + BOX2I pins = GetBodyAndPinsBoundingBox(); + COLOR4D dnp_color = localRenderSettings.GetLayerColor( LAYER_DNP_MARKER ); + VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(), pins.GetEnd().x - bbox.GetEnd().x ), + std::max( bbox.GetY() - pins.GetY(), pins.GetEnd().y - bbox.GetEnd().y ) ); + + margins.x = std::max( margins.x * 0.6, margins.y * 0.3 ); + margins.y = std::max( margins.y * 0.6, margins.x * 0.3 ); + bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) ); GRFilledSegment( DC, bbox.GetOrigin(), bbox.GetEnd(), 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), @@ -2547,9 +2554,18 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& void SCH_SYMBOL::PlotDNP( PLOTTER* aPlotter ) const { COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings(); - BOX2I bbox = GetBodyAndPinsBoundingBox(); + BOX2I bbox = GetBodyBoundingBox(); + BOX2I pins = GetBodyAndPinsBoundingBox(); + VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(), + pins.GetEnd().x - bbox.GetEnd().x ), + std::max( bbox.GetY() - pins.GetY(), + pins.GetEnd().y - bbox.GetEnd().y ) ); int strokeWidth = 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ); + margins.x = std::max( margins.x * 0.6, margins.y * 0.3 ); + margins.y = std::max( margins.y * 0.6, margins.x * 0.3 ); + bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) ); + aPlotter->SetColor( colors->GetColor( LAYER_DNP_MARKER ) ); aPlotter->ThickSegment( bbox.GetOrigin(), bbox.GetEnd(), strokeWidth, FILLED, nullptr );