Eeschema: Adding connection block selections
This adjusts the selection addition criteria for blocks to allow items such as labels to connect to lines not at the endpoints. It also uses the same logic to correctly gather bus-wire, bus-bus entries. Fixes: lp:1738941 * https://bugs.launchpad.net/kicad/+bug/1738941
This commit is contained in:
parent
7f9876ec27
commit
a061fe1f99
|
@ -99,8 +99,6 @@ public:
|
|||
|
||||
bool IsDangling() const override;
|
||||
|
||||
bool IsUnconnected() const override { return m_isDanglingEnd && m_isDanglingStart; }
|
||||
|
||||
bool IsSelectStateChanged( const wxRect& aRect ) override;
|
||||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
@ -144,6 +142,12 @@ public:
|
|||
|
||||
void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return aItem->Type() == SCH_LINE_T &&
|
||||
( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
|
||||
}
|
||||
|
||||
wxString GetSelectMenuText() const override;
|
||||
|
||||
EDA_ITEM* Clone() const override;
|
||||
|
@ -172,6 +176,11 @@ public:
|
|||
|
||||
void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
|
||||
}
|
||||
|
||||
wxString GetSelectMenuText() const override;
|
||||
|
||||
EDA_ITEM* Clone() const override;
|
||||
|
|
|
@ -570,6 +570,13 @@ public:
|
|||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
|
||||
( aItem->Type() == SCH_NO_CONNECT_T ) ||
|
||||
( aItem->Type() == SCH_JUNCTION_T );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the component is in netlist
|
||||
* which means this is not a power component, or something
|
||||
|
|
|
@ -268,7 +268,7 @@ public:
|
|||
|
||||
virtual bool IsDangling() const { return false; }
|
||||
|
||||
virtual bool IsUnconnected() const { return false; }
|
||||
virtual bool CanConnect( const SCH_ITEM* aItem ) const { return m_Layer == aItem->GetLayer(); }
|
||||
|
||||
/**
|
||||
* Function IsSelectStateChanged
|
||||
|
|
|
@ -79,6 +79,12 @@ public:
|
|||
|
||||
void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return aItem->Type() == SCH_LINE_T &&
|
||||
( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
|
||||
}
|
||||
|
||||
wxString GetSelectMenuText() const override { return wxString( _( "Junction" ) ); }
|
||||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
|
|
@ -579,6 +579,27 @@ bool SCH_LINE::IsConnectable() const
|
|||
}
|
||||
|
||||
|
||||
bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
|
||||
{
|
||||
switch( aItem->Type() )
|
||||
{
|
||||
case SCH_JUNCTION_T:
|
||||
case SCH_NO_CONNECT_T:
|
||||
case SCH_LABEL_T:
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
case SCH_HIERARCHICAL_LABEL_T:
|
||||
case SCH_BUS_WIRE_ENTRY_T:
|
||||
case SCH_COMPONENT_T:
|
||||
case SCH_SHEET_T:
|
||||
case SCH_SHEET_PIN_T:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return aItem->GetLayer() == m_Layer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
|
||||
{
|
||||
aPoints.push_back( m_start );
|
||||
|
|
|
@ -166,6 +166,8 @@ public:
|
|||
|
||||
void GetConnectionPoints(std::vector< wxPoint >& aPoints ) const override;
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override;
|
||||
|
||||
wxString GetSelectMenuText() const override;
|
||||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
|
|
@ -79,6 +79,12 @@ public:
|
|||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
|
||||
aItem->Type() == SCH_COMPONENT_T;
|
||||
}
|
||||
|
||||
void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
|
||||
|
||||
wxString GetSelectMenuText() const override { return wxString( _( "No Connect" ) ); }
|
||||
|
|
|
@ -773,13 +773,17 @@ void SCH_SCREEN::SelectBlockItems()
|
|||
}
|
||||
}
|
||||
|
||||
// Select the items that are connected to a component that was added
|
||||
// Select the items that are connected to a block object that was added
|
||||
// to our selection list in the last step.
|
||||
for( unsigned ii = last_select_id; ii < pickedlist->GetCount(); ii++ )
|
||||
{
|
||||
SCH_ITEM* item = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
|
||||
|
||||
if( item->Type() == SCH_COMPONENT_T )
|
||||
if( item->Type() == SCH_COMPONENT_T ||
|
||||
item->Type() == SCH_BUS_BUS_ENTRY_T ||
|
||||
item->Type() == SCH_BUS_WIRE_ENTRY_T ||
|
||||
item->Type() == SCH_SHEET_T ||
|
||||
( item->Type() == SCH_LINE_T && !( item->GetFlags() & ( ENDPOINT | STARTPOINT ) ) ) )
|
||||
{
|
||||
item->SetFlags( IS_DRAGGED );
|
||||
addConnections( item );
|
||||
|
@ -795,44 +799,59 @@ void SCH_SCREEN::addConnectedItemsToBlock( const SCH_ITEM* aItem, const wxPoint&
|
|||
SCH_ITEM* item;
|
||||
ITEM_PICKER picker;
|
||||
|
||||
if( aItem->IsUnconnected() )
|
||||
return;
|
||||
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
bool addinlist = true;
|
||||
picker.SetItem( item );
|
||||
|
||||
if( !item->IsConnectable() || !item->IsConnected( position )
|
||||
|| (item->GetFlags() & SKIP_STRUCT) || item->IsUnconnected() )
|
||||
continue;
|
||||
|
||||
if( item->IsSelected() && item->Type() != SCH_LINE_T )
|
||||
continue;
|
||||
|
||||
if( item->GetLayer() != aItem->GetLayer() )
|
||||
if( !item->IsConnectable() || ( item->GetFlags() & SKIP_STRUCT )
|
||||
|| !item->CanConnect( aItem ) || item == aItem )
|
||||
continue;
|
||||
|
||||
// A line having 2 ends, it can be tested twice: one time per end
|
||||
if( item->Type() == SCH_LINE_T )
|
||||
{
|
||||
if( ! item->IsSelected() ) // First time this line is tested
|
||||
item->SetFlags( SELECTED | STARTPOINT | ENDPOINT );
|
||||
else // second time (or more) this line is tested
|
||||
addinlist = false;
|
||||
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
|
||||
if( !item->HitTest( position ) )
|
||||
continue;
|
||||
|
||||
// First time through. Flags set to denote an end that is not moving
|
||||
if( !item->IsSelected() )
|
||||
item->SetFlags( CANDIDATE | STARTPOINT | ENDPOINT );
|
||||
|
||||
if( line->GetStartPoint() == position )
|
||||
item->ClearFlags( STARTPOINT );
|
||||
else if( line->GetEndPoint() == position )
|
||||
item->ClearFlags( ENDPOINT );
|
||||
else
|
||||
// This picks up items such as labels that can connect to the middle of a line
|
||||
item->ClearFlags( STARTPOINT | ENDPOINT );
|
||||
}
|
||||
else
|
||||
item->SetFlags( SELECTED );
|
||||
|
||||
if( addinlist )
|
||||
// We want to move a mid-connected label or bus entry when the full line is being moved
|
||||
else if( !item->IsSelected()
|
||||
&& aItem->Type() == SCH_LINE_T
|
||||
&& !( aItem->GetFlags() & ( ENDPOINT | STARTPOINT ) ) )
|
||||
{
|
||||
std::vector< wxPoint > connections;
|
||||
item->GetConnectionPoints( connections );
|
||||
|
||||
for( auto conn : connections )
|
||||
{
|
||||
if( aItem->HitTest( conn ) )
|
||||
{
|
||||
item->SetFlags( CANDIDATE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( item->IsSelected() )
|
||||
continue;
|
||||
|
||||
if( ( item->GetFlags() & CANDIDATE ) || item->IsConnected( position ) ) // Deal with all non-line items
|
||||
{
|
||||
item->ClearFlags( CANDIDATE );
|
||||
item->SetFlags( SELECTED );
|
||||
picker.SetItem( item );
|
||||
picker.SetFlags( item->GetFlags() );
|
||||
m_BlockLocate.GetItems().PushItem( picker );
|
||||
}
|
||||
|
|
|
@ -524,6 +524,13 @@ public:
|
|||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
|
||||
( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS ) ||
|
||||
( aItem->Type() == SCH_NO_CONNECT_T );
|
||||
}
|
||||
|
||||
void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
|
||||
|
||||
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||
|
|
|
@ -239,6 +239,12 @@ public:
|
|||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return aItem->Type() == SCH_LINE_T &&
|
||||
( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
|
||||
}
|
||||
|
||||
wxString GetSelectMenuText() const override;
|
||||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
@ -285,6 +291,12 @@ public:
|
|||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return aItem->Type() == SCH_LINE_T &&
|
||||
( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
|
||||
}
|
||||
|
||||
wxString GetSelectMenuText() const override;
|
||||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
@ -331,6 +343,12 @@ public:
|
|||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
bool CanConnect( const SCH_ITEM* aItem ) const override
|
||||
{
|
||||
return aItem->Type() == SCH_LINE_T &&
|
||||
( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
|
||||
}
|
||||
|
||||
wxString GetSelectMenuText() const override;
|
||||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
|
Loading…
Reference in New Issue