Show field children when creating new labels.
And in particular, show reasonable intersheet reference facsimiles.
This commit is contained in:
parent
04f7fbfa4a
commit
c7d689a022
|
@ -1149,11 +1149,16 @@ bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const
|
|||
{
|
||||
if( token->IsSameAs( wxT( "INTERSHEET_REFS" ) ) && Schematic() )
|
||||
{
|
||||
SCHEMATIC_SETTINGS& settings = Schematic()->Settings();
|
||||
wxString ref;
|
||||
auto it = Schematic()->GetPageRefsMap().find( GetText() );
|
||||
|
||||
if( it != Schematic()->GetPageRefsMap().end() )
|
||||
if( it == Schematic()->GetPageRefsMap().end() )
|
||||
{
|
||||
ref = "?";
|
||||
}
|
||||
else
|
||||
{
|
||||
SCHEMATIC_SETTINGS& settings = Schematic()->Settings();
|
||||
std::vector<wxString> pageListCopy;
|
||||
|
||||
pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
|
||||
|
@ -1167,26 +1172,23 @@ bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const
|
|||
currentPage ), pageListCopy.end() );
|
||||
}
|
||||
|
||||
token->Printf( "%s", settings.m_IntersheetRefsPrefix );
|
||||
|
||||
if( ( settings.m_IntersheetRefsFormatShort ) && ( pageListCopy.size() > 2 ) )
|
||||
{
|
||||
token->Append( wxString::Format( wxT( "%s..%s" ),
|
||||
ref.Append( wxString::Format( wxT( "%s..%s" ),
|
||||
pageListCopy.front(),
|
||||
pageListCopy.back() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( const wxString& pageNo : pageListCopy )
|
||||
token->Append( wxString::Format( wxT( "%s," ), pageNo ) );
|
||||
ref.Append( wxString::Format( wxT( "%s," ), pageNo ) );
|
||||
|
||||
if( !token->IsEmpty() && token->Last() == ',' )
|
||||
token->RemoveLast();
|
||||
}
|
||||
|
||||
token->Append( settings.m_IntersheetRefsSuffix );
|
||||
if( !ref.IsEmpty() && ref.Last() == ',' )
|
||||
ref.RemoveLast();
|
||||
}
|
||||
}
|
||||
|
||||
*token = settings.m_IntersheetRefsPrefix + ref + settings.m_IntersheetRefsSuffix;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -806,6 +806,9 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
|
|||
case LAYER_GLOBLABEL:
|
||||
textItem = new SCH_GLOBALLABEL( (wxPoint) aPosition );
|
||||
textItem->SetShape( m_lastGlobalLabelShape );
|
||||
|
||||
if( settings.m_IntersheetRefsShow )
|
||||
static_cast<SCH_GLOBALLABEL*>( textItem )->GetIntersheetRefs()->SetVisible( true );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -936,6 +939,17 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
||||
};
|
||||
|
||||
auto updatePreview =
|
||||
[&]()
|
||||
{
|
||||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( item->Clone() );
|
||||
item->RunOnChildren( [&]( SCH_ITEM* aChild )
|
||||
{
|
||||
m_view->AddToPreview( aChild->Clone() );
|
||||
} );
|
||||
};
|
||||
|
||||
auto cleanup =
|
||||
[&]()
|
||||
{
|
||||
|
@ -1064,15 +1078,15 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
|
||||
|
||||
// Restore cursor after dialog
|
||||
controls->WarpCursor( controls->GetCursorPosition(), true );
|
||||
|
||||
if( item )
|
||||
{
|
||||
item->SetFlags( IS_NEW | IS_MOVED );
|
||||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( item->Clone() );
|
||||
m_selectionTool->AddItemToSel( item );
|
||||
updatePreview();
|
||||
|
||||
// update the cursor so it looks correct before another event
|
||||
setCursor();
|
||||
|
@ -1085,8 +1099,6 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
else
|
||||
{
|
||||
item->ClearFlags( IS_MOVED );
|
||||
item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
|
||||
|
||||
m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), (SCH_ITEM*) item, false );
|
||||
item = nullptr;
|
||||
|
||||
|
@ -1109,8 +1121,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
if( selection.GetSize() == 1 )
|
||||
{
|
||||
item = (SCH_ITEM*) selection.Front();
|
||||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( item->Clone() );
|
||||
updatePreview();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1119,9 +1130,11 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
|
||||
{
|
||||
static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint) cursorPos );
|
||||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( item->Clone() );
|
||||
SCH_ITEM* sch_item = static_cast<SCH_ITEM*>( item );
|
||||
|
||||
item->SetPosition( (wxPoint) cursorPos );
|
||||
item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
|
||||
updatePreview();
|
||||
}
|
||||
else if( item && evt->IsAction( &ACTIONS::doDelete ) )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue