Add import-sheet-pin error message and move messages to status popups.

Fixes: lp:1829314
* https://bugs.launchpad.net/kicad/+bug/1829314
This commit is contained in:
Jeff Young 2019-05-16 22:58:47 +01:00
parent 6630a7227d
commit 0dd1584394
4 changed files with 53 additions and 52 deletions

View File

@ -910,7 +910,7 @@ public:
* @param aSheet The sheet to add the new sheet pin to.
* @return The new sheet pin object created or NULL if the task was aborted by the user.
*/
SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet );
SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel );
/**
* Display the dialog for editing the parameters of \a aSheetPin.
@ -922,13 +922,11 @@ public:
int EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw );
/**
* Automatically create a sheet pin from the hierarchical labels in the schematic
* referenced by \a aSheet.
* Import a hierarchical label with no attached sheet pin.
*
* @param aSheet The sheet to import the new sheet pin to.
* @return The new sheet pin object imported or NULL if the task was aborted by the user.
*/
SCH_SHEET_PIN* ImportSheetPin( SCH_SHEET* aSheet );
SCH_HIERLABEL* ImportHierLabel( SCH_SHEET* aSheet );
/**
* Removes a given junction and heals any wire segments under the junction

View File

@ -342,22 +342,31 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw )
}
SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet )
SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel )
{
wxString line;
wxString text;
SCH_SHEET_PIN* sheetPin;
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line );
if( aLabel )
{
text = aLabel->GetText();
m_lastSheetPinType = aLabel->GetShape();
}
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
sheetPin->SetFlags( IS_NEW );
sheetPin->SetTextSize( GetLastSheetPinTextSize() );
sheetPin->SetShape( m_lastSheetPinType );
int response = EditSheetPin( sheetPin, false );
if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) )
if( !aLabel )
{
delete sheetPin;
return NULL;
int response = EditSheetPin( sheetPin, false );
if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) )
{
delete sheetPin;
return NULL;
}
}
m_lastSheetPinType = sheetPin->GetShape();
@ -369,43 +378,22 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet )
}
SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet )
SCH_HIERLABEL* SCH_EDIT_FRAME::ImportHierLabel( SCH_SHEET* aSheet )
{
EDA_ITEM* item;
SCH_SHEET_PIN* sheetPin;
SCH_HIERLABEL* label = NULL;
if( !aSheet->GetScreen() )
return NULL;
item = aSheet->GetScreen()->GetDrawItems();
for( ; item != NULL; item = item->Next() )
for( EDA_ITEM* item = aSheet->GetScreen()->GetDrawItems(); item != NULL; item = item->Next() )
{
if( item->Type() != SCH_HIER_LABEL_T )
continue;
label = (SCH_HIERLABEL*) item;
SCH_HIERLABEL* label = (SCH_HIERLABEL*) item;
/* A global label has been found: check if there a corresponding sheet label. */
if( !aSheet->HasPin( label->GetText() ) )
break;
label = NULL;
return label;
}
if( label == NULL )
{
DisplayInfoMessage( this, _( "No new hierarchical labels found." ) );
return NULL;
}
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() );
sheetPin->SetFlags( IS_NEW );
sheetPin->SetTextSize( GetLastSheetPinTextSize() );
m_lastSheetPinType = label->GetShape();
sheetPin->SetShape( label->GetShape() );
sheetPin->SetPosition( GetCrossHairPosition() );
return sheetPin;
return nullptr;
}

View File

@ -658,25 +658,40 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
item = m_frame->CreateNewText( LAYER_NOTES );
break;
case SCH_SHEET_PIN_T:
item = m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsOnly );
if( item )
{
if( m_frame->GetToolId() == ID_IMPORT_SHEETPIN_TOOL )
item = m_frame->ImportSheetPin( (SCH_SHEET*) item );
else
item = m_frame->CreateSheetPin( (SCH_SHEET*) item );
}
else
{
SCH_HIERLABEL* label = nullptr;
SCH_SHEET* sheet = (SCH_SHEET*) m_selectionTool->SelectPoint( cursorPos,
EE_COLLECTOR::SheetsOnly );
if( !sheet )
{
m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
m_statusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
m_statusPopup->SetText( _( "Click over a sheet to create a sheet pin" ) );
m_statusPopup->SetText( _( "Click over a sheet." ) );
m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
m_statusPopup->Popup();
m_statusPopup->Expire( 1500 );
m_statusPopup->Expire( 2000 );
break;
}
if( m_frame->GetToolId() == ID_IMPORT_SHEETPIN_TOOL )
{
label = m_frame->ImportHierLabel( sheet );
if( !label )
{
m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
m_statusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
m_statusPopup->Popup();
m_statusPopup->Expire( 2000 );
break;
}
}
item = m_frame->CreateSheetPin( sheet, label );
break;
}
default:
wxFAIL_MSG( "doTwoClickPlace(): unknown type" );
}

View File

@ -333,7 +333,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
{
editFrame->SendCrossProbeNetName( netName );
editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
UnescapeString( netName ) ) );
UnescapeString( netName ) ) );
}
editFrame->SetSelectedNetName( netName );