diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 656b8ab3eb..43f481a534 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -813,35 +813,37 @@ void PDF_PLOTTER::ClosePage() OUTLINE_NODE* pageOutlineNode = addOutlineNode( m_outlineRoot.get(), -1, wxString::Format( _( "Page %s" ), m_pageNumbers.back() ) ); - - OUTLINE_NODE* componentOutlineNode = addOutlineNode( pageOutlineNode, -1, _( "Components" ) ); - // let's reorg the symbol bookmarks under a page handle - for( const std::pair& bookmarkPair : m_componentBookmarksInPage ) + // let's reorg the symbol bookmarks under a page handle + for( const auto& [groupName, groupVector] : m_bookmarksInPage ) { - const BOX2I& box = bookmarkPair.first; - const wxString& ref = bookmarkPair.second; + OUTLINE_NODE* groupOutlineNode = addOutlineNode( pageOutlineNode, -1, groupName ); - VECTOR2I bottomLeft = iuToPdfUserSpace( box.GetPosition() ); - VECTOR2I topRight = iuToPdfUserSpace( box.GetEnd() ); + for( const std::pair& bookmarkPair : groupVector ) + { + const BOX2I& box = bookmarkPair.first; + const wxString& ref = bookmarkPair.second; - int actionHandle = emitGoToAction( pageHandle, bottomLeft, topRight ); + VECTOR2I bottomLeft = iuToPdfUserSpace( box.GetPosition() ); + VECTOR2I topRight = iuToPdfUserSpace( box.GetEnd() ); - addOutlineNode( componentOutlineNode, actionHandle, ref ); + int actionHandle = emitGoToAction( pageHandle, bottomLeft, topRight ); + + addOutlineNode( groupOutlineNode, actionHandle, ref ); + } + + std::sort( groupOutlineNode->children.begin(), groupOutlineNode->children.end(), + []( const OUTLINE_NODE* a, const OUTLINE_NODE* b ) -> bool + { + return a->title < b->title; + } ); } - std::sort( componentOutlineNode->children.begin(), componentOutlineNode->children.end(), - []( const OUTLINE_NODE* a, const OUTLINE_NODE* b ) -> bool - { - return a->title < b->title; - } ); - - // Clean up m_hyperlinksInPage.clear(); m_hyperlinkMenusInPage.clear(); - m_componentBookmarksInPage.clear(); + m_bookmarksInPage.clear(); } @@ -856,7 +858,7 @@ bool PDF_PLOTTER::StartPlot(const wxString& aPageNumber) m_hyperlinkMenusInPage.clear(); m_hyperlinkHandles.clear(); m_hyperlinkMenuHandles.clear(); - m_componentBookmarksInPage.clear(); + m_bookmarksInPage.clear(); m_outlineRoot.release(); m_totalOutlineNodes = 0; @@ -1367,7 +1369,8 @@ void PDF_PLOTTER::HyperlinkMenu( const BOX2I& aBox, const std::vector& } -void PDF_PLOTTER::ComponentBookmark( const BOX2I& aLocation, const wxString& aSymbolReference ) +void PDF_PLOTTER::Bookmark( const BOX2I& aLocation, const wxString& aSymbolReference, const wxString &aGroupName ) { - m_componentBookmarksInPage.push_back( std::make_pair( aLocation, aSymbolReference ) ); + + m_bookmarksInPage[aGroupName].push_back( std::make_pair( aLocation, aSymbolReference ) ); } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 962dbafacb..001c197771 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -2066,8 +2066,7 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const aPlotter->EndBlock( nullptr ); - aPlotter->ComponentBookmark( GetBoundingBox(), - GetField( REFERENCE_FIELD )->GetShownText() ); + aPlotter->Bookmark( GetBoundingBox(), GetField( REFERENCE_FIELD )->GetShownText(), _("Symbols") ); } } diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index cb71a5b86a..1beac0ed02 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -454,7 +454,8 @@ public: * @aBox is the bounding box of the symbol * @aSymbolReference is the symbol schematic ref */ - virtual void ComponentBookmark( const BOX2I& aBox, const wxString& aSymbolReference ) + virtual void Bookmark( const BOX2I& aBox, const wxString& aName, + const wxString& aGroupName = wxEmptyString ) { // NOP for most plotters. } diff --git a/include/plotters/plotters_pslike.h b/include/plotters/plotters_pslike.h index 4bdeefb8b9..7bf84f4eeb 100644 --- a/include/plotters/plotters_pslike.h +++ b/include/plotters/plotters_pslike.h @@ -352,7 +352,7 @@ public: void HyperlinkMenu( const BOX2I& aBox, const std::vector& aDestURLs ) override; - void ComponentBookmark( const BOX2I& aLocation, const wxString& aSymbolReference ) override; + void Bookmark( const BOX2I& aBox, const wxString& aName, const wxString& aGroupName = wxEmptyString ) override; /** * PDF images are handles as inline, not XObject streams... @@ -481,7 +481,7 @@ protected: std::map> m_hyperlinkHandles; std::map>> m_hyperlinkMenuHandles; - std::vector> m_componentBookmarksInPage; + std::map>> m_bookmarksInPage; std::unique_ptr m_outlineRoot; ///< Root outline node int m_totalOutlineNodes; ///< Total number of outline nodes diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 51a7ef97ea..8f0fe62781 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -524,7 +524,7 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask, } aPlotter->EndBlock( nullptr ); - aPlotter->ComponentBookmark( footprint->GetBoundingBox(), footprint->GetReference() ); + aPlotter->Bookmark( footprint->GetBoundingBox(), footprint->GetReference(), _( "Footprints" ) ); } // Plot vias on copper layers, and if aPlotOpt.GetPlotViaOnMaskLayer() is true,