Generalize bookmarks to support additional groups and names
This commit is contained in:
parent
6f8205235f
commit
a381a0acb2
|
@ -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<BOX2I, wxString>& 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<BOX2I, wxString>& 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<wxString>&
|
|||
}
|
||||
|
||||
|
||||
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 ) );
|
||||
}
|
||||
|
|
|
@ -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") );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ public:
|
|||
|
||||
void HyperlinkMenu( const BOX2I& aBox, const std::vector<wxString>& 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<int, std::pair<BOX2D, wxString>> m_hyperlinkHandles;
|
||||
std::map<int, std::pair<BOX2D, std::vector<wxString>>> m_hyperlinkMenuHandles;
|
||||
|
||||
std::vector<std::pair<BOX2I, wxString>> m_componentBookmarksInPage;
|
||||
std::map<wxString, std::vector<std::pair<BOX2I, wxString>>> m_bookmarksInPage;
|
||||
|
||||
std::unique_ptr<OUTLINE_NODE> m_outlineRoot; ///< Root outline node
|
||||
int m_totalOutlineNodes; ///< Total number of outline nodes
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue