Commit 32c8fdad authored by Maciej Suminski's avatar Maciej Suminski

Fix for printing non-consecutive layers or starting with layer > 1 in gerbview.

parent 681090b8
...@@ -106,15 +106,15 @@ public: ...@@ -106,15 +106,15 @@ public:
* @param aPrintBlackAndWhite = true to force black and white insdeat of color * @param aPrintBlackAndWhite = true to force black and white insdeat of color
* useful only to print/plot gebview layers * useful only to print/plot gebview layers
*/ */
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
GR_DRAWMODE aDrawMode, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, const wxPoint& aOffset,
bool aPrintBlackAndWhite = false ); bool aPrintBlackAndWhite = false );
/** /**
* Function SetPrintableLayers * Function SetPrintableLayers
* changes the list of printable layers * changes the list of printable layers
* @param aLayerMask = The new bit-mask of printable layers * @param aLayerMask = The new bit-mask of printable layers
*/ */
void SetPrintableLayers( const std::bitset <GERBER_DRAWLAYERS_COUNT>& aLayerMask ) void SetPrintableLayers( const std::bitset <GERBER_DRAWLAYERS_COUNT>& aLayerMask )
{ {
m_printLayersMask = aLayerMask; m_printLayersMask = aLayerMask;
} }
......
...@@ -78,8 +78,8 @@ private: ...@@ -78,8 +78,8 @@ private:
void OnScaleSelectionClick( wxCommandEvent& event ); void OnScaleSelectionClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event ) { Close(); } void OnButtonCancelClick( wxCommandEvent& event ) { Close(); }
void SetPrintParameters( ); void SetPrintParameters();
void InitValues( ); void InitValues();
public: public:
bool IsMirrored() { return m_Print_Mirror->IsChecked(); } bool IsMirrored() { return m_Print_Mirror->IsChecked(); }
...@@ -151,8 +151,8 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) ...@@ -151,8 +151,8 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
s_pageSetupData = new wxPageSetupDialogData; s_pageSetupData = new wxPageSetupDialogData;
// Set initial page margins. // Set initial page margins.
// Margins are already set in Gerbview, so we can use 0 // Margins are already set in Gerbview, so we can use 0
s_pageSetupData->SetMarginTopLeft(wxPoint(0, 0)); s_pageSetupData->SetMarginTopLeft( wxPoint( 0, 0 ) );
s_pageSetupData->SetMarginBottomRight(wxPoint(0, 0)); s_pageSetupData->SetMarginBottomRight( wxPoint( 0, 0 ) );
} }
s_Parameters.m_PageSetupData = s_pageSetupData; s_Parameters.m_PageSetupData = s_pageSetupData;
...@@ -175,7 +175,6 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) ...@@ -175,7 +175,6 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
wxGROW | wxLEFT | wxRIGHT | wxTOP ); wxGROW | wxLEFT | wxRIGHT | wxTOP );
} }
// Read the scale adjust option // Read the scale adjust option
int scale_idx = 4; // default selected scale = ScaleList[4] = 1.000 int scale_idx = 4; // default selected scale = ScaleList[4] = 1.000
...@@ -184,8 +183,8 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) ...@@ -184,8 +183,8 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
m_Config->Read( OPTKEY_PRINT_X_FINESCALE_ADJ, &s_Parameters.m_XScaleAdjust ); m_Config->Read( OPTKEY_PRINT_X_FINESCALE_ADJ, &s_Parameters.m_XScaleAdjust );
m_Config->Read( OPTKEY_PRINT_Y_FINESCALE_ADJ, &s_Parameters.m_YScaleAdjust ); m_Config->Read( OPTKEY_PRINT_Y_FINESCALE_ADJ, &s_Parameters.m_YScaleAdjust );
m_Config->Read( OPTKEY_PRINT_SCALE, &scale_idx ); m_Config->Read( OPTKEY_PRINT_SCALE, &scale_idx );
m_Config->Read( OPTKEY_PRINT_PAGE_FRAME, &s_Parameters.m_Print_Sheet_Ref, 1); m_Config->Read( OPTKEY_PRINT_PAGE_FRAME, &s_Parameters.m_Print_Sheet_Ref, 1 );
m_Config->Read( OPTKEY_PRINT_MONOCHROME_MODE, &s_Parameters.m_Print_Black_and_White, 1); m_Config->Read( OPTKEY_PRINT_MONOCHROME_MODE, &s_Parameters.m_Print_Black_and_White, 1 );
// Test for a reasonnable scale value. Set to 1 if problem // Test for a reasonnable scale value. Set to 1 if problem
if( s_Parameters.m_XScaleAdjust < MIN_SCALE || if( s_Parameters.m_XScaleAdjust < MIN_SCALE ||
...@@ -207,8 +206,8 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) ...@@ -207,8 +206,8 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
m_ScaleOption->SetSelection( scale_idx ); m_ScaleOption->SetSelection( scale_idx );
scale_idx = m_ScaleOption->GetSelection(); scale_idx = m_ScaleOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[scale_idx]; s_Parameters.m_PrintScale = s_ScaleList[scale_idx];
m_Print_Mirror->SetValue(s_Parameters.m_PrintMirror); m_Print_Mirror->SetValue( s_Parameters.m_PrintMirror );
if( s_Parameters.m_Print_Black_and_White ) if( s_Parameters.m_Print_Black_and_White )
...@@ -230,6 +229,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) ...@@ -230,6 +229,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
m_FineAdjustYscaleOpt->Enable(enable); m_FineAdjustYscaleOpt->Enable(enable);
} }
int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection() int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection()
{ {
int page_count = 0; int page_count = 0;
...@@ -275,7 +275,7 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event ) ...@@ -275,7 +275,7 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
} }
void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( ) void DIALOG_PRINT_USING_PRINTER::SetPrintParameters()
{ {
s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue(); s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue();
s_Parameters.m_Print_Black_and_White = s_Parameters.m_Print_Black_and_White =
...@@ -288,7 +288,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( ) ...@@ -288,7 +288,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
SetLayerSetFromListSelection(); SetLayerSetFromListSelection();
int idx = m_ScaleOption->GetSelection(); int idx = m_ScaleOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[idx]; s_Parameters.m_PrintScale = s_ScaleList[idx];
if( m_FineAdjustXscaleOpt ) if( m_FineAdjustXscaleOpt )
{ {
...@@ -331,7 +331,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) ...@@ -331,7 +331,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event )
bool DIALOG_PRINT_USING_PRINTER::PreparePrintPrms() bool DIALOG_PRINT_USING_PRINTER::PreparePrintPrms()
{ {
SetPrintParameters( ); SetPrintParameters();
// If no layer selected, we have no plot. prompt user if it happens // If no layer selected, we have no plot. prompt user if it happens
// because he could think there is a bug in Pcbnew: // because he could think there is a bug in Pcbnew:
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer, void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
bool aPrintMirrorMode, void* aData ) bool aPrintMirrorMode, void* aData )
{ {
wxCHECK_RET( aData != NULL, wxT( "aDate cannot be NULL." ) ); wxCHECK_RET( aData != NULL, wxT( "aData cannot be NULL." ) );
// Save current draw options, because print mode has specific options: // Save current draw options, because print mode has specific options:
GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions; GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions;
...@@ -59,15 +59,28 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer, ...@@ -59,15 +59,28 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
m_DisplayOptions.m_DisplayDCodes = false; m_DisplayOptions.m_DisplayDCodes = false;
m_DisplayOptions.m_IsPrinting = true; m_DisplayOptions.m_IsPrinting = true;
PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*)aData; PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*) aData;
// Find the layer to be printed
int page = printParameters->m_Flags; // contains the page number (not necessarily layer number)
int layer = 0;
// Find the layer number for the printed page (search through the mask and count bits)
while( page > 0 )
{
if( printLayersMask[layer++] )
--page;
}
--layer;
std::bitset <GERBER_DRAWLAYERS_COUNT> printCurrLayerMask; std::bitset <GERBER_DRAWLAYERS_COUNT> printCurrLayerMask;
printCurrLayerMask.reset(); printCurrLayerMask.reset();
printCurrLayerMask.set(printParameters->m_Flags); // m_Flags contains the draw layer number printCurrLayerMask.set( layer );
GetGerberLayout()->SetPrintableLayers( printCurrLayerMask ); GetGerberLayout()->SetPrintableLayers( printCurrLayerMask );
m_canvas->SetPrintMirrored( aPrintMirrorMode ); m_canvas->SetPrintMirrored( aPrintMirrorMode );
bool printBlackAndWhite = printParameters->m_Print_Black_and_White; bool printBlackAndWhite = printParameters->m_Print_Black_and_White;
GetGerberLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE, GetGerberLayout()->Draw( m_canvas, aDC, (GR_DRAWMODE) 0,
wxPoint( 0, 0 ), printBlackAndWhite ); wxPoint( 0, 0 ), printBlackAndWhite );
m_canvas->SetPrintMirrored( false ); m_canvas->SetPrintMirrored( false );
......
...@@ -81,7 +81,7 @@ bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage ) ...@@ -81,7 +81,7 @@ bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
{ {
// in gerbview, draw layers are always printed on separate pages // in gerbview, draw layers are always printed on separate pages
// because handling negative objects when using only one page is tricky // because handling negative objects when using only one page is tricky
m_PrintParams.m_Flags = aPage-1; // = gerber draw layer id m_PrintParams.m_Flags = aPage;
DrawPage(); DrawPage();
return true; return true;
...@@ -233,12 +233,12 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -233,12 +233,12 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
if( m_PrintParams.PrintBorderAndTitleBlock() ) if( m_PrintParams.PrintBorderAndTitleBlock() )
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
IU_PER_MILS, titleblockFilename ); IU_PER_MILS, titleblockFilename );
if( printMirror ) if( printMirror )
{ {
// To plot mirror, we reverse the x axis, and modify the plot x origin // To plot mirror, we reverse the x axis, and modify the plot x origin
dc->SetAxisOrientation( false, false); dc->SetAxisOrientation( false, false );
/* Plot offset x is moved by the x plot area size in order to have /* Plot offset x is moved by the x plot area size in order to have
* the old draw area in the new draw area, because the draw origin has not moved * the old draw area in the new draw area, because the draw origin has not moved
...@@ -248,7 +248,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -248,7 +248,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
x_dc_offset = KiROUND( x_dc_offset * userscale ); x_dc_offset = KiROUND( x_dc_offset * userscale );
dc->SetDeviceOrigin( x_dc_offset, 0 ); dc->SetDeviceOrigin( x_dc_offset, 0 );
panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ), panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE / 2, -MAX_VALUE / 2 ),
panel->GetClipBox()->GetSize() ) ); panel->GetClipBox()->GetSize() ) );
} }
...@@ -261,8 +261,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -261,8 +261,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
// B&W mode is handled in print page function // B&W mode is handled in print page function
GRForceBlackPen( false ); GRForceBlackPen( false );
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams );
&m_PrintParams );
m_Parent->SetDrawBgColor( bg_color ); m_Parent->SetDrawBgColor( bg_color );
screen->m_IsPrinting = false; screen->m_IsPrinting = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment