From 7f34586c7e406e121956e1866f0645d1378ef3f3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 20 Sep 2022 15:25:03 +0100 Subject: [PATCH] Allow text variable resolution through properties in drawing sheet text. Fixes https://gitlab.com/kicad/code/kicad/issues/12473 --- common/dialogs/dialog_page_settings.cpp | 4 +- common/drawing_sheet/ds_painter.cpp | 12 +++-- common/drawing_sheet/ds_proxy_view_item.cpp | 13 +++-- common/eda_draw_frame.cpp | 9 ++-- common/plotters/common_plot_functions.cpp | 7 +-- eeschema/dialogs/dialog_plot_schematic.cpp | 40 +++++++-------- .../dialogs/dialog_print_using_printer.cpp | 4 +- .../dialogs/panel_eeschema_color_settings.cpp | 3 +- eeschema/sch_edit_frame.cpp | 3 +- eeschema/sch_view.cpp | 3 +- eeschema/schematic.h | 13 +++-- gerbview/gerbview_frame.cpp | 5 +- include/drawing_sheet/ds_draw_item.h | 51 +++++++------------ include/drawing_sheet/ds_painter.h | 8 +-- include/drawing_sheet/ds_proxy_view_item.h | 8 ++- include/eda_draw_frame.h | 5 +- include/plotters/plotter.h | 8 +-- .../dialogs/dialogs_for_printing.cpp | 3 +- pagelayout_editor/pl_editor_frame.cpp | 3 +- .../dialogs/panel_pcbnew_color_settings.cpp | 4 +- pcbnew/pcb_edit_frame.cpp | 5 +- pcbnew/plot_board_layers.cpp | 4 +- 22 files changed, 117 insertions(+), 98 deletions(-) diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 633ae70945..70f496b0d9 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -674,8 +674,8 @@ void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample() GRFilledRect( &memDC, VECTOR2I( 0, 0 ), m_layout_size, 0, bgColor, bgColor ); PrintDrawingSheet( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb, - m_screen->GetPageCount(), m_screen->GetPageNumber(), 1, &Prj(), - wxEmptyString, m_screen->GetVirtualPageNumber() == 1 ); + nullptr, m_screen->GetPageCount(), m_screen->GetPageNumber(), 1, + &Prj(), wxEmptyString, m_screen->GetVirtualPageNumber() == 1 ); memDC.SelectObject( wxNullBitmap ); m_PageLayoutExampleBitmap->SetBitmap( *m_pageBitmap ); diff --git a/common/drawing_sheet/ds_painter.cpp b/common/drawing_sheet/ds_painter.cpp index 49bcd77566..72e2c4da00 100644 --- a/common/drawing_sheet/ds_painter.cpp +++ b/common/drawing_sheet/ds_painter.cpp @@ -108,8 +108,8 @@ void DS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars ) } -// returns the full text corresponding to the aTextbase, -// after replacing format symbols by the corresponding value +// Returns the full text corresponding to the aTextbase, after replacing any text variable +// references. wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) { std::function wsResolver = @@ -166,9 +166,15 @@ wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) } else if( m_titleBlock ) { - // no need for tokenUpdated; TextVarResolver() did a full resolve + // no need for tokenUpdated; TITLE_BLOCK::TextVarResolver() does a full + // resolve return m_titleBlock->TextVarResolver( token, m_project ); } + else if( m_properties && m_properties->count( *token ) ) + { + *token = m_properties->at( *token ); + tokenUpdated = true; + } if( tokenUpdated ) { diff --git a/common/drawing_sheet/ds_proxy_view_item.cpp b/common/drawing_sheet/ds_proxy_view_item.cpp index c96d298943..cd59056ef6 100644 --- a/common/drawing_sheet/ds_proxy_view_item.cpp +++ b/common/drawing_sheet/ds_proxy_view_item.cpp @@ -35,7 +35,8 @@ using namespace KIGFX; DS_PROXY_VIEW_ITEM::DS_PROXY_VIEW_ITEM( int aMils2IUscalefactor, const PAGE_INFO* aPageInfo, - const PROJECT* aProject, const TITLE_BLOCK* aTitleBlock ) : + const PROJECT* aProject, const TITLE_BLOCK* aTitleBlock, + const std::map* aProperties ) : EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type m_mils2IUscalefactor( aMils2IUscalefactor ), m_titleBlock( aTitleBlock ), @@ -44,6 +45,7 @@ DS_PROXY_VIEW_ITEM::DS_PROXY_VIEW_ITEM( int aMils2IUscalefactor, const PAGE_INFO m_sheetCount( 1 ), m_isFirstPage( false ), m_project( aProject ), + m_properties( aProperties ), m_colorLayer( LAYER_DRAWINGSHEET ), m_pageBorderColorLayer( LAYER_PAGE_LIMITS ) { @@ -69,7 +71,9 @@ const BOX2I DS_PROXY_VIEW_ITEM::ViewBBox() const } -void DS_PROXY_VIEW_ITEM::buildDrawList( VIEW* aView, DS_DRAW_ITEM_LIST* aDrawList ) const +void DS_PROXY_VIEW_ITEM::buildDrawList( VIEW* aView, + const std::map* aProperties, + DS_DRAW_ITEM_LIST* aDrawList ) const { RENDER_SETTINGS* settings = aView->GetPainter()->GetSettings(); wxString fileName( m_fileName.c_str(), wxConvUTF8 ); @@ -88,6 +92,7 @@ void DS_PROXY_VIEW_ITEM::buildDrawList( VIEW* aView, DS_DRAW_ITEM_LIST* aDrawLis aDrawList->SetSheetPath( sheetPath ); aDrawList->SetSheetLayer( settings->GetLayerName() ); aDrawList->SetProject( m_project ); + aDrawList->SetProperties( aProperties ); aDrawList->BuildDrawItemsList( *m_pageInfo, *m_titleBlock ); } @@ -99,7 +104,7 @@ void DS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const RENDER_SETTINGS* settings = aView->GetPainter()->GetSettings(); DS_DRAW_ITEM_LIST drawList; - buildDrawList( aView, &drawList ); + buildDrawList( aView, m_properties, &drawList ); // Draw the title block normally even if the view is flipped bool flipped = gal->IsFlippedX(); @@ -144,7 +149,7 @@ bool DS_PROXY_VIEW_ITEM::HitTestDrawingSheetItems( VIEW* aView, const VECTOR2I& int accuracy = (int) aView->ToWorld( 5.0 ); // five pixels at current zoom DS_DRAW_ITEM_LIST drawList; - buildDrawList( aView, &drawList ); + buildDrawList( aView, m_properties, &drawList ); for( DS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() ) { diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index db3426bfa9..b2e2ae9d7c 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -957,7 +957,8 @@ static const wxString productName = wxT( "KiCad E.D.A. " ); void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo, const wxString& aFullSheetName, const wxString& aFileName, - const TITLE_BLOCK& aTitleBlock, int aSheetCount, + const TITLE_BLOCK& aTitleBlock, + const std::map* aProperties, int aSheetCount, const wxString& aPageNumber, double aMils2Iu, const PROJECT* aProject, const wxString& aSheetLayer, bool aIsFirstPage ) { @@ -972,6 +973,7 @@ void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPage drawList.SetSheetLayer( aSheetLayer ); drawList.SetProject( aProject ); drawList.SetIsFirstPage( aIsFirstPage ); + drawList.SetProperties( aProperties ); drawList.BuildDrawItemsList( aPageInfo, aTitleBlock ); @@ -981,6 +983,7 @@ void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPage void EDA_DRAW_FRAME::PrintDrawingSheet( const RENDER_SETTINGS* aSettings, BASE_SCREEN* aScreen, + const std::map* aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer ) { @@ -997,8 +1000,8 @@ void EDA_DRAW_FRAME::PrintDrawingSheet( const RENDER_SETTINGS* aSettings, BASE_S } ::PrintDrawingSheet( aSettings, GetPageSettings(), GetScreenDesc(), aFilename, GetTitleBlock(), - aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, &Prj(), - aSheetLayer, aScreen->GetVirtualPageNumber() == 1 ); + aProperties, aScreen->GetPageCount(), aScreen->GetPageNumber(), aMils2Iu, + &Prj(), aSheetLayer, aScreen->GetVirtualPageNumber() == 1 ); if( origin.y > 0 ) { diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 407597b87c..7c76c80420 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -58,9 +58,9 @@ wxString GetDefaultPlotExtension( PLOT_FORMAT aFormat ) void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK& aTitleBlock, - const PAGE_INFO& aPageInfo, const wxString& aSheetNumber, int aSheetCount, - const wxString& aSheetName, const wxString& aSheetPath, - const wxString& aFilename, COLOR4D aColor, + const PAGE_INFO& aPageInfo, const std::map* aProperties, + const wxString& aSheetNumber, int aSheetCount, const wxString& aSheetName, + const wxString& aSheetPath, const wxString& aFilename, COLOR4D aColor, bool aIsFirstPage ) { /* Note: Page sizes values are given in mils @@ -89,6 +89,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL drawList.SetSheetLayer( plotter->RenderSettings()->GetLayerName() ); drawList.SetProject( aProject ); drawList.SetIsFirstPage( aIsFirstPage ); + drawList.SetProperties( aProperties ); drawList.BuildDrawItemsList( aPageInfo, aTitleBlock ); diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index c5dfdf8459..9b8d59a04d 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -576,13 +576,13 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetDXF( const wxString& aFileName, { wxString sheetName = m_parent->GetCurrentSheet().Last()->GetName(); wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable(); + COLOR4D color = plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET ); PlotDrawingSheet( plotter, &m_parent->Prj(), m_parent->GetTitleBlock(), pageInfo, - aScreen->GetPageNumber(), aScreen->GetPageCount(), - sheetName, sheetPath, aScreen->GetFileName(), - plotter->GetColorMode() ? - plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET ) : - COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 ); + aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(), + aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(), + plotter->GetColorMode() ? color : COLOR4D::BLACK, + aScreen->GetVirtualPageNumber() == 1 ); } aScreen->Plot( plotter ); @@ -769,9 +769,9 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetHpgl( const wxString& aFileName, wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable(); PlotDrawingSheet( plotter, &m_parent->Prj(), m_parent->GetTitleBlock(), aPageInfo, - aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath, - aScreen->GetFileName(), COLOR4D::BLACK, - aScreen->GetVirtualPageNumber() == 1 ); + aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(), + aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(), + COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 ); } aScreen->Plot( plotter ); @@ -923,8 +923,8 @@ void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScr wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable(); PlotDrawingSheet( aPlotter, &aScreen->Schematic()->Prj(), m_parent->GetTitleBlock(), - m_parent->GetPageSettings(), aScreen->GetPageNumber(), - aScreen->GetPageCount(), sheetName, sheetPath, + m_parent->GetPageSettings(), aScreen->Schematic()->GetProperties(), + aScreen->GetPageNumber(), aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(), color, aScreen->GetVirtualPageNumber() == 1 ); } @@ -1110,13 +1110,13 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName, { wxString sheetName = m_parent->GetCurrentSheet().Last()->GetName(); wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable(); + COLOR4D color = plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET ); PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(), m_parent->GetTitleBlock(), - aPageInfo, aScreen->GetPageNumber(), aScreen->GetPageCount(), - sheetName, sheetPath, aScreen->GetFileName(), - plotter->GetColorMode() ? - plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET ) : - COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 ); + aPageInfo, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(), + aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(), + plotter->GetColorMode() ? color : COLOR4D::BLACK, + aScreen->GetVirtualPageNumber() == 1 ); } aScreen->Plot( plotter ); @@ -1243,13 +1243,13 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( const wxString& aFileName, { wxString sheetName = m_parent->GetCurrentSheet().Last()->GetName(); wxString sheetPath = m_parent->GetCurrentSheet().PathHumanReadable(); + COLOR4D color = plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET ); PlotDrawingSheet( plotter, &aScreen->Schematic()->Prj(), m_parent->GetTitleBlock(), - pageInfo, aScreen->GetPageNumber(), aScreen->GetPageCount(), - sheetName, sheetPath, aScreen->GetFileName(), - plotter->GetColorMode() ? - plotter->RenderSettings()->GetLayerColor( LAYER_SCHEMATIC_DRAWINGSHEET ) : - COLOR4D::BLACK, aScreen->GetVirtualPageNumber() == 1 ); + pageInfo, aScreen->Schematic()->GetProperties(), aScreen->GetPageNumber(), + aScreen->GetPageCount(), sheetName, sheetPath, aScreen->GetFileName(), + plotter->GetColorMode() ? color : COLOR4D::BLACK, + aScreen->GetVirtualPageNumber() == 1 ); } aScreen->Plot( plotter ); diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 56969e8897..3e70eaf57c 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -501,8 +501,8 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen ) if( printReference ) { - m_parent->PrintDrawingSheet( &renderSettings, aScreen, schIUScale.IU_PER_MILS, aScreen->GetFileName(), - wxEmptyString ); + m_parent->PrintDrawingSheet( &renderSettings, aScreen, aScreen->Schematic()->GetProperties(), + schIUScale.IU_PER_MILS, aScreen->GetFileName(), wxEmptyString ); } renderSettings.SetIsPrinting( true ); diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index a6cd0fe832..9b43d9e2d9 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -250,7 +250,8 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems() m_page->SetHeightMils( 5000 ); m_page->SetWidthMils( 6000 ); - m_drawingSheet = new DS_PROXY_VIEW_ITEM( (int) schIUScale.IU_PER_MILS, m_page, nullptr, m_titleBlock ); + m_drawingSheet = new DS_PROXY_VIEW_ITEM( (int) schIUScale.IU_PER_MILS, m_page, nullptr, + m_titleBlock, nullptr ); m_drawingSheet->SetColorLayer( LAYER_SCHEMATIC_DRAWINGSHEET ); m_drawingSheet->SetPageBorderColorLayer( LAYER_SCHEMATIC_PAGE_LIMITS ); view->Add( m_drawingSheet ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index d818e4789d..48ce1c0fd4 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1276,7 +1276,8 @@ void SCH_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings ) aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY ); GetScreen()->Print( aSettings ); - PrintDrawingSheet( aSettings, GetScreen(), schIUScale.IU_PER_MILS, fileName ); + PrintDrawingSheet( aSettings, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS, + fileName ); } diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 5bae7643c9..7e71504835 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -97,7 +97,8 @@ void SCH_VIEW::DisplaySheet( const SCH_SCREEN *aScreen ) m_drawingSheet.reset( new DS_PROXY_VIEW_ITEM( static_cast( schIUScale.IU_PER_MILS ), &aScreen->GetPageSettings(), &aScreen->Schematic()->Prj(), - &aScreen->GetTitleBlock() ) ); + &aScreen->GetTitleBlock(), + aScreen->Schematic()->GetProperties() ) ); m_drawingSheet->SetPageNumber( TO_UTF8( aScreen->GetPageNumber() ) ); m_drawingSheet->SetSheetCount( aScreen->GetPageCount() ); m_drawingSheet->SetFileName( TO_UTF8( aScreen->GetFileName() ) ); diff --git a/eeschema/schematic.h b/eeschema/schematic.h index e5c3867c3c..52e424554f 100644 --- a/eeschema/schematic.h +++ b/eeschema/schematic.h @@ -72,13 +72,11 @@ public: void Reset(); /// Return a reference to the project this schematic is part of - PROJECT& Prj() const override - { - return *m_project; - } - + PROJECT& Prj() const override { return *m_project; } void SetProject( PROJECT* aPrj ); + const std::map* GetProperties() { return &m_properties; } + /** * Builds and returns an updated schematic hierarchy * TODO: can this be cached? @@ -209,6 +207,11 @@ private: * used for updating global label intersheet references. */ std::map> m_labelToPageRefsMap; + + /** + * Properties for text variable substitution (and perhaps other uses in future). + */ + std::map m_properties; }; #endif diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index d9b3160408..a334fbfe67 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -825,8 +825,9 @@ void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast( GetCanvas() ); // Prepare drawing-sheet template - DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( gerbIUScale.IU_PER_MILS, &GetPageSettings(), - &Prj(), &GetTitleBlock() ); + DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( gerbIUScale.IU_PER_MILS, + &GetPageSettings(), &Prj(), + &GetTitleBlock(), nullptr ); if( GetScreen() ) { diff --git a/include/drawing_sheet/ds_draw_item.h b/include/drawing_sheet/ds_draw_item.h index e985fe2d37..bc325c75fd 100644 --- a/include/drawing_sheet/ds_draw_item.h +++ b/include/drawing_sheet/ds_draw_item.h @@ -394,6 +394,7 @@ public: m_paperFormat = nullptr; m_project = nullptr; m_isFirstPage = true; + m_properties = nullptr; } ~DS_DRAW_ITEM_LIST() @@ -410,6 +411,11 @@ public: */ void SetTitleBlock( const TITLE_BLOCK* aTblock ) { m_titleBlock = aTblock; } + /** + * Set properties used for text variable resolution. + */ + void SetProperties( const std::map* aProps ) { m_properties = aProps; } + /** * Set the paper format name (mainly for drawing sheet editor) */ @@ -547,31 +553,8 @@ public: static void GetTextVars( wxArrayString* aVars ); /** - * Return the full text corresponding to the aTextbase, - * after replacing format symbols by the corresponding value - * - * Basic texts in Ki_WorkSheetData struct use format notation - * like "Title %T" to identify at run time the full text - * to display. - * Currently format identifier is % followed by a letter or 2 letters - * - * %% = replaced by % - * %K = Kicad version - * %Z = paper format name (A4, USLetter) - * %Y = company name - * %D = date - * %R = revision - * %S = sheet number - * %N = number of sheets - * %Cx = comment (x = 0 to 9 to identify the comment) - * %F = filename - * %P = sheet path or sheet full name - * %T = title - * Other fields like Developer, Verifier, Approver could use %Cx - * and are seen as comments for format - * - * @param aTextbase = the text with format symbols - * @return the text, after replacing the format symbols by the actual value + * @return the full text corresponding to the aTextbase, after replacing any text variable + * references. */ wxString BuildFullText( const wxString& aTextbase ); @@ -584,15 +567,17 @@ protected: // used when an item has a pen size = 0 bool m_isFirstPage; ///< Is this the first page or not. int m_sheetCount; ///< The number of sheets - // for basic inscriptions, in schematic - const TITLE_BLOCK* m_titleBlock; // for basic inscriptions - const wxString* m_paperFormat; // for basic inscriptions - wxString m_fileName; // for basic inscriptions - wxString m_sheetName; // for basic inscriptions - wxString m_sheetPath; // for basic inscriptions + // for text variable references, in schematic + const TITLE_BLOCK* m_titleBlock; // for text variable references + const wxString* m_paperFormat; // for text variable references + wxString m_fileName; // for text variable references + wxString m_sheetName; // for text variable references + wxString m_sheetPath; // for text variable references wxString m_pageNumber; ///< The actual page number displayed in the title block. - const wxString* m_sheetLayer; // for basic inscriptions - const PROJECT* m_project; // for project-based variable substitutions + const wxString* m_sheetLayer; // for text variable references + const PROJECT* m_project; // for project-based text variable references + + const std::map* m_properties; // for text variable references }; diff --git a/include/drawing_sheet/ds_painter.h b/include/drawing_sheet/ds_painter.h index 120c12b5de..d36f390d36 100644 --- a/include/drawing_sheet/ds_painter.h +++ b/include/drawing_sheet/ds_painter.h @@ -131,8 +131,9 @@ private: * @param aPageInfo for margins and page size (in mils). * @param aFullSheetName The sheetpath (full sheet name), for basic inscriptions. * @param aFileName The file name, for basic inscriptions. - * @param aTitleBlock The sheet title block, for basic inscriptions. - * @param aSheetCount The number of sheets (for basic inscriptions). + * @param aTitleBlock The sheet title block, for text variable resolution. + * @param aProperties Optional properties for text variable resolution. + * @param aSheetCount The number of sheets (for text variable resolution). * @param aPageNumber The page number. * @param aScalar the scale factor to convert from mils to internal units. * @param aSheetLayer The layer from Pcbnew. @@ -145,7 +146,8 @@ private: */ void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo, const wxString& aFullSheetName, const wxString& aFileName, - const TITLE_BLOCK& aTitleBlock, int aSheetCount, + const TITLE_BLOCK& aTitleBlock, + const std::map* aProperties, int aSheetCount, const wxString& aPageNumber, double aScalar, const PROJECT* aProject, const wxString& aSheetLayer = wxEmptyString, bool aIsFirstPage = true ); diff --git a/include/drawing_sheet/ds_proxy_view_item.h b/include/drawing_sheet/ds_proxy_view_item.h index 2d74f5741a..faa4889913 100644 --- a/include/drawing_sheet/ds_proxy_view_item.h +++ b/include/drawing_sheet/ds_proxy_view_item.h @@ -48,7 +48,8 @@ class DS_PROXY_VIEW_ITEM : public EDA_ITEM { public: DS_PROXY_VIEW_ITEM( int aScaleFactor, const PAGE_INFO* aPageInfo, const PROJECT* aProject, - const TITLE_BLOCK* aTitleBlock ); + const TITLE_BLOCK* aTitleBlock, + const std::map* aProperties ); /** * Set the file name displayed in the title block. @@ -129,7 +130,8 @@ public: bool HitTestDrawingSheetItems( KIGFX::VIEW* aView, const VECTOR2I& aPosition ); protected: - void buildDrawList( KIGFX::VIEW* aView, DS_DRAW_ITEM_LIST* aDrawList ) const; + void buildDrawList( KIGFX::VIEW* aView, const std::map* aProperties, + DS_DRAW_ITEM_LIST* aDrawList ) const; /// the factor between mils (units used in drawing sheet and internal units) /// it is the value IU_PER_MILS used in the caller @@ -145,6 +147,8 @@ protected: bool m_isFirstPage; const PROJECT* m_project; + const std::map* m_properties; + /// Layer that is used for drawing sheet color (LAYER_DRAWINGSHEET is always used for visibility) int m_colorLayer; diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index caab9ff588..e2c2ec3046 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -304,13 +304,14 @@ public: * Prints the drawing-sheet (frame and title block). * * @param aScreen screen to draw. + * @param aProperties Optional properties for text variable resolution. * @param aMils2Iu The mils to Iu conversion factor. * @param aFilename The filename to display in basic inscriptions. * @param aSheetLayer The layer displayed from PcbNew. */ void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, BASE_SCREEN* aScreen, - double aMils2Iu, const wxString& aFilename, - const wxString& aSheetLayer = wxEmptyString ); + const std::map* aProperties, double aMils2Iu, + const wxString& aFilename, const wxString& aSheetLayer = wxEmptyString ); void DisplayToolMsg( const wxString& msg ) override; diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index b9f9638db2..cc9094e02d 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -641,10 +641,10 @@ protected: // variables used in most of plotters: class TITLE_BLOCK; void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BLOCK& aTitleBlock, - const PAGE_INFO& aPageInfo, const wxString& aSheetNumber, int aSheetCount, - const wxString& aSheetName, const wxString& aSheetPath, - const wxString& aFilename, COLOR4D aColor = COLOR4D::UNSPECIFIED, - bool aIsFirstPage = true ); + const PAGE_INFO& aPageInfo, const std::map*aProperties, + const wxString& aSheetNumber, int aSheetCount, const wxString& aSheetName, + const wxString& aSheetPath, const wxString& aFilename, + COLOR4D aColor = COLOR4D::UNSPECIFIED, bool aIsFirstPage = true ); /** Returns the default plot extension for a format */ diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp index 5731633b51..cf191bd672 100644 --- a/pagelayout_editor/dialogs/dialogs_for_printing.cpp +++ b/pagelayout_editor/dialogs/dialogs_for_printing.cpp @@ -203,7 +203,8 @@ void PLEDITOR_PRINTOUT::PrintPage( int aPageNum ) } } - m_parent->PrintDrawingSheet( &renderSettings, screen, drawSheetIUScale.IU_PER_MILS, wxEmptyString ); + m_parent->PrintDrawingSheet( &renderSettings, screen, nullptr, drawSheetIUScale.IU_PER_MILS, + wxEmptyString ); m_parent->SetDrawBgColor( bg_color ); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index f9c70548c1..0627b2a142 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -777,7 +777,8 @@ void PL_EDITOR_FRAME::PrintPage( const RENDER_SETTINGS* aSettings ) } } - PrintDrawingSheet( aSettings, GetScreen(), drawSheetIUScale.IU_PER_MILS, wxEmptyString ); + PrintDrawingSheet( aSettings, GetScreen(), nullptr, drawSheetIUScale.IU_PER_MILS, + wxEmptyString ); GetCanvas()->DisplayDrawingSheet(); GetCanvas()->Refresh(); diff --git a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp index 58cfc4af6f..8f2220838e 100644 --- a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp @@ -502,8 +502,8 @@ void PANEL_PCBNEW_COLOR_SETTINGS::createPreviewItems() m_preview->UpdateColors(); m_preview->DisplayBoard( m_preview->GetBoard() ); - DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( (int) pcbIUScale.IU_PER_MILS, m_page, nullptr, - m_titleBlock ); + DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( (int) pcbIUScale.IU_PER_MILS, m_page, + nullptr, m_titleBlock, nullptr ); drawingSheet->SetIsFirstPage( true ); drawingSheet->SetColorLayer( LAYER_DRAWINGSHEET ); drawingSheet->SetPageBorderColorLayer( LAYER_PAGE_LIMITS ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 5261d9a7b5..34133dd167 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -532,8 +532,11 @@ void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( pcbIUScale.IU_PER_MILS, &m_pcb->GetPageSettings(), m_pcb->GetProject(), - &m_pcb->GetTitleBlock() ); + &m_pcb->GetTitleBlock(), + &m_pcb->GetProperties() ); + drawingSheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) ); + // A board is not like a schematic having a main page and sub sheets. // So for the drawing sheet, use only the first page option to display items drawingSheet->SetIsFirstPage( true ); diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 437acce1a5..43bb693eac 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -1215,8 +1215,8 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL if( aPlotOpts->GetPlotFrameRef() ) { PlotDrawingSheet( plotter, aBoard->GetProject(), aBoard->GetTitleBlock(), - aBoard->GetPageSettings(), wxT( "1" ), 1, aSheetName, aSheetPath, - aBoard->GetFileName() ); + aBoard->GetPageSettings(), &aBoard->GetProperties(), wxT( "1" ), 1, + aSheetName, aSheetPath, aBoard->GetFileName() ); if( aPlotOpts->GetMirror() ) initializePlotter( plotter, aBoard, aPlotOpts );