diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 5d7c19027a..1d49ea3e42 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -384,6 +384,8 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, if( drawItem.Type() == LIB_PIN_T ) { + LIB_PIN& pin = dynamic_cast( drawItem ); + uintptr_t flags = 0; if( aShowPinText ) flags |= PIN_DRAW_TEXTS; @@ -391,6 +393,9 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, if( !aPinsDangling || (aPinsDangling->size() > pin_index && (*aPinsDangling)[pin_index] ) ) flags |= PIN_DRAW_DANGLING; + if( pin.IsPowerConnection() && IsPower() ) + flags |= PIN_DANGLING_HIDDEN; + drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) flags, aTransform ); ++pin_index; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 8a21b8403f..5488c9eaf4 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -857,6 +857,20 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, void* aData, const TRANSFORM& aTransform ) { + // aData is used here as a bitfield of flags. + uintptr_t flags = (uintptr_t) aData; + bool drawPinText = flags & PIN_DRAW_TEXTS; + bool drawPinDangling = flags & PIN_DRAW_DANGLING; + bool drawDanglingHidden = flags & PIN_DANGLING_HIDDEN; + + LIB_PART* Entry = GetParent(); + + /* Calculate pin orient taking in account the component orientation. */ + int orient = PinDrawOrient( aTransform ); + + /* Calculate the pin position */ + wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset; + // Invisible pins are only drawn on request. // They are drawn in GetInvisibleItemColor(). // in schematic, they are drawn only if m_showAllPins is true. @@ -870,24 +884,19 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, if( frame && frame->IsType( FRAME_SCH ) && ! ((SCH_EDIT_FRAME*)frame)->GetShowAllPins() ) + { + if( drawPinDangling && drawDanglingHidden ) + { + // Draw the target + DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor, drawPinDangling, + /* aOnlyTarget */ true ); + } return; + } aColor = GetInvisibleItemColor(); } - LIB_PART* Entry = GetParent(); - - // aData is used here as a bitfield of flags. - uintptr_t flags = (uintptr_t) aData; - bool drawPinText = flags & PIN_DRAW_TEXTS; - bool drawPinDangling = flags & PIN_DRAW_DANGLING; - - /* Calculate pin orient taking in account the component orientation. */ - int orient = PinDrawOrient( aTransform ); - - /* Calculate the pin position */ - wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset; - /* Drawing from the pin and the special symbol combination */ DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor, drawPinDangling ); @@ -916,7 +925,8 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, int aOrient, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor, - bool aDrawDangling ) + bool aDrawDangling, + bool aOnlyTarget ) { int MapX1, MapY1, x1, y1; int width = GetPenSize(); @@ -962,6 +972,21 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, break; } + // Draw the pin end target (active end of the pin) + BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL; + #define NCSYMB_PIN_DIM TARGET_PIN_RADIUS + + // Draw but do not print the pin end target 1 pixel width + if( m_type != PIN_NC && ( screen == NULL || !screen->m_IsPrinting ) ) + { + if( aDrawDangling ) + GRCircle( clipbox, aDC, posX, posY, TARGET_PIN_RADIUS, 0, color ); + } + + if( aOnlyTarget ) + return; + + if( m_shape & INVERT ) { const int radius = ExternalPinDecoSize( *this ); @@ -1079,10 +1104,6 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, width, color ); } - // Draw the pin end target (active end of the pin) - BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL; - #define NCSYMB_PIN_DIM TARGET_PIN_RADIUS - if( m_type == PIN_NC ) // Draw a N.C. symbol { GRLine( clipbox, aDC, @@ -1094,12 +1115,6 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, posX - NCSYMB_PIN_DIM, posY + NCSYMB_PIN_DIM, width, color ); } - // Draw but do not print the pin end target 1 pixel width - else if( screen == NULL || !screen->m_IsPrinting ) - { - if( aDrawDangling ) - GRCircle( clipbox, aDC, posX, posY, TARGET_PIN_RADIUS, 0, color ); - } } diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index ebd50e53fc..6cf68015c7 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -84,7 +84,8 @@ enum DrawPinOrient { enum LibPinDrawFlags { PIN_DRAW_TEXTS = 1, - PIN_DRAW_DANGLING = 2, + 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 }; @@ -114,7 +115,8 @@ class LIB_PIN : public LIB_ITEM * @param aDrawMode GR_OR, GR_XOR, ... * @param aData = used here as uintptr_t containing bitwise OR'd flags: * PIN_DRAW_TEXTS, -- false to draw only pin shape, useful for fast mode - * PIN_DRAW_DANGLING, + * PIN_DRAW_DANGLING, -- true to draw the pin with its target + * PIN_DANGLING_HIDDEN -- draw the target even if the pin is hidden * @param aTransform Transform Matrix (rotation, mirror ..) */ void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, @@ -401,7 +403,8 @@ public: void DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, int aOrientation, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR, - bool aDrawDangling = true ); + bool aDrawDangling = true, + bool aOnlyTarget = false ); /** * Function DrawPinTexts diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index edd2d663a8..938b4222d7 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1658,7 +1658,7 @@ bool SCH_COMPONENT::IsPinDanglingStateChanged( std::vector &a const LIB_PIN* item_pin = dynamic_cast( each_item.GetItem() ); if( item_pin - && !item_pin->IsPowerConnection() + && ( !item_pin->IsPowerConnection() || !IsInNetlist() ) && std::find( aLibPins.begin(), aLibPins.end(), item_pin) != aLibPins.end() ) continue;