Add %L formatter to worksheets to print layer name.

This commit is contained in:
Ian Roth 2016-09-10 14:06:31 -04:00 committed by Chris Pavlina
parent 7edb6c2d13
commit 7ad2f37391
7 changed files with 47 additions and 17 deletions

View File

@ -8,7 +8,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -53,7 +53,8 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
TITLE_BLOCK& aTitleBlock, TITLE_BLOCK& aTitleBlock,
int aSheetCount, int aSheetNumber, int aSheetCount, int aSheetNumber,
int aPenWidth, double aScalar, int aPenWidth, double aScalar,
EDA_COLOR_T aColor, EDA_COLOR_T aAltColor ) EDA_COLOR_T aColor, EDA_COLOR_T aAltColor,
const wxString& aSheetLayer )
{ {
WS_DRAW_ITEM_LIST drawList; WS_DRAW_ITEM_LIST drawList;
@ -63,6 +64,7 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
drawList.SetSheetCount( aSheetCount ); drawList.SetSheetCount( aSheetCount );
drawList.SetFileName( aFileName ); drawList.SetFileName( aFileName );
drawList.SetSheetName( aFullSheetName ); drawList.SetSheetName( aFullSheetName );
drawList.SetSheetLayer( aSheetLayer );
drawList.BuildWorkSheetGraphicList( aPageInfo, drawList.BuildWorkSheetGraphicList( aPageInfo,
aTitleBlock, aColor, aAltColor ); aTitleBlock, aColor, aAltColor );
@ -73,7 +75,8 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScalar, const wxString &aFilename ) double aScalar, const wxString &aFilename,
const wxString &aSheetLayer )
{ {
if( !m_showBorderAndTitleBlock ) if( !m_showBorderAndTitleBlock )
return; return;
@ -104,7 +107,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo,
GetScreenDesc(), aFilename, t_block, GetScreenDesc(), aFilename, t_block,
aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber,
aLineWidth, aScalar, color, color ); aLineWidth, aScalar, color, color, aSheetLayer );
if( aScreen->m_IsPrinting && origin.y > 0 ) if( aScreen->m_IsPrinting && origin.y > 0 )
{ {
@ -136,6 +139,7 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
* %R = revision * %R = revision
* %S = sheet number * %S = sheet number
* %N = number of sheets * %N = number of sheets
* %L = layer name
* %Cx = comment (x = 0 to 9 to identify the comment) * %Cx = comment (x = 0 to 9 to identify the comment)
* %F = filename * %F = filename
* %P = sheet path (sheet full name) * %P = sheet path (sheet full name)
@ -192,6 +196,10 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
} }
break; break;
case 'L':
msg += *m_sheetLayer;
break;
case 'P': case 'P':
msg += *m_sheetFullName; msg += *m_sheetFullName;
break; break;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -77,7 +77,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; m_PrintParams.m_Flags = aPage;
DrawPage(); DrawPage( wxEmptyString );
return true; return true;
} }
@ -99,7 +99,7 @@ void BOARD_PRINTOUT_CONTROLLER::GetPageInfo( int* minPage, int* maxPage,
} }
void BOARD_PRINTOUT_CONTROLLER::DrawPage() void BOARD_PRINTOUT_CONTROLLER::DrawPage( wxString layer = wxEmptyString )
{ {
wxPoint offset; wxPoint offset;
double userscale; double userscale;

View File

@ -593,9 +593,11 @@ public:
* @param aLineWidth The pen width to use to draw the layout. * @param aLineWidth The pen width to use to draw the layout.
* @param aScale The mils to Iu conversion factor. * @param aScale The mils to Iu conversion factor.
* @param aFilename The filename to display in basic inscriptions. * @param aFilename The filename to display in basic inscriptions.
* @param aSheetLayer The layer displayed from pcbnew.
*/ */
void DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, void DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScale, const wxString &aFilename ); double aScale, const wxString &aFilename,
const wxString &aSheetLayer = wxEmptyString );
void DisplayToolMsg( const wxString& msg ); void DisplayToolMsg( const wxString& msg );
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0; virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0;

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -49,6 +49,7 @@ class TITLE_BLOCK;
* @param aScalar the scale factor to convert from mils to internal units. * @param aScalar the scale factor to convert from mils to internal units.
* @param aColor The color for drawing. * @param aColor The color for drawing.
* @param aAltColor The color for items which need to be "hightlighted". * @param aAltColor The color for items which need to be "hightlighted".
* @param aSheetLayer The layer from pcbnew.
* *
* Parameters used in aPageInfo * Parameters used in aPageInfo
* - the size of the page layout. * - the size of the page layout.
@ -62,7 +63,8 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
TITLE_BLOCK& aTitleBlock, TITLE_BLOCK& aTitleBlock,
int aSheetCount, int aSheetNumber, int aSheetCount, int aSheetNumber,
int aPenWidth, double aScalar, int aPenWidth, double aScalar,
EDA_COLOR_T aColor, EDA_COLOR_T aAltColor ); EDA_COLOR_T aColor, EDA_COLOR_T aAltColor,
const wxString& aSheetLayer = wxEmptyString );
#endif // WORKSHEET_H_ #endif // WORKSHEET_H_

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -384,6 +384,7 @@ protected:
const wxString* m_paperFormat; // for basic inscriptions const wxString* m_paperFormat; // for basic inscriptions
wxString m_fileName; // for basic inscriptions wxString m_fileName; // for basic inscriptions
const wxString* m_sheetFullName; // for basic inscriptions const wxString* m_sheetFullName; // for basic inscriptions
const wxString* m_sheetLayer; // for basic inscriptions
public: public:
@ -423,6 +424,15 @@ public:
m_sheetFullName = &aSheetName; m_sheetFullName = &aSheetName;
} }
/**
* Set the sheet layer to draw/plot
* @param aSheetLayer = the text to draw/plot by the "sheetlayer" format
*/
void SetSheetLayer( const wxString & aSheetLayer )
{
m_sheetLayer = &aSheetLayer;
}
/** Function SetPenSize /** Function SetPenSize
* Set the default pen size to draw/plot lines and texts * Set the default pen size to draw/plot lines and texts
* @param aPenSize the thickness of lines * @param aPenSize the thickness of lines

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -84,6 +84,8 @@ BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aP
bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage ) bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
{ {
LSET lset = m_PrintParams.m_PrintMaskLayer; LSET lset = m_PrintParams.m_PrintMaskLayer;
wxString layer;
LAYER_ID extractLayer;
// compute layer mask from page number if we want one page per layer // compute layer mask from page number if we want one page per layer
if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer
@ -101,11 +103,17 @@ bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
if( !m_PrintParams.m_PrintMaskLayer.any() ) if( !m_PrintParams.m_PrintMaskLayer.any() )
return false; return false;
extractLayer = m_PrintParams.m_PrintMaskLayer.ExtractLayer();
if( extractLayer == UNDEFINED_LAYER )
layer = _( "Multiple Layers" );
else
layer = LSET::Name( extractLayer );
// In Pcbnew we can want the layer EDGE always printed // In Pcbnew we can want the layer EDGE always printed
if( m_PrintParams.m_Flags == 1 ) if( m_PrintParams.m_Flags == 1 )
m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts ); m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts );
DrawPage(); DrawPage( layer );
m_PrintParams.m_PrintMaskLayer = lset; m_PrintParams.m_PrintMaskLayer = lset;
@ -129,7 +137,7 @@ void BOARD_PRINTOUT_CONTROLLER::GetPageInfo( int* minPage, int* maxPage,
} }
void BOARD_PRINTOUT_CONTROLLER::DrawPage() void BOARD_PRINTOUT_CONTROLLER::DrawPage( wxString layer = wxEmptyString )
{ {
wxPoint offset; wxPoint offset;
double userscale; double userscale;
@ -279,7 +287,7 @@ 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, layer );
if( printMirror ) if( printMirror )
{ {

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -123,7 +123,7 @@ public:
void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ); void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
void DrawPage(); void DrawPage( wxString layer );
}; };
#endif // PRINTOUT_CONTROLLER_H #endif // PRINTOUT_CONTROLLER_H