diff --git a/3d-viewer/3d_canvas/board_adapter.cpp b/3d-viewer/3d_canvas/board_adapter.cpp index bbe7212219..198e6fd12a 100644 --- a/3d-viewer/3d_canvas/board_adapter.cpp +++ b/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 ) ) diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 930a1e40d5..72f626cc54 100644 --- a/pcbnew/board.cpp +++ b/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 ) ); } } diff --git a/pcbnew/board.h b/pcbnew/board.h index b02d9cb4d5..cae1d507b9 100644 --- a/pcbnew/board.h +++ b/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& aList ) override; diff --git a/pcbnew/convert_shape_list_to_polygon.cpp b/pcbnew/convert_shape_list_to_polygon.cpp index b52627a10c..681ac5d935 100644 --- a/pcbnew/convert_shape_list_to_polygon.cpp +++ b/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 ) ) diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index 44f11e2d92..378011aaf9 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/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; diff --git a/pcbnew/dialogs/dialog_export_vrml.cpp b/pcbnew/dialogs/dialog_export_vrml.cpp index 516ddaacc6..b0676156ad 100644 --- a/pcbnew/dialogs/dialog_export_vrml.cpp +++ b/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 ); } diff --git a/pcbnew/exporters/export_gencad_writer.cpp b/pcbnew/exporters/export_gencad_writer.cpp index af78c0d710..31f4e71d43 100644 --- a/pcbnew/exporters/export_gencad_writer.cpp +++ b/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. diff --git a/pcbnew/exporters/export_svg.cpp b/pcbnew/exporters/export_svg.cpp index b17817d6d9..d1ea3a9663 100644 --- a/pcbnew/exporters/export_svg.cpp +++ b/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 ); diff --git a/pcbnew/exporters/place_file_exporter.cpp b/pcbnew/exporters/place_file_exporter.cpp index dd060074ad..dfc2ebd780 100644 --- a/pcbnew/exporters/place_file_exporter.cpp +++ b/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"; diff --git a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp index 51e4ccb033..d74c2ead74 100644 --- a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp +++ b/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 ), diff --git a/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp b/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp index 66b26ac217..31f19b6df5 100644 --- a/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp +++ b/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 ), diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index 13260e3a7b..dedb50e337 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/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 ); } diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp index 8bf97ac8e9..25a2f10d6c 100644 --- a/pcbnew/pcbnew_printout.cpp +++ b/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 ); } diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 05285b4ddd..f8afe6cfbd 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/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 ); }