diff --git a/eeschema/dialogs/dialog_eeschema_page_settings.cpp b/eeschema/dialogs/dialog_eeschema_page_settings.cpp index afc22dc9b1..1c68cf4e55 100644 --- a/eeschema/dialogs/dialog_eeschema_page_settings.cpp +++ b/eeschema/dialogs/dialog_eeschema_page_settings.cpp @@ -28,7 +28,7 @@ DIALOG_EESCHEMA_PAGE_SETTINGS::DIALOG_EESCHEMA_PAGE_SETTINGS( EDA_DRAW_FRAME* aParent, wxSize aMaxUserSizeMils ) : - DIALOG_PAGES_SETTINGS( aParent, IU_PER_MILS, aMaxUserSizeMils ) + DIALOG_PAGES_SETTINGS( aParent, schIUScale.IU_PER_MILS, aMaxUserSizeMils ) { } diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index cbae82aac6..b037c65611 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -557,7 +557,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF( const wxString& aFileName, plotter->SetColorMode( getModeColor() ); // Currently, plot units are in decimil - plotter->SetViewport( aPlotOffset, IU_PER_MILS/10, aScale, false ); + plotter->SetViewport( aPlotOffset, schIUScale.IU_PER_MILS/10, aScale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-DXF" ) ); @@ -662,8 +662,8 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFiles( bool aPlotAll, bool aPlotFrameRef, if( getPlotOriginAndUnits() == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER ) { - plotOffset.x = plotPage.GetWidthIU( IU_PER_MILS ) / 2; - plotOffset.y = -plotPage.GetHeightIU( IU_PER_MILS ) / 2; + plotOffset.x = plotPage.GetWidthIU( schIUScale.IU_PER_MILS ) / 2; + plotOffset.y = -plotPage.GetHeightIU( schIUScale.IU_PER_MILS ) / 2; } try @@ -725,7 +725,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetHpgl( const wxString& aFileName, plotter->SetRenderSettings( aRenderSettings ); plotter->RenderSettings()->LoadColors( getColorSettings() ); plotter->SetColorMode( getModeColor() ); - plotter->SetViewport( aPlot0ffset, IU_PER_MILS/10, aScale, false ); + plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false ); // TODO this could be configurable plotter->SetTargetChordLength( schIUScale.mmToIU( 0.6 ) ); @@ -907,8 +907,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( IU_PER_MILS ), - aPlotter->PageSettings().GetHeightIU( IU_PER_MILS ) ); + wxPoint end( aPlotter->PageSettings().GetWidthIU( schIUScale.IU_PER_MILS ), + aPlotter->PageSettings().GetHeightIU( schIUScale.IU_PER_MILS ) ); aPlotter->Rect( wxPoint( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 ); } @@ -963,7 +963,7 @@ void DIALOG_PLOT_SCHEMATIC::setupPlotPagePDF( PLOTTER* aPlotter, SCH_SCREEN* aSc aPlotter->SetPageSettings( plotPage ); // Currently, plot units are in decimil - aPlotter->SetViewport( wxPoint( 0, 0 ), IU_PER_MILS/10, scale, false ); + aPlotter->SetViewport( wxPoint( 0, 0 ), schIUScale.IU_PER_MILS/10, scale, false ); } @@ -1083,7 +1083,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName, plotter->SetColorMode( getModeColor() ); // Currently, plot units are in decimil - plotter->SetViewport( aPlot0ffset, IU_PER_MILS/10, aScale, false ); + plotter->SetViewport( aPlot0ffset, schIUScale.IU_PER_MILS/10, aScale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-PS" ) ); @@ -1101,8 +1101,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( IU_PER_MILS ), - plotter->PageSettings().GetHeightIU( IU_PER_MILS ) ); + wxPoint end( plotter->PageSettings().GetWidthIU( schIUScale.IU_PER_MILS ), + plotter->PageSettings().GetHeightIU( schIUScale.IU_PER_MILS ) ); plotter->Rect( wxPoint( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 ); } @@ -1216,7 +1216,7 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( const wxString& aFileName, double scale = 1.0; // Currently, plot units are in decimil - plotter->SetViewport( plot_offset, IU_PER_MILS/10, scale, false ); + plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS/10, scale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-SVG" ) ); @@ -1234,8 +1234,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( IU_PER_MILS ), - plotter->PageSettings().GetHeightIU( IU_PER_MILS ) ); + wxPoint end( plotter->PageSettings().GetWidthIU( schIUScale.IU_PER_MILS ), + plotter->PageSettings().GetHeightIU( schIUScale.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 5e667d95f0..56969e8897 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -425,7 +425,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( IU_PER_MILS ); + pageSizeIU = aScreen->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS ); FitThisSizeToPaper( pageSizeIU ); fitRect = GetLogicalPaperRect(); @@ -501,7 +501,7 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen ) if( printReference ) { - m_parent->PrintDrawingSheet( &renderSettings, aScreen, IU_PER_MILS, aScreen->GetFileName(), + m_parent->PrintDrawingSheet( &renderSettings, aScreen, schIUScale.IU_PER_MILS, aScreen->GetFileName(), wxEmptyString ); } diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index 2b3cb0c683..b9c2e9a189 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -250,7 +250,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() m_page->SetHeightMils( 5000 ); m_page->SetWidthMils( 6000 ); - m_drawingSheet = new DS_PROXY_VIEW_ITEM( (int) IU_PER_MILS, m_page, nullptr, m_titleBlock ); + m_drawingSheet = new DS_PROXY_VIEW_ITEM( (int) schIUScale.IU_PER_MILS, m_page, nullptr, m_titleBlock ); m_drawingSheet->SetColorLayer( LAYER_SCHEMATIC_DRAWINGSHEET ); m_drawingSheet->SetPageBorderColorLayer( LAYER_SCHEMATIC_PAGE_LIMITS ); view->Add( m_drawingSheet ); @@ -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( IU_PER_MILS ), m_page->GetHeightIU( IU_PER_MILS ) ); + VECTOR2I psize( m_page->GetWidthIU( schIUScale.IU_PER_MILS ), m_page->GetHeightIU( schIUScale.IU_PER_MILS ) ); double scale = view->GetScale() / std::max( fabs( psize.x / screenSize.x ), fabs( psize.y / screenSize.y ) ); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index e7fb70f108..c6577ef00c 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -176,7 +176,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet ) if( aDrawingSheet ) { - wsItems.SetMilsToIUfactor( IU_PER_MILS ); + wsItems.SetMilsToIUfactor( schIUScale.IU_PER_MILS ); wsItems.SetPageNumber( "1" ); wsItems.SetSheetCount( 1 ); wsItems.SetFileName( "dummyFilename" ); diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index f423a6e071..6de50bffcb 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( IU_PER_MILS ); + return GetScreen()->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS ); } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 6472e1bf61..d818e4789d 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1276,7 +1276,7 @@ void SCH_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings ) aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY ); GetScreen()->Print( aSettings ); - PrintDrawingSheet( aSettings, GetScreen(), IU_PER_MILS, fileName ); + PrintDrawingSheet( aSettings, GetScreen(), schIUScale.IU_PER_MILS, fileName ); } @@ -1695,8 +1695,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( IU_PER_MILS ); - int sizeY = GetScreen()->GetPageSettings().GetHeightIU( IU_PER_MILS ); + int sizeX = GetScreen()->GetPageSettings().GetWidthIU( schIUScale.IU_PER_MILS ); + int sizeY = GetScreen()->GetPageSettings().GetHeightIU( schIUScale.IU_PER_MILS ); bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) ); } else diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 07a2b54b0b..b3d955c4f2 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -101,9 +101,9 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() : m_OverrideItemColors( false ), m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ), m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ), - m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ) + m_PinSymbolSize( DEFAULT_TEXT_SIZE * schIUScale.IU_PER_MILS / 2 ) { - SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * IU_PER_MILS ); + SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS ); SetDashLengthRatio( 12 ); // From ISO 128-2 SetGapLengthRatio( 3 ); // From ISO 128-2 diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 7af11ff241..02057d6ab5 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -2499,7 +2499,7 @@ void SCH_ALTIUM_PLUGIN::ParseSheet( const std::map<wxString, wxString>& aPropert m_currentSheet->GetScreen()->SetPageSettings( pageInfo ); - m_sheetOffset = { 0, pageInfo.GetHeightIU( IU_PER_MILS ) }; + m_sheetOffset = { 0, pageInfo.GetHeightIU( schIUScale.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 6376960652..04fdb4d1ec 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( IU_PER_MILS ); + wxSize pageSizeIU = sheet->GetScreen()->GetPageSettings().GetSizeIU( schIUScale.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 5fc402a834..b63bdff2f1 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( IU_PER_MILS ); + wxSize pageSizeIU = m_rootSheet->GetScreen()->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS ); BOX2I 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( IU_PER_MILS ); + wxSize pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU( schIUScale.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( IU_PER_MILS ); + pageSizeIU = m_currentSheet->GetScreen()->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS ); VECTOR2I sheetcentre( pageSizeIU.x / 2, pageSizeIU.y / 2 ); VECTOR2I itemsCentre = sheetBoundingBox.Centre(); diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 1909db76f7..585ce02a71 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -72,7 +72,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( IU_PER_MILS ) ); + InitDataPoints( m_paper.GetSizeIU( schIUScale.IU_PER_MILS ) ); } diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 6886112c73..4fce7daecf 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( IU_PER_MILS ) * 3.0; - double max_size_y = page_info.GetHeightIU( IU_PER_MILS ) * 3.0; + double max_size_x = page_info.GetWidthIU( schIUScale.IU_PER_MILS ) * 3.0; + double max_size_y = page_info.GetHeightIU( schIUScale.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 ); } @@ -94,7 +94,7 @@ void SCH_VIEW::DisplaySheet( const SCH_SCREEN *aScreen ) for( SCH_ITEM* item : aScreen->Items() ) Add( item ); - m_drawingSheet.reset( new DS_PROXY_VIEW_ITEM( static_cast<int>( IU_PER_MILS ), + m_drawingSheet.reset( new DS_PROXY_VIEW_ITEM( static_cast<int>( schIUScale.IU_PER_MILS ), &aScreen->GetPageSettings(), &aScreen->Schematic()->Prj(), &aScreen->GetTitleBlock() ) ); diff --git a/eeschema/schematic_settings.cpp b/eeschema/schematic_settings.cpp index d3d3c6fc21..df45a49792 100644 --- a/eeschema/schematic_settings.cpp +++ b/eeschema/schematic_settings.cpp @@ -37,13 +37,13 @@ const int schSettingsSchemaVersion = 1; SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) : NESTED_SETTINGS( "schematic", schSettingsSchemaVersion, aParent, aPath ), - m_DefaultLineWidth( DEFAULT_LINE_WIDTH_MILS * IU_PER_MILS ), - m_DefaultTextSize( DEFAULT_TEXT_SIZE * IU_PER_MILS ), + m_DefaultLineWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS ), + m_DefaultTextSize( DEFAULT_TEXT_SIZE * schIUScale.IU_PER_MILS ), m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ), m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ), - m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ), + m_PinSymbolSize( DEFAULT_TEXT_SIZE * schIUScale.IU_PER_MILS / 2 ), m_JunctionSizeChoice( 3 ), - m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS ), + m_JunctionSize( DEFAULT_JUNCTION_DIAM * schIUScale.IU_PER_MILS ), m_AnnotateStartNum( 0 ), m_IntersheetRefsShow( false ), m_IntersheetRefsListOwnPage( true ), @@ -103,11 +103,11 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin m_params.emplace_back( new PARAM_SCALED<int>( "drawing.default_line_thickness", &m_DefaultLineWidth, Mils2iu( defaultLineThickness ), Mils2iu( 5 ), Mils2iu( 1000 ), - 1 / IU_PER_MILS ) ); + 1 / schIUScale.IU_PER_MILS ) ); m_params.emplace_back( new PARAM_SCALED<int>( "drawing.default_text_size", &m_DefaultTextSize, Mils2iu( defaultTextSize ), Mils2iu( 5 ), Mils2iu( 1000 ), - 1 / IU_PER_MILS ) ); + 1 / schIUScale.IU_PER_MILS ) ); m_params.emplace_back( new PARAM<double>( "drawing.text_offset_ratio", &m_TextOffsetRatio, DEFAULT_TEXT_OFFSET_RATIO, 0.0, 2.0 ) ); @@ -117,7 +117,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin m_params.emplace_back( new PARAM_SCALED<int>( "drawing.pin_symbol_size", &m_PinSymbolSize, Mils2iu( defaultPinSymbolSize ), Mils2iu( 0 ), Mils2iu( 1000 ), - 1 / IU_PER_MILS ) ); + 1 / schIUScale.IU_PER_MILS ) ); // m_JunctionSize is only a run-time cache of the calculated size. Do not save it. diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 3c3f734f73..cce087c965 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -485,7 +485,7 @@ void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard() // the drawings into the dc size // scale is the ratio resolution (in PPI) / internal units double ppi = 300; // Use 300 pixels per inch to create bitmap images on start - double inch2Iu = 1000.0 * IU_PER_MILS; + double inch2Iu = 1000.0 * schIUScale.IU_PER_MILS; double scale = ppi / inch2Iu; wxSize dcsize = DrawArea.GetSize(); diff --git a/eeschema/symbol_editor/symbol_editor_plotter.cpp b/eeschema/symbol_editor/symbol_editor_plotter.cpp index aa50623495..bc6c25d441 100644 --- a/eeschema/symbol_editor/symbol_editor_plotter.cpp +++ b/eeschema/symbol_editor/symbol_editor_plotter.cpp @@ -44,7 +44,7 @@ void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName ) const double scale = 1.0; // Currently, plot units are in decimil - plotter->SetViewport( plot_offset, IU_PER_MILS/10, scale, false ); + plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS/10, scale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-SVG" ) ); @@ -65,8 +65,8 @@ void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName ) TRANSFORM temp; // Uses default transform wxPoint plotPos; - plotPos.x = pageInfo.GetWidthIU( IU_PER_MILS ) / 2; - plotPos.y = pageInfo.GetHeightIU( IU_PER_MILS ) / 2; + plotPos.x = pageInfo.GetWidthIU( schIUScale.IU_PER_MILS ) / 2; + plotPos.y = pageInfo.GetHeightIU( schIUScale.IU_PER_MILS ) / 2; m_symbol->Plot( plotter, GetUnit(), GetConvert(), background, plotPos, temp, false ); @@ -89,7 +89,7 @@ void SYMBOL_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings ) if( !m_symbol ) return; - wxSize pagesize = GetScreen()->GetPageSettings().GetSizeIU( IU_PER_MILS ); + wxSize pagesize = GetScreen()->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS ); /* Plot item centered to the page * In symbol_editor, the symbol is centered at 0,0 coordinates. diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index d246999263..73afb0f166 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -146,7 +146,7 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAM GetRenderSettings()->LoadColors( GetColorSettings() ); GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) ); - GetRenderSettings()->SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * IU_PER_MILS ); + GetRenderSettings()->SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS ); setupTools(); setupUIConditions(); diff --git a/eeschema/tools/ee_grid_helper.cpp b/eeschema/tools/ee_grid_helper.cpp index 19cd2289f5..39803319a2 100644 --- a/eeschema/tools/ee_grid_helper.cpp +++ b/eeschema/tools/ee_grid_helper.cpp @@ -124,7 +124,7 @@ VECTOR2I EE_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, int aLayer, SC VECTOR2I EE_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, int aLayer, const EE_SELECTION& aSkip ) { - constexpr int snapRange = SNAP_RANGE * IU_PER_MILS; + constexpr int snapRange = SNAP_RANGE * schIUScale.IU_PER_MILS; VECTOR2I pt = aOrigin; VECTOR2I snapDist( snapRange, snapRange ); diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index a6b0511199..1a358e15b4 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -793,7 +793,7 @@ bool EXCELLON_IMAGE::readToolInformation( char*& aText ) return false; // conv_scale = scaling factor from inch to Internal Unit - double conv_scale = IU_PER_MILS * 1000; + double conv_scale = gerbIUScale.IU_PER_MILS * 1000; if( m_GerbMetric ) conv_scale /= 25.4; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index e64e74f574..ae923dc86c 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -122,7 +122,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible. - SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU( IU_PER_MILS ) ) ); + SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU( gerbIUScale.IU_PER_MILS ) ) ); // Create the PCB_LAYER_WIDGET *after* SetLayout(): m_LayersManager = new GERBER_LAYER_WIDGET( this, GetCanvas() ); @@ -829,12 +829,12 @@ void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) m_paper = aPageSettings; if( GetScreen() ) - GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( IU_PER_MILS ) ); + GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( gerbIUScale.IU_PER_MILS ) ); GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() ); // Prepare drawing-sheet template - DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(), + DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( gerbIUScale.IU_PER_MILS, &GetPageSettings(), &Prj(), &GetTitleBlock() ); if( GetScreen() ) @@ -862,7 +862,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( IU_PER_MILS ); + return GetPageSettings().GetSizeIU( gerbIUScale.IU_PER_MILS ); } diff --git a/gerbview/gerbview_printout.cpp b/gerbview/gerbview_printout.cpp index 7ec2486237..7f71a5f4c4 100644 --- a/gerbview/gerbview_printout.cpp +++ b/gerbview/gerbview_printout.cpp @@ -75,7 +75,7 @@ bool GERBVIEW_PRINTOUT::OnPrintPage( int aPage ) int GERBVIEW_PRINTOUT::milsToIU( double aMils ) const { - return KiROUND( IU_PER_MILS * aMils ); + return KiROUND( gerbIUScale.IU_PER_MILS * aMils ); } diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index fd50991b0e..5b82000c4f 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -208,7 +208,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, bool y_fmt_known = false; // conv_scale = scaling factor from inch to Internal Unit - double conv_scale = IU_PER_MILS * 1000; + double conv_scale = gerbIUScale.IU_PER_MILS * 1000; if( m_GerbMetric ) conv_scale /= 25.4; @@ -380,7 +380,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, else if( code == MILLIMETER ) m_GerbMetric = true; - conv_scale = m_GerbMetric ? IU_PER_MILS / 25.4 : IU_PER_MILS; + conv_scale = m_GerbMetric ? gerbIUScale.IU_PER_MILS / 25.4 : gerbIUScale.IU_PER_MILS; break; case FILE_ATTRIBUTE: // Command %TF ... diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 7e5ba9fea8..e128bcec08 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -323,12 +323,12 @@ void GERBVIEW_FRAME::updateDCodeSelectBox() break; case EDA_UNITS::INCHES: - scale = IU_PER_MILS * 1000; + scale = gerbIUScale.IU_PER_MILS * 1000; units = wxT( "in" ); break; case EDA_UNITS::MILS: - scale = IU_PER_MILS; + scale = gerbIUScale.IU_PER_MILS; units = wxT( "mil" ); break; diff --git a/gerbview/tools/gerbview_inspection_tool.cpp b/gerbview/tools/gerbview_inspection_tool.cpp index fb57cf0ba6..03887c73d9 100644 --- a/gerbview/tools/gerbview_inspection_tool.cpp +++ b/gerbview/tools/gerbview_inspection_tool.cpp @@ -84,12 +84,12 @@ int GERBVIEW_INSPECTION_TOOL::ShowDCodes( const TOOL_EVENT& aEvent ) break; case EDA_UNITS::INCHES: - scale = IU_PER_MILS * 1000; + scale = gerbIUScale.IU_PER_MILS * 1000; units = wxT( "in" ); break; case EDA_UNITS::MILS: - scale = IU_PER_MILS; + scale = gerbIUScale.IU_PER_MILS; units = wxT( "mil" ); break; diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp index c926c090b9..5731633b51 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( IU_PER_MILS ); + pageSizeIU = m_parent->GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS ); FitThisSizeToPaper( pageSizeIU ); fitRect = GetLogicalPaperRect(); @@ -199,11 +199,11 @@ void PLEDITOR_PRINTOUT::PrintPage( int aPageNum ) if( dataItem->GetType() == DS_DATA_ITEM::DS_BITMAP ) { BITMAP_BASE* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( dataItem )->m_ImageBitmap; - bitmap->SetPixelSizeIu( IU_PER_MILS * 1000 / bitmap->GetPPI() ); + bitmap->SetPixelSizeIu( drawSheetIUScale.IU_PER_MILS * 1000 / bitmap->GetPPI() ); } } - m_parent->PrintDrawingSheet( &renderSettings, screen, IU_PER_MILS, wxEmptyString ); + m_parent->PrintDrawingSheet( &renderSettings, screen, drawSheetIUScale.IU_PER_MILS, wxEmptyString ); m_parent->SetDrawBgColor( bg_color ); diff --git a/pagelayout_editor/pl_draw_panel_gal.cpp b/pagelayout_editor/pl_draw_panel_gal.cpp index 9f0cb2bf2b..96390a84c8 100644 --- a/pagelayout_editor/pl_draw_panel_gal.cpp +++ b/pagelayout_editor/pl_draw_panel_gal.cpp @@ -93,7 +93,7 @@ void PL_DRAW_PANEL_GAL::DisplayDrawingSheet() m_pageDrawItem.reset(); - model.SetupDrawEnvironment( m_edaFrame->GetPageSettings(), IU_PER_MILS ); + model.SetupDrawEnvironment( m_edaFrame->GetPageSettings(), drawSheetIUScale.IU_PER_MILS ); // To show the formatted texts instead of raw texts in drawing sheet editor, we need // a dummy DS_DRAW_ITEM_LIST. @@ -101,7 +101,7 @@ void PL_DRAW_PANEL_GAL::DisplayDrawingSheet() dummy.SetPaperFormat( &m_edaFrame->GetPageSettings().GetType() ); dummy.SetTitleBlock( &m_edaFrame->GetTitleBlock() ); dummy.SetProject( &m_edaFrame->Prj() ); - dummy.SetMilsToIUfactor( IU_PER_MILS ); + dummy.SetMilsToIUfactor( drawSheetIUScale.IU_PER_MILS ); for( DS_DATA_ITEM* dataItem : model.GetItems() ) dataItem->SyncDrawItems( &dummy, m_view ); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 7044316803..41f5b6a15c 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -121,7 +121,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_acceptedExts.emplace( DrawingSheetFileExtension, nullptr ); DragAcceptFiles( true ); - wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU( IU_PER_MILS ); + wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS ); SetScreen( new BASE_SCREEN( pageSizeIU ) ); setupTools(); @@ -474,7 +474,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( IU_PER_MILS ) ); + BOX2I rv( VECTOR2I( 0, 0 ), GetPageLayout().GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS ) ); return rv; } @@ -570,7 +570,7 @@ void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) m_pageLayout.SetPageSettings( aPageSettings ); if( GetScreen() ) - GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( IU_PER_MILS ) ); + GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( drawSheetIUScale.IU_PER_MILS ) ); } @@ -585,7 +585,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( IU_PER_MILS ); + return m_pageLayout.GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS ); } @@ -773,11 +773,11 @@ void PL_EDITOR_FRAME::PrintPage( const RENDER_SETTINGS* aSettings ) if( dataItem->GetType() == DS_DATA_ITEM::DS_BITMAP ) { BITMAP_BASE* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( dataItem )->m_ImageBitmap; - bitmap->SetPixelSizeIu( IU_PER_MILS * 1000 / bitmap->GetPPI() ); + bitmap->SetPixelSizeIu( drawSheetIUScale.IU_PER_MILS * 1000 / bitmap->GetPPI() ); } } - PrintDrawingSheet( aSettings, GetScreen(), IU_PER_MILS, wxEmptyString ); + PrintDrawingSheet( aSettings, GetScreen(), drawSheetIUScale.IU_PER_MILS, wxEmptyString ); GetCanvas()->DisplayDrawingSheet(); GetCanvas()->Refresh(); @@ -864,7 +864,7 @@ DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType ) } // Set the scale factor for pl_editor (it is set for Eeschema by default) - image->SetPixelSizeIu( IU_PER_MILS * 1000.0 / image->GetPPI() ); + image->SetPixelSizeIu( drawSheetIUScale.IU_PER_MILS * 1000.0 / image->GetPPI() ); item = new DS_DATA_ITEM_BITMAP( image ); } break; @@ -938,7 +938,7 @@ bool PL_EDITOR_FRAME::GetPageNumberOption() const #if 1 void PL_EDITOR_FRAME::UpdateMsgPanelInfo() { - VECTOR2D size = GetPageSettings().GetSizeIU( IU_PER_MILS ); + VECTOR2D size = GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS ); std::vector<MSG_PANEL_ITEM> msgItems; msgItems.emplace_back( _( "Page Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( diff --git a/pagelayout_editor/tools/pl_editor_control.cpp b/pagelayout_editor/tools/pl_editor_control.cpp index 3fd2f2008e..40f83b673e 100644 --- a/pagelayout_editor/tools/pl_editor_control.cpp +++ b/pagelayout_editor/tools/pl_editor_control.cpp @@ -89,7 +89,7 @@ int PL_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent ) { m_frame->SaveCopyInUndoList(); - DIALOG_PAGES_SETTINGS dlg( m_frame, IU_PER_MILS, + DIALOG_PAGES_SETTINGS dlg( m_frame, drawSheetIUScale.IU_PER_MILS, wxSize( MAX_PAGE_SIZE_EESCHEMA_MILS, MAX_PAGE_SIZE_EESCHEMA_MILS ) ); dlg.SetWksFileName( m_frame->GetCurrentFileName() ); diff --git a/pcbnew/dialogs/dialog_export_svg.cpp b/pcbnew/dialogs/dialog_export_svg.cpp index d64984d43d..275d19505a 100644 --- a/pcbnew/dialogs/dialog_export_svg.cpp +++ b/pcbnew/dialogs/dialog_export_svg.cpp @@ -340,8 +340,8 @@ bool DIALOG_EXPORT_SVG::CreateSVGFile( const wxString& aFullFileName ) BOX2I bbox = m_board->ComputeBoundingBox(); PAGE_INFO currpageInfo = m_board->GetPageSettings(); - currpageInfo.SetWidthMils( bbox.GetWidth() / IU_PER_MILS ); - currpageInfo.SetHeightMils( bbox.GetHeight() / IU_PER_MILS ); + currpageInfo.SetWidthMils( bbox.GetWidth() / pcbIUScale.IU_PER_MILS ); + currpageInfo.SetHeightMils( bbox.GetHeight() / pcbIUScale.IU_PER_MILS ); m_board->SetPageSettings( currpageInfo ); plot_opts.SetUseAuxOrigin( true ); VECTOR2I origin = bbox.GetOrigin(); diff --git a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp index c38c461216..50f7d94ebd 100644 --- a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp +++ b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp @@ -74,7 +74,7 @@ int InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSetting return dlg.ShowQuasiModal(); } -#define MIN_THICKNESS 10*IU_PER_MILS +#define MIN_THICKNESS 10*pcbIUScale.IU_PER_MILS DIALOG_NON_COPPER_ZONES_EDITOR::DIALOG_NON_COPPER_ZONES_EDITOR( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings, diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 4956e8012a..f69d0b9044 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -228,7 +228,7 @@ void DIALOG_PLOT::init_Dialog() } // Set units and value for HPGL pen size (this param is in mils). - m_defaultPenSize.SetValue( m_plotOpts.GetHPGLPenDiameter() * IU_PER_MILS ); + m_defaultPenSize.SetValue( m_plotOpts.GetHPGLPenDiameter() * pcbIUScale.IU_PER_MILS ); // Test for a reasonable scale value. Set to 1 if problem if( m_XScaleAdjust < PLOT_MIN_SCALE || m_YScaleAdjust < PLOT_MIN_SCALE @@ -784,9 +784,9 @@ void DIALOG_PLOT::applyPlotSettings() // is in use if( getPlotFormat() == PLOT_FORMAT::HPGL ) { - if( !tempOptions.SetHPGLPenDiameter( m_defaultPenSize.GetValue() / IU_PER_MILS ) ) + if( !tempOptions.SetHPGLPenDiameter( m_defaultPenSize.GetValue() / pcbIUScale.IU_PER_MILS ) ) { - m_defaultPenSize.SetValue( tempOptions.GetHPGLPenDiameter() * IU_PER_MILS ); + m_defaultPenSize.SetValue( tempOptions.GetHPGLPenDiameter() * pcbIUScale.IU_PER_MILS ); msg.Printf( _( "HPGL pen size constrained." ) ); reporter.Report( msg, RPT_SEVERITY_INFO ); } diff --git a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp index 0bd4f9dce9..58cfc4af6f 100644 --- a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp @@ -502,7 +502,7 @@ void PANEL_PCBNEW_COLOR_SETTINGS::createPreviewItems() m_preview->UpdateColors(); m_preview->DisplayBoard( m_preview->GetBoard() ); - DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( (int) IU_PER_MILS, m_page, nullptr, + DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( (int) pcbIUScale.IU_PER_MILS, m_page, nullptr, m_titleBlock ); drawingSheet->SetIsFirstPage( true ); drawingSheet->SetColorLayer( LAYER_DRAWINGSHEET ); diff --git a/pcbnew/drc/drc_test_provider_misc.cpp b/pcbnew/drc/drc_test_provider_misc.cpp index 4467fb7400..e5424536ed 100644 --- a/pcbnew/drc/drc_test_provider_misc.cpp +++ b/pcbnew/drc/drc_test_provider_misc.cpp @@ -302,7 +302,7 @@ void DRC_TEST_PROVIDER_MISC::testTextVars() if( !drawingSheet || m_drcEngine->IsErrorLimitExceeded( DRCE_UNRESOLVED_VARIABLE ) ) return; - drawItems.SetMilsToIUfactor( IU_PER_MILS ); + drawItems.SetMilsToIUfactor( pcbIUScale.IU_PER_MILS ); drawItems.SetPageNumber( wxT( "1" ) ); drawItems.SetSheetCount( 1 ); drawItems.SetFileName( wxT( "dummyFilename" ) ); diff --git a/pcbnew/exporters/export_d356.cpp b/pcbnew/exporters/export_d356.cpp index 9547542131..225b8645d7 100644 --- a/pcbnew/exporters/export_d356.cpp +++ b/pcbnew/exporters/export_d356.cpp @@ -86,7 +86,7 @@ static int compute_pad_access_code( BOARD *aPcb, LSET aLayerMask ) /* Convert and clamp a size from IU to decimils */ static int iu_to_d356(int iu, int clamp) { - int val = KiROUND( iu / ( IU_PER_MILS / 10 ) ); + int val = KiROUND( iu / ( pcbIUScale.IU_PER_MILS / 10 ) ); if( val > clamp ) return clamp; if( val < -clamp ) return -clamp; return val; diff --git a/pcbnew/exporters/export_footprints_placefile.cpp b/pcbnew/exporters/export_footprints_placefile.cpp index 58643e0364..e43fc24d9e 100644 --- a/pcbnew/exporters/export_footprints_placefile.cpp +++ b/pcbnew/exporters/export_footprints_placefile.cpp @@ -47,7 +47,7 @@ public: // Defined values to write coordinates using inches or mm: -static const double conv_unit_inch = 0.001 / IU_PER_MILS ; // units = INCHES +static const double conv_unit_inch = 0.001 / pcbIUScale.IU_PER_MILS ; // units = INCHES static const char unit_text_inch[] = "## Unit = inches, Angle = deg.\n"; static const double conv_unit_mm = 1.0 / IU_PER_MM; // units = mm diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index 0cc29de502..26faf68911 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -212,7 +212,7 @@ static const wxString getShapeName( FOOTPRINT* aFootprint ) // GerbTool chokes on units different than INCH so this is the conversion factor -const static double SCALE_FACTOR = 1000.0 * IU_PER_MILS; +const static double SCALE_FACTOR = 1000.0 * pcbIUScale.IU_PER_MILS; /* Two helper functions to calculate coordinates of footprints in gencad values diff --git a/pcbnew/exporters/exporter_vrml.cpp b/pcbnew/exporters/exporter_vrml.cpp index e393101080..892d69866e 100644 --- a/pcbnew/exporters/exporter_vrml.cpp +++ b/pcbnew/exporters/exporter_vrml.cpp @@ -1052,7 +1052,7 @@ void EXPORTER_PCB_VRML::ExportVrmlFootprint( FOOTPRINT* aFootprint, std::ostream compose_quat( q1, q2, q1 ); from_quat( q1, rot ); - double offsetFactor = 1000.0f * IU_PER_MILS / 25.4f; + double offsetFactor = 1000.0f * pcbIUScale.IU_PER_MILS / 25.4f; // adjust 3D shape local offset position // they are given in mm, so they are converted in board IU. diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 017e151de5..a437bae30c 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -44,7 +44,7 @@ /* Conversion utilities - these will be used often in there... */ inline double diameter_in_inches( double ius ) { - return ius * 0.001 / IU_PER_MILS; + return ius * 0.001 / pcbIUScale.IU_PER_MILS; } @@ -98,7 +98,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ { case PLOT_FORMAT::GERBER: plotter = new GERBER_PLOTTER(); - plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false ); + plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false ); plotter->SetGerberCoordinatesFormat( 5 ); // format x.5 unit = mm break; @@ -111,7 +111,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ case PLOT_FORMAT::SVG: { PAGE_INFO pageA4( wxT( "A4" ) ); - wxSize pageSizeIU = pageA4.GetSizeIU( IU_PER_MILS ); + wxSize pageSizeIU = pageA4.GetSizeIU( pcbIUScale.IU_PER_MILS ); // Reserve a 10 mm margin around the page. int margin = pcbIUScale.mmToIU( 10 ); @@ -147,7 +147,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ plotter = new PS_PLOTTER; plotter->SetPageSettings( pageA4 ); - plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false ); + plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false ); break; } @@ -162,7 +162,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ plotter = dxf_plotter; plotter->SetPageSettings( page_info ); - plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false ); + plotter->SetViewport( offset, pcbIUScale.IU_PER_MILS / 10, scale, false ); break; } } diff --git a/pcbnew/exporters/gendrill_Excellon_writer.cpp b/pcbnew/exporters/gendrill_Excellon_writer.cpp index 291b899861..0346aef344 100644 --- a/pcbnew/exporters/gendrill_Excellon_writer.cpp +++ b/pcbnew/exporters/gendrill_Excellon_writer.cpp @@ -361,7 +361,7 @@ void EXCELLON_WRITER::SetFormat( bool aMetric, ZEROS_FMT aZerosFmt, int aLeftDig if( m_unitsMetric ) m_conversionUnits = 1.0 / IU_PER_MM; // EXCELLON units = mm else - m_conversionUnits = 0.001 / IU_PER_MILS; // EXCELLON units = INCHES + m_conversionUnits = 0.001 / pcbIUScale.IU_PER_MILS; // EXCELLON units = INCHES // Set the zero counts. if aZerosFmt == DECIMAL_FORMAT, these values // will be set, but not used. diff --git a/pcbnew/exporters/gendrill_gerber_writer.cpp b/pcbnew/exporters/gendrill_gerber_writer.cpp index 04e86f79d8..fb02762c67 100644 --- a/pcbnew/exporters/gendrill_gerber_writer.cpp +++ b/pcbnew/exporters/gendrill_gerber_writer.cpp @@ -147,7 +147,7 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth, // Add the standard X2 header, without FileFunction AddGerberX2Header( &plotter, m_pcb ); - plotter.SetViewport( m_offset, IU_PER_MILS/10, /* scale */ 1.0, /* mirror */false ); + plotter.SetViewport( m_offset, pcbIUScale.IU_PER_MILS/10, /* scale */ 1.0, /* mirror */false ); // has meaning only for gerber plotter. Must be called only after SetViewport plotter.SetGerberCoordinatesFormat( 6 ); diff --git a/pcbnew/exporters/gerber_placefile_writer.cpp b/pcbnew/exporters/gerber_placefile_writer.cpp index 4f58167daf..6acf56bf04 100644 --- a/pcbnew/exporters/gerber_placefile_writer.cpp +++ b/pcbnew/exporters/gerber_placefile_writer.cpp @@ -85,7 +85,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER // Add the standard X2 header, without FileFunction AddGerberX2Header( &plotter, m_pcb ); - plotter.SetViewport( m_offset, IU_PER_MILS/10, /* scale */ 1.0, /* mirror */false ); + plotter.SetViewport( m_offset, pcbIUScale.IU_PER_MILS/10, /* scale */ 1.0, /* mirror */false ); // has meaning only for gerber plotter. Must be called only after SetViewport plotter.SetGerberCoordinatesFormat( 6 ); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 07ceea8e05..a53b1ee406 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( IU_PER_MILS ) ) ); + SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) ); // Create the manager and dispatcher & route draw panel events to the dispatcher setupTools(); diff --git a/pcbnew/microwave/microwave_polygon.cpp b/pcbnew/microwave/microwave_polygon.cpp index 608b58fa04..96f7be7b42 100644 --- a/pcbnew/microwave/microwave_polygon.cpp +++ b/pcbnew/microwave/microwave_polygon.cpp @@ -242,7 +242,7 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event ) if( strncasecmp( param1, "Unit", 4 ) == 0 ) { if( strncasecmp( param2, "inch", 4 ) == 0 ) - unitconv = IU_PER_MILS*1000; + unitconv = pcbIUScale.IU_PER_MILS*1000; if( strncasecmp( param2, "mm", 2 ) == 0 ) unitconv = IU_PER_MM; diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index 99165b5147..4ccd6e6c80 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -120,7 +120,7 @@ VECTOR2I 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( IU_PER_MILS ); + wxSize pageSize = m_board->GetPageSettings().GetSizeIU( pcbIUScale.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 beed8060b9..fd9ba9487f 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( IU_PER_MILS ) ); + GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( pcbIUScale.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( IU_PER_MILS ); + return m_pcb->GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ); } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index b890c2e3f8..5261d9a7b5 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -233,7 +233,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // initialize parameters in m_LayersManager LoadSettings( config() ); - SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( IU_PER_MILS ) ) ); + SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) ); // PCB drawings start in the upper left corner. GetScreen()->m_Center = false; @@ -529,7 +529,7 @@ void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) PCB_BASE_FRAME::SetPageSettings( aPageSettings ); // Prepare drawing-sheet template - DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( IU_PER_MILS, + DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( pcbIUScale.IU_PER_MILS, &m_pcb->GetPageSettings(), m_pcb->GetProject(), &m_pcb->GetTitleBlock() ); diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp index ee25610ffc..a20106ec68 100644 --- a/pcbnew/pcbnew_printout.cpp +++ b/pcbnew/pcbnew_printout.cpp @@ -126,7 +126,7 @@ bool PCBNEW_PRINTOUT::OnPrintPage( int aPage ) int PCBNEW_PRINTOUT::milsToIU( double aMils ) const { - return KiROUND( IU_PER_MILS * aMils ); + return KiROUND( pcbIUScale.IU_PER_MILS * aMils ); } diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 826bfeb54d..da79f6cf23 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -1007,7 +1007,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( IU_PER_MILS ) ); + wxSize pageSizeIU( pageInfo.GetSizeIU( pcbIUScale.IU_PER_MILS ) ); bool autocenter = false; // Special options: to fit the sheet to an A4 sheet replace the paper size. However there @@ -1018,7 +1018,7 @@ static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard, if( aPlotOpts->GetA4Output() ) { sheet_info = &pageA4; - paperSizeIU = pageA4.GetSizeIU( IU_PER_MILS ); + paperSizeIU = pageA4.GetSizeIU( pcbIUScale.IU_PER_MILS ); paperscale = (double) paperSizeIU.x / pageSizeIU.x; autocenter = true; } @@ -1069,7 +1069,7 @@ static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard, aPlotter->SetPageSettings( *sheet_info ); - aPlotter->SetViewport( offset, IU_PER_MILS/10, compound_scale, aPlotOpts->GetMirror() ); + aPlotter->SetViewport( offset, pcbIUScale.IU_PER_MILS/10, compound_scale, aPlotOpts->GetMirror() ); // Has meaning only for gerber plotter. Must be called only after SetViewport aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() ); @@ -1106,7 +1106,7 @@ static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, const PCB_PLOT_PARAMS { // Compute penDiam (the value is given in mils) in pcb units, with plot scale (if Scale is 2, // penDiam value is always m_HPGLPenDiam so apparent penDiam is actually penDiam / Scale - int penDiam = KiROUND( aPlotOpts->GetHPGLPenDiameter() * IU_PER_MILS / aPlotOpts->GetScale() ); + int penDiam = KiROUND( aPlotOpts->GetHPGLPenDiameter() * pcbIUScale.IU_PER_MILS / aPlotOpts->GetScale() ); // Set HPGL-specific options and start aPlotter->SetPenSpeed( aPlotOpts->GetHPGLPenSpeed() ); diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index d6774ec58b..69f8b068bb 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 BOX2I bbbox = m_board->GetBoardEdgesBoundingBox(); - int w = m_board->GetPageSettings().GetWidthIU( IU_PER_MILS ); - int h = m_board->GetPageSettings().GetHeightIU( IU_PER_MILS ); + int w = m_board->GetPageSettings().GetWidthIU( pcbIUScale.IU_PER_MILS ); + int h = m_board->GetPageSettings().GetHeightIU( pcbIUScale.IU_PER_MILS ); int desired_x = ( w - bbbox.GetWidth() ) / 2; int desired_y = ( h - bbbox.GetHeight() ) / 2; diff --git a/pcbnew/plugins/eagle/eagle_plugin.cpp b/pcbnew/plugins/eagle/eagle_plugin.cpp index 9ab4561a65..5c599b44a0 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.cpp +++ b/pcbnew/plugins/eagle/eagle_plugin.cpp @@ -1593,7 +1593,7 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode ) } else if( p.pour == EPOLYGON::HATCH ) { - int spacing = p.spacing ? p.spacing->ToPcbUnits() : 50 * IU_PER_MILS; + int spacing = p.spacing ? p.spacing->ToPcbUnits() : 50 * pcbIUScale.IU_PER_MILS; zone->SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN ); zone->SetHatchThickness( p.width.ToPcbUnits() ); @@ -1603,7 +1603,7 @@ ZONE* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode ) // We divide the thickness by half because we are tracing _inside_ the zone outline // This means the radius of curvature will be twice the size for an equivalent EAGLE zone - zone->SetMinThickness( std::max<int>( ZONE_THICKNESS_MIN_VALUE_MIL * IU_PER_MILS, + zone->SetMinThickness( std::max<int>( ZONE_THICKNESS_MIN_VALUE_MIL * pcbIUScale.IU_PER_MILS, p.width.ToPcbUnits() / 2 ) ); if( p.isolate ) diff --git a/pcbnew/plugins/fabmaster/import_fabmaster.cpp b/pcbnew/plugins/fabmaster/import_fabmaster.cpp index 062960415a..eecf72327f 100644 --- a/pcbnew/plugins/fabmaster/import_fabmaster.cpp +++ b/pcbnew/plugins/fabmaster/import_fabmaster.cpp @@ -277,19 +277,19 @@ double FABMASTER::processScaleFactor( size_t aRow ) std::transform(units.begin(), units.end(),units.begin(), ::toupper); if( units == "MILS" ) - retval = IU_PER_MILS; + retval = pcbIUScale.IU_PER_MILS; else if( units == "MILLIMETERS" ) retval = IU_PER_MM; else if( units == "MICRONS" ) retval = IU_PER_MM * 10.0; else if( units == "INCHES" ) - retval = IU_PER_MILS * 1000.0; + retval = pcbIUScale.IU_PER_MILS * 1000.0; } if( retval < 1.0 ) { wxLogError( _( "Could not find units value, defaulting to mils." ) ); - retval = IU_PER_MILS; + retval = pcbIUScale.IU_PER_MILS; } return retval; diff --git a/pcbnew/plugins/geda/gpcb_plugin.cpp b/pcbnew/plugins/geda/gpcb_plugin.cpp index 76a734ea76..0215ac5e72 100644 --- a/pcbnew/plugins/geda/gpcb_plugin.cpp +++ b/pcbnew/plugins/geda/gpcb_plugin.cpp @@ -309,11 +309,11 @@ long long GPCB_FPL_CACHE::GetTimestamp( const wxString& aLibPath ) FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader ) { - #define TEXT_DEFAULT_SIZE ( 40*IU_PER_MILS ) - #define OLD_GPCB_UNIT_CONV IU_PER_MILS + #define TEXT_DEFAULT_SIZE ( 40*pcbIUScale.IU_PER_MILS ) + #define OLD_GPCB_UNIT_CONV pcbIUScale.IU_PER_MILS // Old version unit = 1 mil, so conv_unit is 10 or 0.1 - #define NEW_GPCB_UNIT_CONV ( 0.01*IU_PER_MILS ) + #define NEW_GPCB_UNIT_CONV ( 0.01*pcbIUScale.IU_PER_MILS ) int paramCnt; @@ -398,7 +398,7 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader ) // Calculate size: default height is 40 mils, width 30 mil. // real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size int thsize = parseInt( parameters[paramCnt-3], TEXT_DEFAULT_SIZE ) / 100; - thsize = std::max( (int)( 5 * IU_PER_MILS ), thsize ); // Ensure a minimal size = 5 mils + thsize = std::max( (int)( 5 * pcbIUScale.IU_PER_MILS ), thsize ); // Ensure a minimal size = 5 mils int twsize = thsize * 30 / 40; int thickness = thsize / 8; diff --git a/pcbnew/plugins/legacy/legacy_plugin.cpp b/pcbnew/plugins/legacy/legacy_plugin.cpp index 6c37bf7fad..b8c142d568 100644 --- a/pcbnew/plugins/legacy/legacy_plugin.cpp +++ b/pcbnew/plugins/legacy/legacy_plugin.cpp @@ -2885,7 +2885,7 @@ void LEGACY_PLUGIN::init( const PROPERTIES* aProperties ) // mm to nanometers. The deci-mil legacy files have no such "Units" marker // so we must assume the file is in deci-mils until told otherwise. - diskToBiu = IU_PER_MILS / 10; // BIUs are nanometers + diskToBiu = pcbIUScale.IU_PER_MILS / 10; // BIUs are nanometers } diff --git a/pcbnew/plugins/pcad/pcad2kicad_common.cpp b/pcbnew/plugins/pcad/pcad2kicad_common.cpp index 20bad99ee7..a9059f61a8 100644 --- a/pcbnew/plugins/pcad/pcad2kicad_common.cpp +++ b/pcbnew/plugins/pcad/pcad2kicad_common.cpp @@ -161,7 +161,7 @@ double StrToDoublePrecisionUnits( const wxString& aStr, char aAxe, else { ls.ToCDouble( &i ); - i *= IU_PER_MILS; + i *= pcbIUScale.IU_PER_MILS; } } else diff --git a/pcbnew/python/swig/units.i b/pcbnew/python/swig/units.i index 664dde14ac..f28fe0e35b 100644 --- a/pcbnew/python/swig/units.i +++ b/pcbnew/python/swig/units.i @@ -49,7 +49,7 @@ def ToMils(iu): if type(iu) in [int,float]: - return float(iu) / float(IU_PER_MILS) + return float(iu) / float(pcbIUScale.IU_PER_MILS) elif type(iu) in [wxPoint,wxSize,VECTOR2I]: return tuple(map(ToMils,iu)) else: @@ -57,7 +57,7 @@ def FromMils(mils): if type(mils) in [int,float]: - return int(float(mils)*float(IU_PER_MILS)) + return int(float(mils)*float(pcbIUScale.IU_PER_MILS)) elif type(mils) in [wxPoint,wxSize,VECTOR2I]: return tuple(map(FromMils,mils)) else: diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index de784242b5..b33384d7c5 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -294,7 +294,7 @@ int BOARD_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent ) undoCmd.PushItem( wrapper ); m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS ); - DIALOG_PAGES_SETTINGS dlg( m_frame, IU_PER_MILS, wxSize( MAX_PAGE_SIZE_PCBNEW_MILS, + DIALOG_PAGES_SETTINGS dlg( m_frame, pcbIUScale.IU_PER_MILS, wxSize( MAX_PAGE_SIZE_PCBNEW_MILS, MAX_PAGE_SIZE_PCBNEW_MILS ) ); dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );