← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Don't draw invisible pins in component chooser

 

Hi Orson, patch is attached again, hopefully it goes through this time.

Thanks,
Jon

On Mon, Jan 15, 2018 at 4:24 AM, Rene Pöschl <poeschlr@xxxxxxxxx> wrote:

> On 15/01/18 10:00, Maciej Sumiński wrote:
>
>> Perhaps we should have an ERC rule
>> that warns about invisible pins being connected to a wire, any thoughts?
>>
>
> Invisible pins are used for three distinct applications.
>
> The first one is to remove clutter by hiding pins that should not be
> connected. ERC will complain if you connect such pins if they have the
> electrical type "Not connected".
>
> The second application is to create "power labels". A invisible power
> input pin is handled as a global label. These pins are meant to be
> connected.
>
> The third application is again to remove clutter by stacking pins. Here
> you have one visible pin and several other invisible pins at the same
> location. (Normally all these pins have the same name and electrical
> type. With the exception of power input pins, power output pins and
> output pins.)
> Such pins are again meant to be connected.
>
> This means a ERC rule that complains about connecting hidden pins will
> create too many false positives. Having a lot of false positives means
> users will start to ignore ERC output.
>
> It might be a good idea to have a symbol checker that complains if
> invisible pins are used differently than i described above.
> In other words: complain for invisible pins if they are not part of a
> stack or of types NC or power input.
>
>
>
>
> _______________________________________________
> 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
>
From cc08130759a8eb0ae8f9553038a369a028797814 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Wed, 10 Jan 2018 23:10:08 -0500
Subject: [PATCH] Don't draw invisible pins in component chooser

Fixes: lp:1742485
* https://bugs.launchpad.net/kicad/+bug/1742485
---
 eeschema/class_libentry.cpp                  | 3 +++
 eeschema/class_libentry.h                    | 2 ++
 eeschema/dialogs/dialog_choose_component.cpp | 1 +
 eeschema/lib_pin.cpp                         | 6 ++++--
 eeschema/lib_pin.h                           | 5 +++--
 5 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp
index 434af8628..f81c11802 100644
--- a/eeschema/class_libentry.cpp
+++ b/eeschema/class_libentry.cpp
@@ -391,6 +391,9 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
             if( pin.IsPowerConnection() && IsPower() )
                 flags |= PIN_DANGLING_HIDDEN;
 
+            if( aOpts.draw_invisible_pins )
+                flags |= PIN_DRAW_INVISIBLE_PINS;
+
             drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
                            aOpts.draw_mode, (void*) flags, aOpts.transform );
 
diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h
index af546123e..0bff3b2d2 100644
--- a/eeschema/class_libentry.h
+++ b/eeschema/class_libentry.h
@@ -180,6 +180,7 @@ struct PART_DRAW_OPTIONS
     bool only_selected;         ///< Draws only the body items that are selected, for block moves
     std::vector<bool> dangling; ///< which pins should display as dangling, or empty for All
     bool show_elec_type;        ///< Whether to show the pin electrical type
+    bool draw_invisible_pins;   ///< Whether to draw invisible pins
 
     static PART_DRAW_OPTIONS Default()
     {
@@ -192,6 +193,7 @@ struct PART_DRAW_OPTIONS
         def.draw_hidden_fields  = true;
         def.only_selected       = false;
         def.show_elec_type      = false;
+        def.draw_invisible_pins = true;
         return def;
     }
 
diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp
index ad9dc2deb..c43bd3bec 100644
--- a/eeschema/dialogs/dialog_choose_component.cpp
+++ b/eeschema/dialogs/dialog_choose_component.cpp
@@ -496,5 +496,6 @@ void DIALOG_CHOOSE_COMPONENT::RenderPreview( LIB_PART* aComponent, int aUnit )
 
     auto opts = PART_DRAW_OPTIONS::Default();
     opts.draw_hidden_fields = false;
+    opts.draw_invisible_pins = false;
     aComponent->Draw( nullptr, &dc, offset, unit, convert, opts );
 }
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index d9255d054..c451ed64e 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -581,6 +581,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL*  aPanel,
     bool drawPinDangling = flags & PIN_DRAW_DANGLING;
     bool drawDanglingHidden = flags & PIN_DANGLING_HIDDEN;
     bool drawElectricalTypeName = flags & PIN_DRAW_ELECTRICAL_TYPE_NAME;
+    bool drawInvisiblePins = flags & PIN_DRAW_INVISIBLE_PINS;
 
     LIB_PART* Entry = GetParent();
 
@@ -601,8 +602,9 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL*  aPanel,
         if( aPanel && aPanel->GetParent() )
             frame = (EDA_DRAW_FRAME*)aPanel->GetParent();
 
-        if( frame && frame->IsType( FRAME_SCH ) &&
-            ! ((SCH_EDIT_FRAME*)frame)->GetShowAllPins() )
+        if( ( frame && frame->IsType( FRAME_SCH ) &&
+              ! ((SCH_EDIT_FRAME*)frame)->GetShowAllPins() ) ||
+            !drawInvisiblePins )
         {
             if( drawPinDangling && drawDanglingHidden )
             {
diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h
index cbea6c4f9..b021638ff 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -60,8 +60,9 @@ enum LibPinDrawFlags {
     PIN_DRAW_TEXTS = 1,
     PIN_DRAW_DANGLING = 2,      // Draw this pin with a 'dangling' indicator
     PIN_DANGLING_HIDDEN = 4,    // Draw (only!) the dangling indicator if the pin is hidden
-    PIN_DRAW_ELECTRICAL_TYPE_NAME = 8   // Draw the pin electrical type name
-                                        // used only in component editor and component viewer
+    PIN_DRAW_ELECTRICAL_TYPE_NAME = 8,   // Draw the pin electrical type name
+                                         // used only in component editor and component viewer
+    PIN_DRAW_INVISIBLE_PINS = 16    // Draw invisible pins
 };
 
 
-- 
2.14.1


Follow ups

References