diff --git a/common/bitmap_base.cpp b/common/bitmap_base.cpp index d9734fa96d..2210d63e86 100644 --- a/common/bitmap_base.cpp +++ b/common/bitmap_base.cpp @@ -44,12 +44,12 @@ BITMAP_BASE::BITMAP_BASE( const wxPoint& pos ) { - m_scale = 1.0; // 1.0 = original bitmap size + m_scale = 1.0; // 1.0 = original bitmap size m_bitmap = NULL; m_image = NULL; - m_ppi = 300; // the bitmap definition. the default is 300PPI - m_pixelScaleFactor = 254000.0 / m_ppi; // a value OK for bitmaps using 300 PPI - // for Eeschema which uses currently 254000PPI + m_ppi = 300; // the bitmap definition. the default is 300PPI + m_pixelSizeIu = 254000.0 / m_ppi; // a pixel size value OK for bitmaps using 300 PPI + // for Eeschema which uses currently 254000PPI } @@ -57,7 +57,7 @@ BITMAP_BASE::BITMAP_BASE( const BITMAP_BASE& aSchBitmap ) { m_scale = aSchBitmap.m_scale; m_ppi = aSchBitmap.m_ppi; - m_pixelScaleFactor = aSchBitmap.m_pixelScaleFactor; + m_pixelSizeIu = aSchBitmap.m_pixelSizeIu; m_image = nullptr; m_bitmap = nullptr; @@ -80,7 +80,7 @@ void BITMAP_BASE::ImportData( BITMAP_BASE* aItem ) *m_bitmap = *aItem->m_bitmap; m_scale = aItem->m_scale; m_ppi = aItem->m_ppi; - m_pixelScaleFactor = aItem->m_pixelScaleFactor; + m_pixelSizeIu = aItem->m_pixelSizeIu; } diff --git a/common/common.cpp b/common/common.cpp index 81de209180..eaa07be1d1 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -308,7 +308,6 @@ bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, if( !wxFileName::DirExists( outputPath ) ) { // Make every directory provided when the provided path doesn't exist - // Fixes GitLab Issue #6394 if( wxFileName::Mkdir( outputPath, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) ) { if( aReporter ) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 2ca4bef4d7..427f4d3376 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -823,13 +823,13 @@ static const wxString productName = wxT( "KiCad E.D.A. " ); void PrintPageLayout( RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo, const wxString& aFullSheetName, const wxString& aFileName, const TITLE_BLOCK& aTitleBlock, int aSheetCount, const wxString& aPageNumber, - double aScalar, const PROJECT* aProject, const wxString& aSheetLayer, + double aMils2Iu, const PROJECT* aProject, const wxString& aSheetLayer, bool aIsFirstPage ) { WS_DRAW_ITEM_LIST drawList; drawList.SetDefaultPenSize( aSettings->GetDefaultPenWidth() ); - drawList.SetMilsToIUfactor( aScalar ); + drawList.SetMilsToIUfactor( aMils2Iu ); drawList.SetPageNumber( aPageNumber ); drawList.SetSheetCount( aSheetCount ); drawList.SetFileName( aFileName ); @@ -846,7 +846,7 @@ void PrintPageLayout( RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo, void EDA_DRAW_FRAME::PrintWorkSheet( RENDER_SETTINGS* aSettings, BASE_SCREEN* aScreen, - double aScalar, const wxString &aFilename, + double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer ) { if( !m_showBorderAndTitleBlock ) @@ -862,7 +862,7 @@ void EDA_DRAW_FRAME::PrintWorkSheet( RENDER_SETTINGS* aSettings, BASE_SCREEN* aS } PrintPageLayout( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(), - aScreen->GetPageCount(), aScreen->GetPageNumber(), aScalar, &Prj(), + aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, &Prj(), aSheetLayer, aScreen->GetVirtualPageNumber() == 1 ); if( origin.y > 0 ) diff --git a/common/page_layout/ws_data_item.cpp b/common/page_layout/ws_data_item.cpp index 475f74405f..6d6a398637 100644 --- a/common/page_layout/ws_data_item.cpp +++ b/common/page_layout/ws_data_item.cpp @@ -762,7 +762,11 @@ void WS_DATA_ITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::V if( j && !IsInsidePage( j ) ) continue; - auto bitmap = new WS_DRAW_ITEM_BITMAP( this, j, GetStartPosUi( j ) ); + double pix_size_iu = aCollector->GetMilsToIUfactor() * 1000 / m_ImageBitmap->GetPPI(); + m_ImageBitmap->SetPixelSizeIu( pix_size_iu ); + + WS_DRAW_ITEM_BITMAP* bitmap = new WS_DRAW_ITEM_BITMAP( this, j, GetStartPosUi( j ) ); + bitmap->SetFlags( itemFlags[ j ] ); m_drawItems.push_back( bitmap ); diff --git a/common/page_layout/ws_draw_item.cpp b/common/page_layout/ws_draw_item.cpp index 32eec9c873..faad54cd26 100644 --- a/common/page_layout/ws_draw_item.cpp +++ b/common/page_layout/ws_draw_item.cpp @@ -401,16 +401,7 @@ void WS_DRAW_ITEM_BITMAP::PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint if( !bitmap->m_ImageBitmap ) return; - // We are using here internal unit = 1 mil for historical reason - // the PixelScaleFactor in mils is: - double pix_scale = 1000.0 / bitmap->GetPPI(); - - double ps = bitmap->m_ImageBitmap->GetPixelScaleFactor(); // Store initial value - - bitmap->m_ImageBitmap->SetPixelScaleFactor( pix_scale ); bitmap->m_ImageBitmap->DrawBitmap( aSettings->GetPrintDC(), m_pos + aOffset ); - - bitmap->m_ImageBitmap->SetPixelScaleFactor( ps ); // restore initial value } diff --git a/include/bitmap_base.h b/include/bitmap_base.h index 42ed5755b3..11ff67ee21 100644 --- a/include/bitmap_base.h +++ b/include/bitmap_base.h @@ -52,10 +52,10 @@ class BITMAP_BASE { private: double m_scale; // The scaling factor of the bitmap - // With m_pixelScaleFactor, controls the actual draw size + // With m_pixelSizeIu, controls the actual draw size wxImage* m_image; // the raw image data (png format) wxBitmap* m_bitmap; // the bitmap used to draw/plot image - double m_pixelScaleFactor; // The scaling factor of the bitmap + double m_pixelSizeIu; // The scaling factor of the bitmap // to convert the bitmap size (in pixels) // to internal KiCad units // Usually does not change @@ -77,8 +77,8 @@ public: /* * Accessors: */ - double GetPixelScaleFactor() const { return m_pixelScaleFactor; } - void SetPixelScaleFactor( double aSF ) { m_pixelScaleFactor = aSF; } + double GetPixelSizeIu() const { return m_pixelSizeIu; } + void SetPixelSizeIu( double aPixSize ) { m_pixelSizeIu = aPixSize; } wxImage* GetImageData() { return m_image; } const wxImage* GetImageData() const { return m_image; } @@ -114,8 +114,8 @@ public: /** * Function GetScalingFactor * @return the scaling factor from pixel size to actual draw size - * this scaling factor depends on m_pixelScaleFactor and m_scale - * m_pixelScaleFactor gives the scaling factor between a pixel size and + * this scaling factor depends on m_pixelSizeIu and m_scale + * m_pixelSizeIu gives the scaling factor between a pixel size and * the internal schematic units * m_scale is an user dependant value, and gives the "zoom" value * m_scale = 1.0 = original size of bitmap. @@ -124,7 +124,7 @@ public: */ double GetScalingFactor() const { - return m_pixelScaleFactor * m_scale; + return m_pixelSizeIu * m_scale; } diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index d544c0043f..617cee5f04 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -362,11 +362,11 @@ public: * Prints the page layout with the frame and the basic inscriptions. * * @param aScreen screen to draw - * @param aScale The mils to Iu conversion factor. + * @param aMils2Iu The mils to Iu conversion factor. * @param aFilename The filename to display in basic inscriptions. * @param aSheetLayer The layer displayed from pcbnew. */ - void PrintWorkSheet( RENDER_SETTINGS* aSettings, BASE_SCREEN* aScreen, double aScale, + void PrintWorkSheet( RENDER_SETTINGS* aSettings, BASE_SCREEN* aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer = wxEmptyString ); void DisplayToolMsg( const wxString& msg ) override; diff --git a/include/page_layout/ws_draw_item.h b/include/page_layout/ws_draw_item.h index b3301111b6..34c6b21c86 100644 --- a/include/page_layout/ws_draw_item.h +++ b/include/page_layout/ws_draw_item.h @@ -440,11 +440,16 @@ public: /** * Set the scalar to convert pages units (mils) to draw/plot units */ - void SetMilsToIUfactor( double aScale ) + void SetMilsToIUfactor( double aMils2Iu ) { - m_milsToIu = aScale; + m_milsToIu = aMils2Iu; } + /** + * Get the scalar to convert pages units (mils) to draw/plot units + */ + double GetMilsToIUfactor() { return m_milsToIu; } + /** * Set the value of the sheet number. */ @@ -512,7 +517,7 @@ public: * * Before calling this function, some parameters should be initialized by calling: * SetPenSize( aPenWidth ); - * SetMilsToIUfactor( aScalar ); + * SetMilsToIUfactor( aMils2Iu ); * SetSheetNumber( aSheetNumber ); * SetSheetCount( aSheetCount ); * SetFileName( aFileName ); diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp index 7536536c6a..ec22b9c664 100644 --- a/pagelayout_editor/dialogs/dialogs_for_printing.cpp +++ b/pagelayout_editor/dialogs/dialogs_for_printing.cpp @@ -202,8 +202,8 @@ void PLEDITOR_PRINTOUT::PrintPage( int aPageNum ) continue; WS_DATA_ITEM_BITMAP* itemBM = static_cast( dataItem ); - itemBM->m_ImageBitmap->SetPixelScaleFactor( IU_PER_MILS * 1000 / - itemBM->m_ImageBitmap->GetPPI() ); + itemBM->m_ImageBitmap->SetPixelSizeIu( IU_PER_MILS * 1000 / + itemBM->m_ImageBitmap->GetPPI() ); } m_parent->PrintWorkSheet( &renderSettings, screen, IU_PER_MILS, wxEmptyString ); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index b0d36033e3..2b4afece5a 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -782,7 +782,7 @@ void PL_EDITOR_FRAME::PrintPage( RENDER_SETTINGS* aSettings ) continue; WS_DATA_ITEM_BITMAP* itemBM = static_cast( dataItem ); - itemBM->m_ImageBitmap->SetPixelScaleFactor( IU_PER_MILS * 1000 + itemBM->m_ImageBitmap->SetPixelSizeIu( IU_PER_MILS * 1000 / itemBM->m_ImageBitmap->GetPPI() ); } @@ -870,7 +870,7 @@ WS_DATA_ITEM* PL_EDITOR_FRAME::AddPageLayoutItem( int aType ) } // Set the scale factor for pl_editor (it is set for eeschema by default) - image->SetPixelScaleFactor( 25400.0 / image->GetPPI() ); + image->SetPixelSizeIu( 25400.0 / image->GetPPI() ); item = new WS_DATA_ITEM_BITMAP( image ); } break;