Eeschema: Correct wire/bus/entry connections

Fixes the connection display and dragging behavior of wires,
busses and their entries.

The implemented drag logic is:
-busses and bus-bus entries drag each other when connected at endpoints
-wires and wire-bus entries drag each other when connected at endpoints
-entries do not drag wires or busses when connected to wire middles
-wire-bus entries do not drag busses

The implemented connection logic is:
-bus-bus entries connect busses to busses but not wires
-wire-bus entries connect wires to busses but not wire to wires or
busses to busses
This commit is contained in:
Seth Hillbrand 2017-11-30 17:21:23 -08:00 committed by Wayne Stambaugh
parent cd3122d8cd
commit bdc1fb04be
6 changed files with 54 additions and 18 deletions

View File

@ -92,9 +92,10 @@ private:
* \a aPosition and adds them to the block selection pick list. This is used when a block
* drag is being performed to ensure connections to items in the block are not lost.
*</p>
* @param aItem = The item we are connecting from
* @param aPosition = The connection point to test.
*/
void addConnectedItemsToBlock( const wxPoint& aPosition );
void addConnectedItemsToBlock( const SCH_ITEM* aItem, const wxPoint& aPosition );
public:

View File

@ -78,6 +78,12 @@ EDA_ITEM* SCH_BUS_BUS_ENTRY::Clone() const
}
bool SCH_BUS_ENTRY_BASE::doIsConnected( const wxPoint& aPosition ) const
{
return ( m_pos == aPosition || m_End() == aPosition );
}
wxPoint SCH_BUS_ENTRY_BASE::m_End() const
{
return wxPoint( m_pos.x + m_size.x, m_pos.y + m_size.y );
@ -120,6 +126,26 @@ int SCH_BUS_BUS_ENTRY::GetPenSize() const
}
void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
{
DANGLING_END_ITEM item( WIRE_ENTRY_END, this, m_pos );
aItemList.push_back( item );
DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, m_End() );
aItemList.push_back( item1 );
}
void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
{
DANGLING_END_ITEM item( BUS_ENTRY_END, this, m_pos );
aItemList.push_back( item );
DANGLING_END_ITEM item1( BUS_ENTRY_END, this, m_End() );
aItemList.push_back( item1 );
}
void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
@ -175,16 +201,6 @@ void SCH_BUS_ENTRY_BASE::Rotate( wxPoint aPosition )
}
void SCH_BUS_ENTRY_BASE::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
{
DANGLING_END_ITEM item( ENTRY_END, this, m_pos );
aItemList.push_back( item );
DANGLING_END_ITEM item1( ENTRY_END, this, m_End() );
aItemList.push_back( item1 );
}
bool SCH_BUS_ENTRY_BASE::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList )
{
bool previousStateStart = m_isDanglingStart;

View File

@ -97,12 +97,12 @@ public:
void Rotate( wxPoint aPosition ) override;
void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ) override;
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; }
@ -122,6 +122,9 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
private:
bool doIsConnected( const wxPoint& aPosition ) const override;
};
/**
@ -141,6 +144,8 @@ public:
int GetPenSize() const override;
void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
wxString GetSelectMenuText() const override;
EDA_ITEM* Clone() const override;
@ -165,6 +170,8 @@ public:
int GetPenSize() const override;
void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
wxString GetSelectMenuText() const override;
EDA_ITEM* Clone() const override;

View File

@ -63,7 +63,8 @@ enum DANGLING_END_T {
JUNCTION_END,
PIN_END,
LABEL_END,
ENTRY_END,
BUS_ENTRY_END,
WIRE_ENTRY_END,
SHEET_LABEL_END,
NO_CONNECT_END,
};
@ -253,6 +254,8 @@ public:
virtual bool IsDangling() const { return false; }
virtual bool IsUnconnected() const { return false; }
/**
* Function IsSelectStateChanged
* checks if the selection state of an item inside \a aRect has changed.

View File

@ -509,7 +509,10 @@ bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
if( item.GetItem() == this )
continue;
if( item.GetType() == NO_CONNECT_END )
if( item.GetType() == NO_CONNECT_END ||
item.GetType() == BUS_START_END ||
item.GetType() == BUS_END_END ||
item.GetType() == BUS_ENTRY_END )
continue;
if( m_start == item.GetPosition() )

View File

@ -717,7 +717,7 @@ void SCH_SCREEN::SelectBlockItems()
std::vector< wxPoint > connections;
item->GetConnectionPoints( connections );
for( auto conn : connections )
addConnectedItemsToBlock( conn );
addConnectedItemsToBlock( item, conn );
};
PICKED_ITEMS_LIST* pickedlist = &m_BlockLocate.GetItems();
@ -785,23 +785,29 @@ void SCH_SCREEN::SelectBlockItems()
}
void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position )
void SCH_SCREEN::addConnectedItemsToBlock( const SCH_ITEM* aItem, const wxPoint& position )
{
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->GetFlags() & SKIP_STRUCT) || item->IsUnconnected() )
continue;
if( item->IsSelected() && item->Type() != SCH_LINE_T )
continue;
if( item->GetLayer() != aItem->GetLayer() )
continue;
// A line having 2 ends, it can be tested twice: one time per end
if( item->Type() == SCH_LINE_T )
{