Labels can connect directly to symbols, other labels, etc.

Fixes https://gitlab.com/kicad/code/kicad/issues/11768

(cherry picked from commit c6604e3576)
This commit is contained in:
Jeff Young 2022-06-12 18:15:38 +01:00
parent 0580fc6819
commit 832c689345
2 changed files with 65 additions and 12 deletions

View File

@ -306,8 +306,26 @@ public:
bool CanConnect( const SCH_ITEM* aItem ) const override
{
return aItem->Type() == SCH_LINE_T &&
( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
switch( aItem->Type() )
{
case SCH_LINE_T:
return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
case SCH_BUS_WIRE_ENTRY_T:
return true;
case SCH_SYMBOL_T:
return true;
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T:
return true;
default:
return false;
}
}
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
@ -400,8 +418,26 @@ public:
bool CanConnect( const SCH_ITEM* aItem ) const override
{
return aItem->Type() == SCH_LINE_T &&
( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
switch( aItem->Type() )
{
case SCH_LINE_T:
return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
case SCH_BUS_WIRE_ENTRY_T:
return true;
case SCH_SYMBOL_T:
return true;
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T:
return true;
default:
return false;
}
}
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
@ -473,8 +509,26 @@ public:
bool CanConnect( const SCH_ITEM* aItem ) const override
{
return aItem->Type() == SCH_LINE_T &&
( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
switch( aItem->Type() )
{
case SCH_LINE_T:
return aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS;
case SCH_BUS_WIRE_ENTRY_T:
return true;
case SCH_SYMBOL_T:
return true;
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T:
return true;
default:
return false;
}
}
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;

View File

@ -544,6 +544,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, const wxPoin
EE_RTREE& items = m_frame->GetScreen()->Items();
EE_RTREE::EE_TYPE itemsOverlapping = items.Overlapping( aOriginalItem->GetBoundingBox() );
bool ptHasUnselectedJunction = false;
SCH_LINE* newWire = nullptr;
for( SCH_ITEM* item : itemsOverlapping )
{
@ -625,14 +626,12 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, const wxPoin
case SCH_SHEET_T:
case SCH_SYMBOL_T:
case SCH_JUNCTION_T:
if( test->IsConnected( aPoint ) )
if( test->IsConnected( aPoint ) && !newWire )
{
// Add a new wire between the symbol or junction and the selected item so
// the selected item can be dragged.
SCH_LINE* newWire = nullptr;
if( test->GetLayer() == LAYER_BUS_JUNCTION ||
aOriginalItem->GetLayer() == LAYER_BUS )
if( test->GetLayer() == LAYER_BUS_JUNCTION
|| aOriginalItem->GetLayer() == LAYER_BUS )
{
newWire = new SCH_LINE( aPoint, LAYER_BUS );
}
@ -704,7 +703,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, const wxPoin
newWire->SetFlags( IS_NEW );
m_frame->AddToScreen( newWire, m_frame->GetScreen() );
newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
newWire->SetFlags( TEMP_SELECTED | STARTPOINT );
aList.push_back( newWire );
}