Fix a couple of bugs in intersheet references.

1) init reference pages before trying to draw the SCH_FIELDs when
turning intersheet references on

2) don't double redraw because we accidentally cleared the last
hover item on a non-mouse-moved event.

3) make sure the root sheet gets a name for the hypertext menu.
This commit is contained in:
Jeff Young 2020-11-29 16:31:43 +00:00
parent d3d26f2892
commit 3da0ab1a9a
5 changed files with 21 additions and 9 deletions

View File

@ -539,7 +539,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
SetSheetNumberAndCount(); SetSheetNumberAndCount();
RecomputeIntersheetsRefs(); RecomputeIntersheetRefs();
// re-create junctions if needed. Eeschema optimizes wires by merging // re-create junctions if needed. Eeschema optimizes wires by merging
// colinear segments. If a schematic is saved without a valid // colinear segments. If a schematic is saved without a valid

View File

@ -1285,13 +1285,13 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags )
wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() ); wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
if( settings.m_IntersheetRefsShow == true ) if( settings.m_IntersheetRefsShow == true )
RecomputeIntersheetsRefs(); RecomputeIntersheetRefs();
Schematic().ConnectionGraph()->Recalculate( list, true ); Schematic().ConnectionGraph()->Recalculate( list, true );
} }
int SCH_EDIT_FRAME::RecomputeIntersheetsRefs() int SCH_EDIT_FRAME::RecomputeIntersheetRefs()
{ {
std::map<wxString, std::set<wxString>>& pageRefsMap = Schematic().GetPageRefsMap(); std::map<wxString, std::set<wxString>>& pageRefsMap = Schematic().GetPageRefsMap();
@ -1348,6 +1348,9 @@ int SCH_EDIT_FRAME::RecomputeIntersheetsRefs()
void SCH_EDIT_FRAME::ShowAllIntersheetRefs( bool aShow ) void SCH_EDIT_FRAME::ShowAllIntersheetRefs( bool aShow )
{ {
if( aShow )
RecomputeIntersheetRefs();
SCH_SCREENS screens( Schematic().Root() ); SCH_SCREENS screens( Schematic().Root() );
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() ) for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )

View File

@ -927,7 +927,12 @@ public:
*/ */
void UpdateSymbolFromEditor( const LIB_PART& aSymbol ); void UpdateSymbolFromEditor( const LIB_PART& aSymbol );
int RecomputeIntersheetsRefs(); /**
* Update the schematic's page reference map for all global labels, and refresh the labels
* so that they are redrawn with up-to-date references.
* @return
*/
int RecomputeIntersheetRefs();
void ShowAllIntersheetRefs( bool aShow ); void ShowAllIntersheetRefs( bool aShow );

View File

@ -472,15 +472,18 @@ void SCH_FIELD::DoHypertextMenu( EDA_DRAW_FRAME* aFrame )
std::sort( pageListCopy.begin(), pageListCopy.end() ); std::sort( pageListCopy.begin(), pageListCopy.end() );
for( const SCH_SHEET_PATH& sheet : Schematic()->GetSheets() ) for( const SCH_SHEET_PATH& sheet : Schematic()->GetSheets() )
{
if( sheet.size() == 1 )
sheetNames[ sheet.GetPageNumber() ] = _( "<root sheet>" );
else
sheetNames[ sheet.GetPageNumber() ] = sheet.Last()->GetName(); sheetNames[ sheet.GetPageNumber() ] = sheet.Last()->GetName();
}
for( const wxString& pageNo : pageListCopy ) for( const wxString& pageNo : pageListCopy )
{ {
wxString pageName = pageNo == "/" ? _( "Root" ) : sheetNames[ pageNo ];
menu.Append( -1, wxString::Format( _( "Go to Page %s (%s)" ), menu.Append( -1, wxString::Format( _( "Go to Page %s (%s)" ),
pageNo, pageNo,
pageName ) ); sheetNames[ pageNo ] ) );
} }
menu.AppendSeparator(); menu.AppendSeparator();

View File

@ -307,7 +307,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
{ {
bool displayWireCursor = false; bool displayWireCursor = false;
KIID rolloverItem = niluuid; KIID rolloverItem = lastRolloverItem;
m_additive = m_subtractive = m_exclusive_or = false; m_additive = m_subtractive = m_exclusive_or = false;
if( evt->Modifier( MD_SHIFT ) && evt->Modifier( MD_CTRL ) ) if( evt->Modifier( MD_SHIFT ) && evt->Modifier( MD_CTRL ) )
@ -496,6 +496,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
} }
else if( evt->IsMotion() && !m_isSymbolEditor && m_frame->ToolStackIsEmpty() ) else if( evt->IsMotion() && !m_isSymbolEditor && m_frame->ToolStackIsEmpty() )
{ {
rolloverItem = niluuid;
EE_COLLECTOR collector; EE_COLLECTOR collector;
// We are checking if we should display a pencil when hovering over anchors // We are checking if we should display a pencil when hovering over anchors