Browse Source

Explicit control over hidden text in bounding boxes.

In particular, don't consider hidden text when plotting,
and only when AsItemCheckboxes is checked for printing.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17958
fusion360
Jeff Young 1 year ago
parent
commit
8184ed64e7
  1. 2
      3d-viewer/3d_canvas/board_adapter.cpp
  2. 12
      pcbnew/board.cpp
  3. 6
      pcbnew/board.h
  4. 4
      pcbnew/convert_shape_list_to_polygon.cpp
  5. 2
      pcbnew/dialogs/dialog_export_step.cpp
  6. 2
      pcbnew/dialogs/dialog_export_vrml.cpp
  7. 2
      pcbnew/exporters/export_gencad_writer.cpp
  8. 2
      pcbnew/exporters/export_svg.cpp
  9. 2
      pcbnew/exporters/place_file_exporter.cpp
  10. 2
      pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp
  11. 2
      pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp
  12. 2
      pcbnew/pcbnew_jobs_handler.cpp
  13. 5
      pcbnew/pcbnew_printout.cpp
  14. 4
      pcbnew/plot_board_layers.cpp

2
3d-viewer/3d_canvas/board_adapter.cpp

@ -344,7 +344,7 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
BOX2I bbbox;
if( m_board )
bbbox = m_board->ComputeBoundingBox( !m_board->IsFootprintHolder() && haveOutline );
bbbox = m_board->ComputeBoundingBox( !m_board->IsFootprintHolder() && haveOutline, false );
// Gives a non null size to avoid issues in zoom / scale calculations
if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )

12
pcbnew/board.cpp

@ -1552,17 +1552,13 @@ unsigned BOARD::GetNodesCount( int aNet ) const
}
BOX2I BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
BOX2I BOARD::ComputeBoundingBox( bool aBoardEdgesOnly, bool aIncludeHiddenText ) const
{
BOX2I bbox;
LSET visible = GetVisibleLayers();
bool showHiddenText = IsElementVisible( LAYER_HIDDEN_TEXT );
if( PgmOrNull() && PgmOrNull()->m_Printing )
showHiddenText = false;
// If the board is just showing a footprint, we want all footprint layers
// included in the bounding box
// If the board is just showing a footprint, we want all footprint layers included in the
// bounding box
if( IsFootprintHolder() )
visible.set();
@ -1595,7 +1591,7 @@ BOX2I BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
}
else
{
bbox.Merge( footprint->GetBoundingBox( true, showHiddenText ) );
bbox.Merge( footprint->GetBoundingBox( true, aIncludeHiddenText ) );
}
}

6
pcbnew/board.h

@ -892,11 +892,11 @@ public:
* @param aBoardEdgesOnly is true if we are interested in board edge segments only.
* @return the board's bounding box.
*/
BOX2I ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
BOX2I ComputeBoundingBox( bool aBoardEdgesOnly, bool aIncludeHiddenText ) const;
const BOX2I GetBoundingBox() const override
{
return ComputeBoundingBox( false );
return ComputeBoundingBox( false, IsElementVisible( LAYER_HIDDEN_TEXT ) );
}
/**
@ -910,7 +910,7 @@ public:
*/
const BOX2I GetBoardEdgesBoundingBox() const
{
return ComputeBoundingBox( true );
return ComputeBoundingBox( true, false );
}
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;

4
pcbnew/convert_shape_list_to_polygon.cpp

@ -821,7 +821,7 @@ bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines, int aE
// If null area, uses the global bounding box.
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
bbbox = aBoard->ComputeBoundingBox();
bbbox = aBoard->ComputeBoundingBox( false, false );
// Ensure non null area. If happen, gives a minimal size.
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
@ -881,7 +881,7 @@ void buildBoardBoundingBoxPoly( const BOARD* aBoard, SHAPE_POLY_SET& aOutline )
// If null area, uses the global bounding box.
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
bbbox = aBoard->ComputeBoundingBox();
bbbox = aBoard->ComputeBoundingBox( false, false );
// Ensure non null area. If happen, gives a minimal size.
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )

2
pcbnew/dialogs/dialog_export_step.cpp

@ -560,7 +560,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
case STEP_ORIGIN_BOARD_CENTER:
{
BOX2I bbox = m_parent->GetBoard()->ComputeBoundingBox( true );
BOX2I bbox = m_parent->GetBoard()->ComputeBoundingBox( true, false );
double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
LOCALE_IO dummy;

2
pcbnew/dialogs/dialog_export_vrml.cpp

@ -264,7 +264,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
{
// Origin = board center:
BOARD* pcb = GetBoard();
BOX2I bbox = pcb->ComputeBoundingBox( true );
BOX2I bbox = pcb->ComputeBoundingBox( true, false );
aXRef = pcbIUScale.IUTomm( bbox.GetCenter().x );
aYRef = pcbIUScale.IUTomm( bbox.GetCenter().y );
}

2
pcbnew/exporters/export_gencad_writer.cpp

@ -204,7 +204,7 @@ bool GENCAD_EXPORTER::WriteFile( wxString& aFullFileName )
BOARD* pcb = m_board;
// Update some board data, to ensure a reliable gencad export
pcb->ComputeBoundingBox();
pcb->ComputeBoundingBox( false, false );
/* Temporary modification of footprints that are flipped (i.e. on bottom
* layer) to convert them to non flipped footprints.

2
pcbnew/exporters/export_svg.cpp

@ -63,7 +63,7 @@ bool EXPORT_SVG::Plot( BOARD* aBoard, const PCB_PLOT_SVG_OPTIONS& aSvgPlotOption
if( aSvgPlotOptions.m_pageSizeMode == 2 ) // Page is board boundary size
{
BOX2I bbox = aBoard->ComputeBoundingBox();
BOX2I bbox = aBoard->ComputeBoundingBox( false, false );
PAGE_INFO currpageInfo = aBoard->GetPageSettings();
currpageInfo.SetWidthMils( bbox.GetWidth() / pcbIUScale.IU_PER_MILS );

2
pcbnew/exporters/place_file_exporter.cpp

@ -309,7 +309,7 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
buffer += "\n$BeginDESCRIPTION\n";
BOX2I bbbox = m_board->ComputeBoundingBox();
BOX2I bbbox = m_board->ComputeBoundingBox( false, false );
buffer += "\n$BOARD\n";

2
pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp

@ -241,7 +241,7 @@ BOARD* PCB_IO_EASYEDA::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
parser.ParseBoard( m_board, origin, m_loadedFootprints, doc.shape );
// Center the board
BOX2I outlineBbox = m_board->ComputeBoundingBox( true );
BOX2I outlineBbox = m_board->ComputeBoundingBox( true, false );
PAGE_INFO pageInfo = m_board->GetPageSettings();
VECTOR2D pageCenter( pcbIUScale.MilsToIU( pageInfo.GetWidthMils() / 2 ),

2
pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp

@ -1819,7 +1819,7 @@ void PCB_IO_EASYEDAPRO_PARSER::ParseBoard(
aBoard->Add( ptr.release(), ADD_MODE::APPEND );
// Center the board
BOX2I outlineBbox = aBoard->ComputeBoundingBox( true );
BOX2I outlineBbox = aBoard->ComputeBoundingBox( true, false );
PAGE_INFO pageInfo = aBoard->GetPageSettings();
VECTOR2D pageCenter( pcbIUScale.MilsToIU( pageInfo.GetWidthMils() / 2 ),

2
pcbnew/pcbnew_jobs_handler.cpp

@ -166,7 +166,7 @@ int PCBNEW_JOBS_HANDLER::JobExportStep( JOB* aJob )
if( !aStepJob->m_hasUserOrigin )
{
BOX2I bbox = brd->ComputeBoundingBox( true );
BOX2I bbox = brd->ComputeBoundingBox( true, false );
originX = pcbIUScale.IUTomm( bbox.GetCenter().x );
originY = pcbIUScale.IUTomm( bbox.GetCenter().y );
}

5
pcbnew/pcbnew_printout.cpp

@ -288,7 +288,10 @@ void PCBNEW_PRINTOUT::setupGal( KIGFX::GAL* aGal )
BOX2I PCBNEW_PRINTOUT::getBoundingBox()
{
return m_board->ComputeBoundingBox();
bool showHiddenText = m_pcbnewSettings.m_AsItemCheckboxes
&& m_board->IsElementVisible( LAYER_HIDDEN_TEXT );
return m_board->ComputeBoundingBox( false, showHiddenText );
}

4
pcbnew/plot_board_layers.cpp

@ -1061,7 +1061,7 @@ static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard,
autocenter = (aPlotOpts->GetScale() != 1.0);
}
BOX2I bbox = aBoard->ComputeBoundingBox();
BOX2I bbox = aBoard->ComputeBoundingBox( false, false );
VECTOR2I boardCenter = bbox.Centre();
VECTOR2I boardSize = bbox.GetSize();
@ -1266,7 +1266,7 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL
// done in the driver (if supported)
if( aPlotOpts->GetNegative() )
{
BOX2I bbox = aBoard->ComputeBoundingBox();
BOX2I bbox = aBoard->ComputeBoundingBox( false, false );
FillNegativeKnockout( plotter, bbox );
}

Loading…
Cancel
Save