diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options.cpp b/3d-viewer/dialogs/panel_3D_raytracing_options.cpp index 8dc4c683b1..632d2d6690 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options.cpp +++ b/3d-viewer/dialogs/panel_3D_raytracing_options.cpp @@ -25,6 +25,7 @@ #include <pgm_base.h> #include <settings/settings_manager.h> #include <eda_3d_viewer_settings.h> +#include <base_units.h> #include "panel_3D_raytracing_options.h" diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 094ab7c91d..c99465bcb3 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -344,6 +344,7 @@ set( COMMON_SRCS netclass.cpp observable.cpp origin_transforms.cpp + page_info.cpp paths.cpp printout.cpp project.cpp @@ -507,7 +508,6 @@ set( PCB_COMMON_SRCS eda_shape.cpp fp_lib_table.cpp hash_eda.cpp - page_info.cpp pg_properties.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_base_frame.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_expr_evaluator.cpp diff --git a/common/page_info.cpp b/common/page_info.cpp index 0318b061f3..5f1b9624f9 100644 --- a/common/page_info.cpp +++ b/common/page_info.cpp @@ -26,6 +26,7 @@ #include <common.h> #include <page_info.h> #include <macros.h> +#include <base_units.h> // for Mm2mils // late arriving wxPAPER_A0, wxPAPER_A1 diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 69e241c62d..8f64d53da4 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -322,7 +322,6 @@ set( EESCHEMA_COMMON_SRCS ${CMAKE_SOURCE_DIR}/common/base_units.cpp ${CMAKE_SOURCE_DIR}/common/eda_shape.cpp ${CMAKE_SOURCE_DIR}/common/eda_text.cpp - ${CMAKE_SOURCE_DIR}/common/page_info.cpp ) diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp index 1045b94044..c2d94907a9 100644 --- a/eeschema/dialogs/dialog_annotate.cpp +++ b/eeschema/dialogs/dialog_annotate.cpp @@ -24,6 +24,7 @@ #include <sch_edit_frame.h> +#include <base_units.h> #include <bitmaps.h> #include <confirm.h> #include <dialog_annotate_base.h> diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index d2c8393b18..5866277929 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -26,6 +26,7 @@ #include "lib_pin.h" #include "pin_numbers.h" #include "pgm_base.h" +#include <base_units.h> #include <bitmaps.h> #include <confirm.h> #include <symbol_edit_frame.h> diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index a84a73870f..9f7a39a51b 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -657,8 +657,8 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFiles( bool aPlotAll, bool aPlotFrameRef, if( getPlotOriginAndUnits() == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER ) { - plotOffset.x = plotPage.GetWidthIU() / 2; - plotOffset.y = -plotPage.GetHeightIU() / 2; + plotOffset.x = plotPage.GetWidthIU( IU_PER_MILS ) / 2; + plotOffset.y = -plotPage.GetHeightIU( IU_PER_MILS ) / 2; } try @@ -899,8 +899,8 @@ void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScr if( m_plotBackgroundColor->GetValue() && aPlotter->GetColorMode() ) { aPlotter->SetColor( aPlotter->RenderSettings()->GetBackgroundColor() ); - wxPoint end( aPlotter->PageSettings().GetWidthIU(), - aPlotter->PageSettings().GetHeightIU() ); + wxPoint end( aPlotter->PageSettings().GetWidthIU( IU_PER_MILS ), + aPlotter->PageSettings().GetHeightIU( IU_PER_MILS ) ); aPlotter->Rect( wxPoint( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 ); } @@ -1093,7 +1093,8 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName, if( m_plotBackgroundColor->GetValue() && plotter->GetColorMode() ) { plotter->SetColor( plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) ); - wxPoint end( plotter->PageSettings().GetWidthIU(), plotter->PageSettings().GetHeightIU() ); + wxPoint end( plotter->PageSettings().GetWidthIU( IU_PER_MILS ), + plotter->PageSettings().GetHeightIU( IU_PER_MILS ) ); plotter->Rect( wxPoint( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 ); } @@ -1225,8 +1226,8 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( const wxString& aFileName, if( m_plotBackgroundColor->GetValue() && plotter->GetColorMode() ) { plotter->SetColor( plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) ); - wxPoint end( plotter->PageSettings().GetWidthIU(), - plotter->PageSettings().GetHeightIU() ); + wxPoint end( plotter->PageSettings().GetWidthIU( IU_PER_MILS ), + plotter->PageSettings().GetHeightIU( IU_PER_MILS ) ); plotter->Rect( wxPoint( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 ); } diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index c732275813..717d1ac539 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -423,7 +423,7 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen ) // Change scale factor and offset to print the whole page. bool printReference = cfg->m_Printing.title_block; - pageSizeIU = aScreen->GetPageSettings().GetSizeIU(); + pageSizeIU = aScreen->GetPageSettings().GetSizeIU( IU_PER_MILS ); FitThisSizeToPaper( pageSizeIU ); fitRect = GetLogicalPaperRect(); diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index 9d3cca3f55..2b3cb0c683 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -501,7 +501,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview() view->SetScale( 1.0 ); VECTOR2D screenSize = view->ToWorld( m_preview->GetClientSize(), false ); - VECTOR2I psize( m_page->GetWidthIU(), m_page->GetHeightIU() ); + VECTOR2I psize( m_page->GetWidthIU( IU_PER_MILS ), m_page->GetHeightIU( IU_PER_MILS ) ); double scale = view->GetScale() / std::max( fabs( psize.x / screenSize.x ), fabs( psize.y / screenSize.y ) ); diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index f3ea627731..ffb8cad1ef 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -23,6 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <base_units.h> #include <pgm_base.h> #include <sch_draw_panel.h> #include <sch_edit_frame.h> diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp index 3095accd0f..6cd148fee3 100644 --- a/eeschema/lib_textbox.cpp +++ b/eeschema/lib_textbox.cpp @@ -21,6 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <base_units.h> #include <pgm_base.h> #include <sch_edit_frame.h> #include <plotters/plotter.h> diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 6e0cba38dc..78633de15e 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -151,7 +151,7 @@ const PAGE_INFO& SCH_BASE_FRAME::GetPageSettings () const const wxSize SCH_BASE_FRAME::GetPageSizeIU() const { // GetSizeIU is compile time dependent: - return GetScreen()->GetPageSettings().GetSizeIU(); + return GetScreen()->GetPageSettings().GetSizeIU( IU_PER_MILS ); } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 549ef47f15..d3f85c16f6 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1670,8 +1670,8 @@ const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const if( aIncludeAllVisible ) { // Get the whole page size and return that - int sizeX = GetScreen()->GetPageSettings().GetWidthIU(); - int sizeY = GetScreen()->GetPageSettings().GetHeightIU(); + int sizeX = GetScreen()->GetPageSettings().GetWidthIU( IU_PER_MILS ); + int sizeY = GetScreen()->GetPageSettings().GetHeightIU( IU_PER_MILS ); bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) ); } else diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 5d14f1048e..5d7dfa8e14 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -32,6 +32,7 @@ #include <wx/log.h> #include <wx/menu.h> +#include <base_units.h> #include <common.h> // for ExpandTextVars #include <eda_item.h> #include <sch_edit_frame.h> diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 441cf895de..6ec58b1994 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -23,6 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <base_units.h> #include <pgm_base.h> #include <sch_edit_frame.h> #include <plotters/plotter.h> diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 2124d9b1c6..748b95719c 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -22,6 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <base_units.h> #include <bitmaps.h> #include <string_utils.h> #include <core/mirror.h> diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 21f5db0547..4ff5df1be0 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -19,6 +19,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <base_units.h> #include <lib_pin.h> #include <sch_symbol.h> #include <sch_pin.h> diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 962f01f573..8855c3b188 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -2429,7 +2429,7 @@ void SCH_ALTIUM_PLUGIN::ParseSheet( const std::map<wxString, wxString>& aPropert m_currentSheet->GetScreen()->SetPageSettings( pageInfo ); - m_sheetOffset = { 0, pageInfo.GetHeightIU() }; + m_sheetOffset = { 0, pageInfo.GetHeightIU( IU_PER_MILS ) }; } diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index a379fc1c83..e31f09621e 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -232,7 +232,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh // Set the new sheet size. sheet->GetScreen()->SetPageSettings( pageInfo ); - wxSize pageSizeIU = sheet->GetScreen()->GetPageSettings().GetSizeIU(); + wxSize pageSizeIU = sheet->GetScreen()->GetPageSettings().GetSizeIU( IU_PER_MILS ); VECTOR2I sheetcentre( pageSizeIU.x / 2, pageSizeIU.y / 2 ); VECTOR2I itemsCentre = sheetBoundingBox.Centre(); diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index 5fa9d58757..375be5f32c 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -755,7 +755,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode ) // Calculate the already placed items bounding box and the page size to determine // placement for the new symbols - wxSize pageSizeIU = m_rootSheet->GetScreen()->GetPageSettings().GetSizeIU(); + wxSize pageSizeIU = m_rootSheet->GetScreen()->GetPageSettings().GetSizeIU( IU_PER_MILS ); EDA_RECT sheetBbox = getSheetBbox( m_rootSheet ); VECTOR2I newCmpPosition( sheetBbox.GetLeft(), sheetBbox.GetBottom() ); int maxY = sheetBbox.GetY(); @@ -940,7 +940,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex ) targetSheetSize += VECTOR2I( Mils2iu( 1500 ), Mils2iu( 1500 ) ); // Get current Eeschema sheet size. - wxSize pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU(); + wxSize pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU( IU_PER_MILS ); PAGE_INFO pageInfo = m_currentSheet->GetScreen()->GetPageSettings(); // Increase if necessary @@ -953,7 +953,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex ) // Set the new sheet size. m_currentSheet->GetScreen()->SetPageSettings( pageInfo ); - pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU(); + pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU( IU_PER_MILS ); VECTOR2I sheetcentre( pageSizeIU.x / 2, pageSizeIU.y / 2 ); VECTOR2I itemsCentre = sheetBoundingBox.Centre(); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp index 1f42547ae9..002d7021ab 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp @@ -19,6 +19,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <base_units.h> #include <lib_field.h> #include <lib_shape.h> #include <lib_symbol.h> diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index ada2235c77..1c247472b1 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -34,6 +34,7 @@ #include <wx/mstream.h> #include <wx/tokenzr.h> +#include <base_units.h> #include <lib_id.h> #include <lib_shape.h> #include <lib_pin.h> diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 8c3f9a64f0..6ee136ef43 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -29,6 +29,7 @@ #include <wx/log.h> #include <wx/mstream.h> #include <advanced_config.h> +#include <base_units.h> #include <trace_helpers.h> #include <locale_io.h> #include <sch_bitmap.h> diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin_common.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin_common.cpp index 2ed2414837..0fdf1c3679 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin_common.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin_common.cpp @@ -18,6 +18,7 @@ */ #include <advanced_config.h> +#include <base_units.h> #include <macros.h> #include <schematic_lexer.h> #include "sch_sexpr_plugin_common.h" diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 88d64544f2..79ba857c8e 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -73,7 +73,7 @@ SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) : // Suitable for schematic only. For symbol_editor and viewlib, must be set to true m_Center = false; - InitDataPoints( m_paper.GetSizeIU() ); + InitDataPoints( m_paper.GetSizeIU( IU_PER_MILS ) ); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 9f544dee9a..c446078a63 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -23,6 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <base_units.h> #include <pgm_base.h> #include <sch_edit_frame.h> #include <plotters/plotter.h> diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index 1a7537153a..ddc3fdcd3d 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -21,6 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <base_units.h> #include <pgm_base.h> #include <sch_edit_frame.h> #include <plotters/plotter.h> diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 844dd3661f..6886112c73 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -82,8 +82,8 @@ void SCH_VIEW::SetScale( double aScale, VECTOR2D aAnchor ) void SCH_VIEW::ResizeSheetWorkingArea( const SCH_SCREEN* aScreen ) { const PAGE_INFO& page_info = aScreen->GetPageSettings(); - double max_size_x = page_info.GetWidthIU() * 3.0; - double max_size_y = page_info.GetHeightIU() * 3.0; + double max_size_x = page_info.GetWidthIU( IU_PER_MILS ) * 3.0; + double max_size_y = page_info.GetHeightIU( IU_PER_MILS ) * 3.0; m_boundary.SetOrigin( -max_size_x / 4, -max_size_y / 4 ); m_boundary.SetSize( max_size_x, max_size_y ); } diff --git a/eeschema/symbol_editor/symbol_editor_plotter.cpp b/eeschema/symbol_editor/symbol_editor_plotter.cpp index 7f4a699008..a63d6564fe 100644 --- a/eeschema/symbol_editor/symbol_editor_plotter.cpp +++ b/eeschema/symbol_editor/symbol_editor_plotter.cpp @@ -65,8 +65,8 @@ void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName ) TRANSFORM temp; // Uses default transform wxPoint plotPos; - plotPos.x = pageInfo.GetWidthIU() / 2; - plotPos.y = pageInfo.GetHeightIU() / 2; + plotPos.x = pageInfo.GetWidthIU( IU_PER_MILS ) / 2; + plotPos.y = pageInfo.GetHeightIU( IU_PER_MILS ) / 2; m_symbol->Plot( plotter, GetUnit(), GetConvert(), background, plotPos, temp ); @@ -89,7 +89,7 @@ void SYMBOL_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings ) if( !m_symbol ) return; - wxSize pagesize = GetScreen()->GetPageSettings().GetSizeIU(); + wxSize pagesize = GetScreen()->GetPageSettings().GetSizeIU( IU_PER_MILS ); /* Plot item centered to the page * In symbol_editor, the symbol is centered at 0,0 coordinates. diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 1e0e26baa6..bce392ce67 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -77,7 +77,6 @@ set( GERBVIEW_EXTRA_SRCS ${CMAKE_SOURCE_DIR}/common/eda_text.cpp ${CMAKE_SOURCE_DIR}/common/widgets/layer_box_selector.cpp ${CMAKE_SOURCE_DIR}/common/lset.cpp - ${CMAKE_SOURCE_DIR}/common/page_info.cpp ) if( WIN32 ) diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index b2a2386403..98b4292bec 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -22,6 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <base_units.h> #include <trigo.h> #include <bitmaps.h> #include <eda_text.h> diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 59938aa477..daa4a20498 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -19,6 +19,7 @@ */ #include <kiface_base.h> +#include <base_units.h> #include <pgm_base.h> #include <bitmaps.h> #include <wildcards_and_files_ext.h> @@ -120,7 +121,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible. - SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU() ) ); + SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU( IU_PER_MILS ) ) ); // Create the PCB_LAYER_WIDGET *after* SetLayout(): m_LayersManager = new GERBER_LAYER_WIDGET( this, GetCanvas() ); @@ -821,7 +822,7 @@ void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) m_paper = aPageSettings; if( GetScreen() ) - GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() ); + GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( IU_PER_MILS ) ); GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() ); @@ -854,7 +855,7 @@ const wxSize GERBVIEW_FRAME::GetPageSizeIU() const // this function is only needed because EDA_DRAW_FRAME is not compiled // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route // into an application specific source file. - return GetPageSettings().GetSizeIU(); + return GetPageSettings().GetSizeIU( IU_PER_MILS ); } diff --git a/include/page_info.h b/include/page_info.h index aec47754b3..7857326587 100644 --- a/include/page_info.h +++ b/include/page_info.h @@ -31,9 +31,9 @@ #define PAGE_INFO_H #include <wx/string.h> +#include <math/vector2d.h> #include <richio.h> // for OUTPUTFORMATTER and IO_ERROR -#include <base_units.h> // for IU_PER_MILS /// Min and max page sizes for clamping, in mils. #define MIN_PAGE_SIZE_MILS 1000 @@ -134,13 +134,35 @@ public: const VECTOR2I& GetSizeMils() const { return m_size; } - // Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA, - // and either deci-mils or nanometers in PCBNew. -#if defined(PCBNEW) || defined(EESCHEMA) || defined(GERBVIEW) || defined(PL_EDITOR) - int GetWidthIU() const { return IU_PER_MILS * GetWidthMils(); } - int GetHeightIU() const { return IU_PER_MILS * GetHeightMils(); } - const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); } -#endif + /** + * Gets the page width in IU + * + * @param aIUScale The IU scale, this is most likely always going to be IU_PER_MILS + * variable being passed. Note, this constexpr variable changes depending + * on application, hence why it is passed. + */ + int GetWidthIU( double aIUScale ) const { return aIUScale * GetWidthMils(); } + + /** + * Gets the page height in IU + * + * @param aIUScale The IU scale, this is most likely always going to be IU_PER_MILS + * variable being passed. Note, this constexpr variable changes depending + * on application, hence why it is passed. + */ + int GetHeightIU( double aIUScale ) const { return aIUScale * GetHeightMils(); } + + /** + * Gets the page size in internal units + * + * @param aIUScale The IU scale, this is most likely always going to be IU_PER_MILS + * variable being passed. Note, this constexpr variable changes depending + * on application, hence why it is passed. + */ + const wxSize GetSizeIU( double aIUScale ) const + { + return wxSize( GetWidthIU( aIUScale ), GetHeightIU( aIUScale ) ); + } /** * Set the width of Custom page in mils for any custom page constructed or made via diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index b8b99ad371..1d9b0534c9 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -49,7 +49,6 @@ set( PL_EDITOR_EXTRA_SRCS ${CMAKE_SOURCE_DIR}/common/base_units.cpp ${CMAKE_SOURCE_DIR}/common/eda_text.cpp ${CMAKE_SOURCE_DIR}/common/dialogs/panel_gal_display_options.cpp - ${CMAKE_SOURCE_DIR}/common/page_info.cpp ) if( WIN32 ) diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp index c30a157bf1..c926c090b9 100644 --- a/pagelayout_editor/dialogs/dialogs_for_printing.cpp +++ b/pagelayout_editor/dialogs/dialogs_for_printing.cpp @@ -169,7 +169,7 @@ void PLEDITOR_PRINTOUT::PrintPage( int aPageNum ) // Change scale factor and offset to print the whole page. - pageSizeIU = m_parent->GetPageSettings().GetSizeIU(); + pageSizeIU = m_parent->GetPageSettings().GetSizeIU( IU_PER_MILS ); FitThisSizeToPaper( pageSizeIU ); fitRect = GetLogicalPaperRect(); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index b65e7b1c2a..4f805ee4ab 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -114,7 +114,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : LoadSettings( config() ); - wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU(); + wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU( IU_PER_MILS ); SetScreen( new BASE_SCREEN( pageSizeIU ) ); setupTools(); @@ -467,7 +467,7 @@ void PL_EDITOR_FRAME::ToPrinter( bool doPreview ) const BOX2I PL_EDITOR_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const { - BOX2I rv( VECTOR2I( 0, 0 ), GetPageLayout().GetPageSettings().GetSizeIU() ); + BOX2I rv( VECTOR2I( 0, 0 ), GetPageLayout().GetPageSettings().GetSizeIU( IU_PER_MILS ) ); return rv; } @@ -563,7 +563,7 @@ void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) m_pageLayout.SetPageSettings( aPageSettings ); if( GetScreen() ) - GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() ); + GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( IU_PER_MILS ) ); } @@ -578,7 +578,7 @@ const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const // this function is only needed because EDA_DRAW_FRAME is not compiled // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route // into an application specific source file. - return m_pageLayout.GetPageSettings().GetSizeIU(); + return m_pageLayout.GetPageSettings().GetSizeIU( IU_PER_MILS ); } @@ -928,7 +928,7 @@ bool PL_EDITOR_FRAME::GetPageNumberOption() const #if 1 void PL_EDITOR_FRAME::UpdateMsgPanelInfo() { - VECTOR2D size = GetPageSettings().GetSizeIU(); + VECTOR2D size = GetPageSettings().GetSizeIU( IU_PER_MILS ); std::vector<MSG_PANEL_ITEM> msgItems; msgItems.emplace_back( _( "Page Width" ), MessageTextFromValue( GetUserUnits(), size.x ) ); diff --git a/pcbnew/dialogs/dialog_export_vrml.cpp b/pcbnew/dialogs/dialog_export_vrml.cpp index e9c14913d4..03a6b041cf 100644 --- a/pcbnew/dialogs/dialog_export_vrml.cpp +++ b/pcbnew/dialogs/dialog_export_vrml.cpp @@ -28,6 +28,7 @@ #include <wx/dir.h> +#include <base_units.h> #include <board.h> #include <confirm.h> #include <kiface_base.h> diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 7d54839b95..8d323aa6f2 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -112,7 +112,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ case PLOT_FORMAT::SVG: { PAGE_INFO pageA4( wxT( "A4" ) ); - wxSize pageSizeIU = pageA4.GetSizeIU(); + wxSize pageSizeIU = pageA4.GetSizeIU( IU_PER_MILS ); // Reserve a 10 mm margin around the page. int margin = Millimeter2iu( 10 ); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 71d65d24d6..3c3e915bd6 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -160,7 +160,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // In Footprint Editor, set the default paper size to A4 for plot/print SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) ); - SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) ); + SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( IU_PER_MILS ) ) ); // Create the manager and dispatcher & route draw panel events to the dispatcher setupTools(); diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 857d8b57f6..09aa96db2a 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -23,6 +23,7 @@ #include <utility> #include "pcbnew_settings.h" +#include <base_units.h> #include <board.h> #include <footprint.h> #include <eda_draw_frame.h> diff --git a/pcbnew/import_gfx/dialog_import_gfx.cpp b/pcbnew/import_gfx/dialog_import_gfx.cpp index ecfca52ebc..4354a95d1a 100644 --- a/pcbnew/import_gfx/dialog_import_gfx.cpp +++ b/pcbnew/import_gfx/dialog_import_gfx.cpp @@ -25,6 +25,7 @@ #include <dialogs/html_message_box.h> #include "dialog_import_gfx.h" +#include <base_units.h> #include <kiface_base.h> #include <locale_io.h> #include <pcb_layer_box_selector.h> diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index bc65d48f03..6cd4cbb31d 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -29,6 +29,7 @@ #include <common.h> // for PAGE_INFO +#include <base_units.h> #include <board.h> #include <netinfo.h> #include <footprint.h> @@ -119,7 +120,7 @@ wxPoint BOARD_NETLIST_UPDATER::estimateFootprintInsertionPosition() else { // Position new components in the center of the page when the board is empty. - wxSize pageSize = m_board->GetPageSettings().GetSizeIU(); + wxSize pageSize = m_board->GetPageSettings().GetSizeIU( IU_PER_MILS ); bestPosition.x = pageSize.GetWidth() / 2; bestPosition.y = pageSize.GetHeight() / 2; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 90d8b7863f..17bca69f59 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -528,7 +528,7 @@ void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) m_pcb->SetPageSettings( aPageSettings ); if( GetScreen() ) - GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() ); + GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( IU_PER_MILS ) ); } @@ -543,7 +543,7 @@ const wxSize PCB_BASE_FRAME::GetPageSizeIU() const // this function is only needed because EDA_DRAW_FRAME is not compiled // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route // into an application specific source file. - return m_pcb->GetPageSettings().GetSizeIU(); + return m_pcb->GetPageSettings().GetSizeIU( IU_PER_MILS ); } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index bb927e0d87..2104f77c21 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -228,7 +228,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // initialize parameters in m_LayersManager LoadSettings( config() ); - SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) ); + SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( IU_PER_MILS ) ) ); // PCB drawings start in the upper left corner. GetScreen()->m_Center = false; diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index db4e8aaa8e..5d679d0c32 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -973,7 +973,7 @@ static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard, const PAGE_INFO* sheet_info; double paperscale; // Page-to-paper ratio wxSize paperSizeIU; - wxSize pageSizeIU( pageInfo.GetSizeIU() ); + wxSize pageSizeIU( pageInfo.GetSizeIU( IU_PER_MILS ) ); bool autocenter = false; // Special options: to fit the sheet to an A4 sheet replace the paper size. However there @@ -984,7 +984,7 @@ static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard, if( aPlotOpts->GetA4Output() ) { sheet_info = &pageA4; - paperSizeIU = pageA4.GetSizeIU(); + paperSizeIU = pageA4.GetSizeIU( IU_PER_MILS ); paperscale = (double) paperSizeIU.x / pageSizeIU.x; autocenter = true; } diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index ef16747b64..e3b9e5a918 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -638,8 +638,8 @@ void ALTIUM_PCB::Parse( const ALTIUM_COMPOUND_FILE& altiumPcbFi // center board EDA_RECT bbbox = m_board->GetBoardEdgesBoundingBox(); - int w = m_board->GetPageSettings().GetWidthIU(); - int h = m_board->GetPageSettings().GetHeightIU(); + int w = m_board->GetPageSettings().GetWidthIU( IU_PER_MILS ); + int h = m_board->GetPageSettings().GetHeightIU( IU_PER_MILS ); int desired_x = ( w - bbbox.GetWidth() ) / 2; int desired_y = ( h - bbbox.GetHeight() ) / 2;