Hi, I already sent in this patch but as a reply to my existing pin targets thread; I think it may have got lost. This patch enables pin "targets" on bus entries as well, as Wayne suggested, and hides them when the bus entry is connected.
-- Chris
commit a646e6c4b1a9ef624b4f56101d3a55f747558bf2 Author: Chris Pavlina <cpavl...@binghamton.edu> Date: Sun Jun 7 22:02:45 2015 -0400 Show targets on bus entries diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 227f88a..6b3e3b6 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -35,6 +35,7 @@ #include <common.h> #include <richio.h> #include <plot_common.h> +#include <boost/foreach.hpp> #include <eeschema_config.h> #include <general.h> @@ -182,6 +183,7 @@ void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor ) { EDA_COLOR_T color; + EDA_RECT* clipbox = aPanel->GetClipBox(); if( aColor >= 0 ) color = aColor; @@ -190,8 +192,16 @@ void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& GRSetDrawMode( aDC, aDrawMode ); - GRLine( aPanel->GetClipBox(), aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, + GRLine( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, m_End().x + aOffset.x, m_End().y + aOffset.y, GetPenSize(), color ); + + if( m_isDanglingStart ) { + GRCircle( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, TARGET_BUSENTRY_RADIUS, 0, color ); + } + + if( m_isDanglingEnd ) { + GRCircle( clipbox, aDC, m_End().x + aOffset.x, m_End().y + aOffset.y, TARGET_BUSENTRY_RADIUS, 0, color ); + } } @@ -230,6 +240,50 @@ void SCH_BUS_ENTRY_BASE::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemLi } +bool SCH_BUS_ENTRY_BASE::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ) +{ + bool previousStateStart = m_isDanglingStart; + bool previousStateEnd = m_isDanglingEnd; + + m_isDanglingStart = m_isDanglingEnd = true; + + // Wires and buses are stored in the list as a pair, start and end. This + // variable holds the start position from one iteration so it can be used + // when the end position is found. + wxPoint seg_start; + + BOOST_FOREACH( DANGLING_END_ITEM& each_item, aItemList ) + { + if( each_item.GetItem() == this ) + continue; + + switch( each_item.GetType() ) + { + case WIRE_START_END: + case BUS_START_END: + seg_start = each_item.GetPosition(); + break; + case WIRE_END_END: + case BUS_END_END: + if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_pos ) ) + m_isDanglingStart = false; + if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_End() ) ) + m_isDanglingEnd = false; + default: + break; + } + } + + return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd); +} + + +bool SCH_BUS_ENTRY_BASE::IsDangling() const +{ + return m_isDanglingStart || m_isDanglingEnd; +} + + bool SCH_BUS_ENTRY_BASE::IsSelectStateChanged( const wxRect& aRect ) { bool previousState = IsSelected(); diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 09e1007..5de14e6 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -32,6 +32,8 @@ #include <sch_item_struct.h> +#define TARGET_BUSENTRY_RADIUS 12 // Circle diameter drawn at the ends + /** * Class SCH_BUS_ENTRY_BASE @@ -43,6 +45,7 @@ class SCH_BUS_ENTRY_BASE : public SCH_ITEM protected: wxPoint m_pos; wxSize m_size; + bool m_isDanglingStart, m_isDanglingEnd; public: SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' ); @@ -100,6 +103,10 @@ public: void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ); + bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ); + + bool IsDangling() const; + bool IsSelectStateChanged( const wxRect& aRect ); bool IsConnectable() const { return true; }
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp