Fixed scale in Gerbview printouts

This commit is contained in:
Maciej Suminski 2018-09-29 12:13:06 +02:00
parent 8cb464b725
commit 92c5cb288e
8 changed files with 25 additions and 7 deletions

View File

@ -164,6 +164,7 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
// TODO fix 'Preview' button
VECTOR2D nps( GetLogicalPageRect().width, GetLogicalPageRect().height );
setupGal( gal );
galPrint->SetNativePaperSize( VECTOR2D( nps.x / dc->GetPPI().x, nps.y / dc->GetPPI().y ),
printCtx->HasNativeLandscapeRotation() );
gal->SetLookAtPoint( bBox.Centre() );

View File

@ -135,11 +135,8 @@ void CAIRO_PRINT_GAL::SetLineWidth( float aLineWidth )
void CAIRO_PRINT_GAL::ComputeWorldScreenMatrix()
{
// worldUnitLength = inch per integer
worldUnitLength = 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */;
worldScale = screenDPI * worldUnitLength * zoomFactor;
const auto paperSizeIU = VECTOR2D( m_nativePaperSize.y, m_nativePaperSize.x ) /* inches */ * 0.0254 * 1e9 /* 1 inch in nm */;
const auto paperSizeIU = VECTOR2D( m_nativePaperSize.y, m_nativePaperSize.x ) /* inches */ / worldUnitLength; /* 1 inch in IU */
const auto paperSizeIUTransposed = VECTOR2D( paperSizeIU.y, paperSizeIU.x );
MATRIX3x3D scale, translation, flip, rotate, lookat;
@ -152,18 +149,18 @@ void CAIRO_PRINT_GAL::ComputeWorldScreenMatrix()
if( m_hasNativeLandscapeRotation )
{
translation.SetTranslation( 0.5 / GetZoomFactor() * paperSizeIUTransposed );
translation.SetTranslation( 0.5 / zoomFactor * paperSizeIUTransposed );
}
else
{
if( isLandscape() )
{
translation.SetTranslation( 0.5 / GetZoomFactor() * paperSizeIU );
translation.SetTranslation( 0.5 / zoomFactor * paperSizeIU );
rotate.SetRotation( 90.0 * M_PI / 180.0 );
}
else
{
translation.SetTranslation( 0.5 / GetZoomFactor() * paperSizeIUTransposed );
translation.SetTranslation( 0.5 / zoomFactor * paperSizeIUTransposed );
}
}

View File

@ -226,6 +226,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
m_ModeColorOption->SetSelection( 0 );
s_Parameters.m_PenDefaultSize = 0;
s_Parameters.m_Print_Sheet_Ref = false;
// Create scale adjust option
msg.Printf( wxT( "%f" ), s_Parameters.m_XScaleAdjust );

View File

@ -98,6 +98,12 @@ void GERBVIEW_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aVi
}
void GERBVIEW_PRINTOUT::setupGal( KIGFX::GAL* aGal )
{
aGal->SetWorldUnitLength( 10e-9 /* 10 nm */ / 0.0254 /* 1 inch in meters */ );
}
EDA_RECT GERBVIEW_PRINTOUT::getBoundingBox()
{
return m_layout->ComputeBoundingBox();

View File

@ -35,6 +35,8 @@ public:
protected:
void setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView, const LSET& aLayerSet ) override;
void setupGal( KIGFX::GAL* aGal ) override;
EDA_RECT getBoundingBox() override;
std::unique_ptr<KIGFX::PAINTER> getPainter( KIGFX::GAL* aGal ) override;

View File

@ -131,6 +131,9 @@ protected:
///> Configures PAINTER object for a printout
virtual void setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter );
///> Configures GAL object for a printout
virtual void setupGal( KIGFX::GAL* aGal ) {}
///> Returns bounding box of the printed objects (excluding worksheet frame)
virtual EDA_RECT getBoundingBox() = 0;

View File

@ -159,6 +159,12 @@ void PCBNEW_PRINTOUT::setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPain
}
void PCBNEW_PRINTOUT::setupGal( KIGFX::GAL* aGal )
{
aGal->SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ );
}
EDA_RECT PCBNEW_PRINTOUT::getBoundingBox()
{
return m_board->ComputeBoundingBox();

View File

@ -38,6 +38,8 @@ protected:
void setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter ) override;
void setupGal( KIGFX::GAL* aGal ) override;
EDA_RECT getBoundingBox() override;
std::unique_ptr<KIGFX::PAINTER> getPainter( KIGFX::GAL* aGal ) override;