From 7ad2f37391e3e0debb7b96cd7164961d118f44c1 Mon Sep 17 00:00:00 2001 From: Ian Roth Date: Sat, 10 Sep 2016 14:06:31 -0400 Subject: [PATCH] Add %L formatter to worksheets to print layer name. --- common/worksheet.cpp | 16 ++++++++++++---- gerbview/printout_control.cpp | 6 +++--- include/draw_frame.h | 4 +++- include/worksheet.h | 6 ++++-- include/worksheet_shape_builder.h | 12 +++++++++++- pcbnew/printout_controler.cpp | 16 ++++++++++++---- pcbnew/printout_controler.h | 4 ++-- 7 files changed, 47 insertions(+), 17 deletions(-) diff --git a/common/worksheet.cpp b/common/worksheet.cpp index 3e9255d9cd..367fa98bd6 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -8,7 +8,7 @@ /* * 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 @@ -53,7 +53,8 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox, TITLE_BLOCK& aTitleBlock, int aSheetCount, int aSheetNumber, 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; @@ -63,6 +64,7 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox, drawList.SetSheetCount( aSheetCount ); drawList.SetFileName( aFileName ); drawList.SetSheetName( aFullSheetName ); + drawList.SetSheetLayer( aSheetLayer ); drawList.BuildWorkSheetGraphicList( aPageInfo, 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, - double aScalar, const wxString &aFilename ) + double aScalar, const wxString &aFilename, + const wxString &aSheetLayer ) { if( !m_showBorderAndTitleBlock ) return; @@ -104,7 +107,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, GetScreenDesc(), aFilename, t_block, aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, - aLineWidth, aScalar, color, color ); + aLineWidth, aScalar, color, color, aSheetLayer ); if( aScreen->m_IsPrinting && origin.y > 0 ) { @@ -136,6 +139,7 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) * %R = revision * %S = sheet number * %N = number of sheets + * %L = layer name * %Cx = comment (x = 0 to 9 to identify the comment) * %F = filename * %P = sheet path (sheet full name) @@ -192,6 +196,10 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) } break; + case 'L': + msg += *m_sheetLayer; + break; + case 'P': msg += *m_sheetFullName; break; diff --git a/gerbview/printout_control.cpp b/gerbview/printout_control.cpp index 9098cdd48d..cc0da57224 100644 --- a/gerbview/printout_control.cpp +++ b/gerbview/printout_control.cpp @@ -2,7 +2,7 @@ * 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) 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 * 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 // because handling negative objects when using only one page is tricky m_PrintParams.m_Flags = aPage; - DrawPage(); + DrawPage( wxEmptyString ); 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; double userscale; diff --git a/include/draw_frame.h b/include/draw_frame.h index 1913c52f7a..2a65c7dd60 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -593,9 +593,11 @@ public: * @param aLineWidth The pen width to use to draw the layout. * @param aScale The mils to Iu conversion factor. * @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, - double aScale, const wxString &aFilename ); + double aScale, const wxString &aFilename, + const wxString &aSheetLayer = wxEmptyString ); void DisplayToolMsg( const wxString& msg ); virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0; diff --git a/include/worksheet.h b/include/worksheet.h index 985f77d805..cb2a667edd 100644 --- a/include/worksheet.h +++ b/include/worksheet.h @@ -1,7 +1,7 @@ /* * 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 * 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 aColor The color for drawing. * @param aAltColor The color for items which need to be "hightlighted". + * @param aSheetLayer The layer from pcbnew. * * Parameters used in aPageInfo * - the size of the page layout. @@ -62,7 +63,8 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox, TITLE_BLOCK& aTitleBlock, int aSheetCount, int aSheetNumber, 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_ diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index 6ff408eded..69b200088a 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -2,7 +2,7 @@ * 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) 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 * modify it under the terms of the GNU General Public License @@ -384,6 +384,7 @@ protected: const wxString* m_paperFormat; // for basic inscriptions wxString m_fileName; // for basic inscriptions const wxString* m_sheetFullName; // for basic inscriptions + const wxString* m_sheetLayer; // for basic inscriptions public: @@ -423,6 +424,15 @@ public: 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 * Set the default pen size to draw/plot lines and texts * @param aPenSize the thickness of lines diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 7ad346f81d..aec6957303 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -2,7 +2,7 @@ * 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) 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 * 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 ) { LSET lset = m_PrintParams.m_PrintMaskLayer; + wxString layer; + LAYER_ID extractLayer; // compute layer mask from page number if we want 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() ) 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 if( m_PrintParams.m_Flags == 1 ) m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts ); - DrawPage(); + DrawPage( layer ); 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; double userscale; @@ -279,7 +287,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() if( m_PrintParams.PrintBorderAndTitleBlock() ) m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, - IU_PER_MILS, titleblockFilename ); + IU_PER_MILS, titleblockFilename, layer ); if( printMirror ) { diff --git a/pcbnew/printout_controler.h b/pcbnew/printout_controler.h index a9cd6c2ece..8527bcf951 100644 --- a/pcbnew/printout_controler.h +++ b/pcbnew/printout_controler.h @@ -2,7 +2,7 @@ * 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) 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 * 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 DrawPage(); + void DrawPage( wxString layer ); }; #endif // PRINTOUT_CONTROLLER_H