From 209e1b208683997898421584d7f8512d8cb598f0 Mon Sep 17 00:00:00 2001 From: Marek Roszko <mark.roszko@gmail.com> Date: Sat, 24 Sep 2022 22:52:09 -0400 Subject: [PATCH] Add naming of the outline page entries --- common/plotters/PDF_plotter.cpp | 28 ++++++++++++++++++---- eeschema/dialogs/dialog_plot_schematic.cpp | 5 ++-- include/plotters/plotters_pslike.h | 7 +++++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 43f481a534..39920638d2 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -670,12 +670,13 @@ void PDF_PLOTTER::closePdfStream() } -void PDF_PLOTTER::StartPage( const wxString& aPageNumber ) +void PDF_PLOTTER::StartPage( const wxString& aPageNumber, const wxString& aPageName ) { wxASSERT( m_outputFile ); wxASSERT( !m_workFile ); m_pageNumbers.push_back( aPageNumber ); + m_pageName = aPageName; // Compute the paper size in IUs m_paperSize = m_pageInfo.GetSizeMils(); @@ -810,8 +811,18 @@ void PDF_PLOTTER::ClosePage() // Mark the page stream as idle m_pageStreamHandle = 0; - OUTLINE_NODE* pageOutlineNode = addOutlineNode( - m_outlineRoot.get(), -1, wxString::Format( _( "Page %s" ), m_pageNumbers.back() ) ); + wxString pageOutlineName = wxEmptyString; + if( m_pageName.IsEmpty() ) + { + pageOutlineName = wxString::Format( _( "Page %s" ), m_pageNumbers.back() ); + } + else + { + pageOutlineName = wxString::Format( _( "%s (Page %s)" ), m_pageName, m_pageNumbers.back() ); + } + + + OUTLINE_NODE* pageOutlineNode = addOutlineNode( m_outlineRoot.get(), -1, pageOutlineName ); // let's reorg the symbol bookmarks under a page handle // let's reorg the symbol bookmarks under a page handle @@ -847,7 +858,14 @@ void PDF_PLOTTER::ClosePage() } -bool PDF_PLOTTER::StartPlot(const wxString& aPageNumber) +bool PDF_PLOTTER::StartPlot( const wxString& aPageNumber ) +{ + return StartPlot( aPageNumber, wxEmptyString ); +} + + +bool PDF_PLOTTER::StartPlot( const wxString& aPageNumber, + const wxString& aPageName ) { wxASSERT(m_outputFile); @@ -879,7 +897,7 @@ bool PDF_PLOTTER::StartPlot(const wxString& aPageNumber) /* Now, the PDF is read from the end, (more or less)... so we start with the page stream for page 1. Other more important stuff is written at the end */ - StartPage(aPageNumber); + StartPage(aPageNumber, aPageName); return true; } diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index 9b8d59a04d..fc863d671a 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -851,7 +851,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet // Open the plotter and do the first page setupPlotPagePDF( plotter, screen ); - plotter->StartPlot( sheetList[i].GetPageNumber() ); + plotter->StartPlot( sheetList[i].GetPageNumber(), _("Root") ); } catch( const IO_ERROR& e ) { @@ -870,7 +870,8 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotDrawingSheet * reconfigure, and then start a new one */ plotter->ClosePage(); setupPlotPagePDF( plotter, screen ); - plotter->StartPage( sheetList[i].GetPageNumber() ); + plotter->StartPage( sheetList[i].GetPageNumber(), + sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText() ); } plotOneSheetPDF( plotter, screen, aPlotDrawingSheet ); diff --git a/include/plotters/plotters_pslike.h b/include/plotters/plotters_pslike.h index 7bf84f4eeb..b0bf2fd89c 100644 --- a/include/plotters/plotters_pslike.h +++ b/include/plotters/plotters_pslike.h @@ -274,12 +274,16 @@ public: * are to be closed and reopened. Between each page parameters can be set. */ virtual bool StartPlot( const wxString& aPageNumber ) override; + + virtual bool StartPlot( const wxString& aPageNumber, + const wxString& aPageName = wxEmptyString ); + virtual bool EndPlot() override; /** * Start a new page in the PDF document. */ - virtual void StartPage( const wxString& aPageNumber ); + virtual void StartPage( const wxString& aPageNumber, const wxString& aPageName = wxEmptyString ); /** * Close the current page in the PDF document (and emit its compressed stream). @@ -467,6 +471,7 @@ protected: int m_pageStreamHandle; ///< Handle of the page content object int m_streamLengthHandle; ///< Handle to the deferred stream length wxString m_workFilename; + wxString m_pageName; FILE* m_workFile; ///< Temporary file to construct the stream before zipping std::vector<long> m_xrefTable; ///< The PDF xref offset table