Allow clicking on terminal point to finish a bus unfold.

Fixes https://gitlab.com/kicad/code/kicad/issues/7413
This commit is contained in:
Jeff Young 2021-02-06 23:35:24 +00:00
parent 088ff5b2bb
commit d70cebcd62
3 changed files with 30 additions and 23 deletions

View File

@ -485,38 +485,40 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false, wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false,
wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) ); wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) );
SCH_SHEET_PIN* label;
SCH_TEXT* text;
SCH_CONNECTION conn;
switch( aLayer ) switch( aLayer )
{ {
case LAYER_BUS: case LAYER_BUS:
{
if( GetBus( aPosition ) ) if( GetBus( aPosition ) )
return true; return true;
label = GetSheetLabel( aPosition ); SCH_SHEET_PIN* sheetPin = GetSheetPin( aPosition );
if( label && conn.MightBeBusLabel( label->GetText() ) && label->IsConnected( aPosition ) ) if( sheetPin && SCH_CONNECTION::MightBeBusLabel( sheetPin->GetText() )
&& sheetPin->IsConnected( aPosition ) )
{
return true; return true;
}
text = GetLabel( aPosition ); SCH_TEXT* label = GetLabel( aPosition );
if( text && conn.MightBeBusLabel( text->GetText() ) && text->IsConnected( aPosition ) if( label && SCH_CONNECTION::MightBeBusLabel( label->GetText() )
&& (text->Type() != SCH_LABEL_T) ) && label->IsConnected( aPosition ) && label->Type() != SCH_LABEL_T )
{
return true; return true;
}
}
break; break;
case LAYER_NOTES: case LAYER_NOTES:
{
if( GetLine( aPosition ) ) if( GetLine( aPosition ) )
return true; return true;
}
break; break;
case LAYER_WIRE: case LAYER_WIRE:
{
if( GetItem( aPosition, Mils2iu( 6 ), SCH_BUS_WIRE_ENTRY_T) ) if( GetItem( aPosition, Mils2iu( 6 ), SCH_BUS_WIRE_ENTRY_T) )
return true; return true;
@ -532,16 +534,22 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
if( GetWire( aPosition ) ) if( GetWire( aPosition ) )
return true; return true;
text = GetLabel( aPosition ); SCH_TEXT* label = GetLabel( aPosition );
if( text && text->IsConnected( aPosition ) && !conn.MightBeBusLabel( text->GetText() ) ) if( label && !SCH_CONNECTION::MightBeBusLabel( label->GetText() )
&& label->IsConnected( aPosition ) && label->Type() != SCH_LABEL_T )
{
return true; return true;
}
label = GetSheetLabel( aPosition ); SCH_SHEET_PIN* sheetPin = GetSheetPin( aPosition );
if( label && label->IsConnected( aPosition ) && !conn.MightBeBusLabel( label->GetText() ) ) if( sheetPin && sheetPin->IsConnected( aPosition )
&& !SCH_CONNECTION::MightBeBusLabel( sheetPin->GetText() ) )
{
return true; return true;
}
}
break; break;
default: default:
@ -892,7 +900,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aSymbol,
} }
SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition ) SCH_SHEET_PIN* SCH_SCREEN::GetSheetPin( const wxPoint& aPosition )
{ {
SCH_SHEET_PIN* sheetPin = nullptr; SCH_SHEET_PIN* sheetPin = nullptr;

View File

@ -390,7 +390,7 @@ public:
* @param aPosition The position to test. * @param aPosition The position to test.
* @return The sheet label object if found otherwise NULL. * @return The sheet label object if found otherwise NULL.
*/ */
SCH_SHEET_PIN* GetSheetLabel( const wxPoint& aPosition ); SCH_SHEET_PIN* GetSheetPin( const wxPoint& aPosition );
/** /**
* Clear the annotation for the components in \a aSheetPath on the screen. * Clear the annotation for the components in \a aSheetPath on the screen.

View File

@ -628,10 +628,9 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
// Create a new segment if we're out of previously-created ones // Create a new segment if we're out of previously-created ones
else if( !segment->IsNull() || ( forceHV && !m_wires[ m_wires.size() - 2 ]->IsNull() ) ) else if( !segment->IsNull() || ( forceHV && !m_wires[ m_wires.size() - 2 ]->IsNull() ) )
{ {
// Terminate the command if the end point is on a pin, junction, or another // Terminate the command if the end point is on a pin, junction, label, or another
// wire or bus. // wire or bus.
if( !m_busUnfold.in_progress if( screen->IsTerminalPoint( cursorPos, segment->GetLayer() ) )
&& screen->IsTerminalPoint( cursorPos, segment->GetLayer() ) )
{ {
finishSegments(); finishSegments();
segment = nullptr; segment = nullptr;