kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #18503
Re: [PATCH] Hide pin targets when properly connected
Almost no work at all - here you go.
On Sun, Jun 07, 2015 at 07:49:58PM -0400, Wayne Stambaugh wrote:
> If you have the time and can get too it in the not too distant future,
> then please do. I think this would be a nice addition to your patch. I
> will go ahead and commit this patch along with the refresh patch that
> goes along with it for now.
>
> On 6/7/2015 6:14 PM, Chris Pavlina wrote:
> > I could add this too.
> >
> > On Sun, Jun 07, 2015 at 05:44:09PM -0400, Wayne Stambaugh wrote:
> >> One thing I did notice is that bus entries do not draw the connection
> >> point so they cannot show their connection status. It would be nice if
> >> bus entries exhibited the same behavior. I'm not sure how much work
> >> would be involved. I'm surprised I never noticed that before or AFAIR
> >> no one has every said anything about it.
> >>
> >> On 6/4/2015 6:21 PM, Chris Pavlina wrote:
> >>> Recently a proposal was made on Launchpad for pins to indicate when they
> >>> are connected: https://bugs.launchpad.net/kicad/+bug/1458083
> >>>
> >>> Sounds like a good idea to me; I recently asked on the list, and on both
> >>> list and Launchpad there is general agreement that the second proposal
> >>> (hide the pin target after the connection is made) was best. Here's a
> >>> patch to do this.
> >>>
> >>> IMO it makes the schematic look a lot cleaner in addition to helping
> >>> make sure the schematic is connected correctly :)
> >>>
> >>> --
> >>> Chris
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Mailing list: https://launchpad.net/~kicad-developers
> >>> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> >>> Unsubscribe : https://launchpad.net/~kicad-developers
> >>> More help : https://help.launchpad.net/ListHelp
> >>>
> >>
> >>
> >> _______________________________________________
> >> Mailing list: https://launchpad.net/~kicad-developers
> >> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> >> Unsubscribe : https://launchpad.net/~kicad-developers
> >> More help : https://help.launchpad.net/ListHelp
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~kicad-developers
> > Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~kicad-developers
> > More help : https://help.launchpad.net/ListHelp
> >
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
commit a646e6c4b1a9ef624b4f56101d3a55f747558bf2
Author: Chris Pavlina <cpavlin1@xxxxxxxxxxxxxx>
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; }
References