Handle printout settings: line width, color/mono, mirror

This commit is contained in:
Maciej Suminski 2018-09-28 13:15:17 +02:00
parent 47d0eaa2c6
commit 347e21daaa
5 changed files with 51 additions and 0 deletions

View File

@ -104,7 +104,25 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
view->SetScaleLimits( 10e9, 0.0001 );
view->SetScale( 1.0 );
// Set the color scheme
auto srcSettings = m_view->GetPainter()->GetSettings();
auto dstSettings = view->GetPainter()->GetSettings();
if( m_PrintParams.m_Print_Black_and_White )
{
for( int i = 0; i < LAYER_ID_COUNT; ++i )
dstSettings->SetLayerColor( i, COLOR4D::BLACK );
}
else // color enabled
{
for( int i = 0; i < LAYER_ID_COUNT; ++i )
dstSettings->SetLayerColor( i, srcSettings->GetLayerColor( i ) );
}
setupViewLayers( view, m_PrintParams.m_PrintMaskLayer );
setupPainter( painter );
BOX2I bBox; // determine printout bounding box
@ -137,6 +155,10 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
}
if( m_PrintParams.m_PrintMirror )
gal->SetFlip( true, false );
// TODO fix 'Preview' button
VECTOR2D nps( GetLogicalPageRect().width, GetLogicalPageRect().height );
@ -162,3 +184,9 @@ void BOARD_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView,
aView->SetLayerTarget( i, KIGFX::TARGET_NONCACHED );
}
}
void BOARD_PRINTOUT::setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter )
{
aPainter->GetSettings()->SetOutlineWidth( m_PrintParams.m_PenDefaultSize );
}

View File

@ -125,6 +125,14 @@ CAIRO_PRINT_GAL::CAIRO_PRINT_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions,
}
void CAIRO_PRINT_GAL::SetLineWidth( float aLineWidth )
{
storePath();
lineWidth = aLineWidth;
cairo_set_line_width( currentContext, aLineWidth );
}
void CAIRO_PRINT_GAL::ComputeWorldScreenMatrix()
{
// worldUnitLength = inch per integer

View File

@ -128,6 +128,9 @@ protected:
///> Enables layers visibility for a printout
virtual void setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView, const LSET& aLayerSet );
///> Configures PAINTER object for a printout
virtual void setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter );
///> Returns bounding box of the printed objects (excluding worksheet frame)
virtual EDA_RECT getBoundingBox() = 0;

View File

@ -82,6 +82,8 @@ public:
CAIRO_PRINT_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions,
std::unique_ptr<CAIRO_PRINT_CTX> aContext );
void SetLineWidth( float aLineWidth ) override;
void ComputeWorldScreenMatrix() override;
GAL* GetGAL() override

View File

@ -234,6 +234,16 @@ public:
return false;
}
/**
* Set line width used for drawing outlines.
*
* @param aWidth is the new width.
*/
void SetOutlineWidth( float aWidth )
{
m_outlineWidth = aWidth;
}
protected:
/**
* Function update