Add pins to net highlighting.
Fixes: lp:1763873 * https://bugs.launchpad.net/kicad/+bug/1763873
This commit is contained in:
parent
8a9b82c2a2
commit
52246121b9
|
@ -32,6 +32,7 @@
|
|||
#include <sch_view.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_component.h>
|
||||
#include <erc.h>
|
||||
|
||||
#include <netlist_object.h>
|
||||
|
@ -93,38 +94,54 @@ bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags( std::vector<EDA_ITEM*>* aIte
|
|||
if( !screen )
|
||||
return true;
|
||||
|
||||
// Disable highlight flag on all items in the current screen
|
||||
for( SCH_ITEM* ptr = screen->GetDrawItems(); ptr; ptr = ptr->Next() )
|
||||
{
|
||||
auto conn = ptr->Connection( *g_CurrentSheet );
|
||||
bool bright = ptr->GetState( BRIGHTENED );
|
||||
|
||||
if( bright && aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( ptr );
|
||||
bool redraw = ptr->GetState( BRIGHTENED );
|
||||
|
||||
ptr->SetState( BRIGHTENED, ( conn && conn->Name() == m_SelectedNetName ) );
|
||||
|
||||
if( !bright && ptr->GetState( BRIGHTENED ) && aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( ptr );
|
||||
redraw |= ptr->GetState( BRIGHTENED );
|
||||
|
||||
if( ptr->Type() == SCH_SHEET_T )
|
||||
if( ptr->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( ptr );
|
||||
|
||||
redraw |= comp->HasBrightenedPins();
|
||||
|
||||
comp->ClearBrightenedPins();
|
||||
std::vector<LIB_PIN*> pins;
|
||||
comp->GetPins( pins );
|
||||
|
||||
for( LIB_PIN* pin : pins )
|
||||
{
|
||||
auto pin_conn = comp->GetConnectionForPin( pin, *g_CurrentSheet );
|
||||
|
||||
if( pin_conn && pin_conn->Name( false, true ) == m_SelectedNetName )
|
||||
{
|
||||
comp->BrightenPin( pin );
|
||||
redraw = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( ptr->Type() == SCH_SHEET_T )
|
||||
{
|
||||
for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( ptr )->GetPins() )
|
||||
{
|
||||
auto pin_conn = pin.Connection( *g_CurrentSheet );
|
||||
bool redrawPin = pin.GetState( BRIGHTENED );
|
||||
|
||||
bright = pin.GetState( BRIGHTENED );
|
||||
pin.SetState( BRIGHTENED, ( pin_conn && pin_conn->Name() == m_SelectedNetName ) );
|
||||
|
||||
if( bright && aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( &pin );
|
||||
redrawPin |= pin.GetState( BRIGHTENED );
|
||||
|
||||
pin.SetState( BRIGHTENED, ( pin_conn &&
|
||||
pin_conn->Name() == m_SelectedNetName ) );
|
||||
|
||||
if( !bright && pin.GetState( BRIGHTENED ) && aItemsToRedrawList )
|
||||
if( redrawPin && aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( &pin );
|
||||
}
|
||||
}
|
||||
|
||||
if( redraw && aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( ptr );
|
||||
}
|
||||
|
||||
if( m_SelectedNetName == "" )
|
||||
|
|
|
@ -1774,14 +1774,10 @@ void LIB_PIN::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >
|
|||
|
||||
#if defined(DEBUG)
|
||||
|
||||
if( auto pin_connection = aComponent->GetConnectionForPin( this ) )
|
||||
{
|
||||
auto conn = pin_connection->Connection( *g_CurrentSheet );
|
||||
|
||||
wxASSERT( conn );
|
||||
auto conn = aComponent->GetConnectionForPin( this, *g_CurrentSheet );
|
||||
|
||||
if( conn )
|
||||
conn->AppendDebugInfoToMsgPanel( aList );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -566,17 +566,17 @@ void SCH_COMPONENT::UpdatePinConnections( SCH_SHEET_PATH aSheet )
|
|||
}
|
||||
|
||||
|
||||
SCH_PIN_CONNECTION* SCH_COMPONENT::GetConnectionForPin( LIB_PIN* aPin )
|
||||
SCH_CONNECTION* SCH_COMPONENT::GetConnectionForPin( LIB_PIN* aPin, const SCH_SHEET_PATH& aSheet )
|
||||
{
|
||||
try
|
||||
if( m_pin_connections.count( aPin ) )
|
||||
{
|
||||
return m_pin_connections.at( aPin );
|
||||
}
|
||||
catch( const std::out_of_range& oor )
|
||||
{
|
||||
return nullptr;
|
||||
SCH_PIN_CONNECTION* pin_conn = m_pin_connections.at( aPin );
|
||||
|
||||
if( pin_conn )
|
||||
return pin_conn->Connection( aSheet );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2028,6 +2028,30 @@ void SCH_COMPONENT::Plot( PLOTTER* aPlotter )
|
|||
}
|
||||
|
||||
|
||||
bool SCH_COMPONENT::HasBrightenedPins()
|
||||
{
|
||||
return m_brightenedPins.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::ClearBrightenedPins()
|
||||
{
|
||||
m_brightenedPins.clear();
|
||||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::BrightenPin( LIB_PIN* aPin )
|
||||
{
|
||||
m_brightenedPins.insert( aPin->GetNumber() );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_COMPONENT::IsPinBrightened( const LIB_PIN* aPin )
|
||||
{
|
||||
return m_brightenedPins.find( aPin->GetNumber() ) != m_brightenedPins.end();
|
||||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::ClearHighlightedPins()
|
||||
{
|
||||
m_highlightedPins.clear();
|
||||
|
|
|
@ -96,6 +96,7 @@ private:
|
|||
std::vector<bool> m_isDangling; ///< One isDangling per pin
|
||||
std::vector<wxPoint> m_Pins;
|
||||
std::set<wxString> m_highlightedPins; ///< God forgive me - Tom
|
||||
std::set<wxString> m_brightenedPins; ///< ... and me too - Jeff
|
||||
|
||||
AUTOPLACED m_fieldsAutoplaced; ///< indicates status of field autoplacement
|
||||
|
||||
|
@ -221,9 +222,9 @@ public:
|
|||
void UpdatePinConnections( SCH_SHEET_PATH aSheet );
|
||||
|
||||
/**
|
||||
* Retrieves the pin connection for a given pin of the component
|
||||
* Retrieves the connection for a given pin of the component
|
||||
*/
|
||||
SCH_PIN_CONNECTION* GetConnectionForPin( LIB_PIN* aPin );
|
||||
SCH_CONNECTION* GetConnectionForPin( LIB_PIN* aPin, const SCH_SHEET_PATH& aSheet );
|
||||
|
||||
const std::unordered_map<LIB_PIN*, SCH_PIN_CONNECTION*>& PinConnections()
|
||||
{
|
||||
|
@ -662,6 +663,14 @@ public:
|
|||
void Show( int nestLevel, std::ostream& os ) const override;
|
||||
#endif
|
||||
|
||||
void ClearBrightenedPins();
|
||||
|
||||
bool HasBrightenedPins();
|
||||
|
||||
void BrightenPin( LIB_PIN* aPin );
|
||||
|
||||
bool IsPinBrightened( const LIB_PIN* aPin );
|
||||
|
||||
void ClearHighlightedPins();
|
||||
|
||||
void HighlightPin( LIB_PIN* aPin );
|
||||
|
|
|
@ -243,7 +243,7 @@ bool SCH_CONNECTION::IsDriver() const
|
|||
}
|
||||
|
||||
|
||||
wxString SCH_CONNECTION::Name( bool aIgnoreSheet ) const
|
||||
wxString SCH_CONNECTION::Name( bool aIgnoreSheet, bool aForceSheet ) const
|
||||
{
|
||||
wxString ret = m_name + m_suffix;
|
||||
|
||||
|
@ -271,7 +271,7 @@ wxString SCH_CONNECTION::Name( bool aIgnoreSheet ) const
|
|||
}
|
||||
}
|
||||
|
||||
if( prepend_path && !aIgnoreSheet )
|
||||
if( aForceSheet || ( prepend_path && !aIgnoreSheet ) )
|
||||
ret = m_sheet.PathHumanReadable() + ret;
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
m_dirty = false;
|
||||
}
|
||||
|
||||
wxString Name( bool aIgnoreSheet = false ) const;
|
||||
wxString Name( bool aIgnoreSheet = false, bool aForceSheet = false ) const;
|
||||
|
||||
wxString Prefix() const
|
||||
{
|
||||
|
|
|
@ -540,8 +540,12 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool aIsDangling, bool isMovi
|
|||
isMoving = true;
|
||||
|
||||
VECTOR2I pos = mapCoords( aPin->GetPosition() );
|
||||
COLOR4D color;
|
||||
|
||||
COLOR4D color = getOverlayColor( aPin, m_schSettings.GetLayerColor( LAYER_PIN ), false );
|
||||
if( aPin->IsBrightened() )
|
||||
color = m_schSettings.GetLayerColor( LAYER_BRIGHTENED );
|
||||
else
|
||||
color = getOverlayColor( aPin, m_schSettings.GetLayerColor( LAYER_PIN ), false );
|
||||
|
||||
if( !aPin->IsVisible() )
|
||||
{
|
||||
|
@ -1144,10 +1148,11 @@ void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
|
|||
if( item.Type() == LIB_PIN_T )
|
||||
{
|
||||
auto pin = static_cast<LIB_PIN*>( &item );
|
||||
if( aComp->IsPinHighlighted( pin ) )
|
||||
{
|
||||
|
||||
if( aComp->IsPinBrightened( pin ) )
|
||||
pin->SetFlags( BRIGHTENED );
|
||||
else if( aComp->IsPinHighlighted( pin ) )
|
||||
pin->SetFlags( HIGHLIGHTED );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,26 +53,20 @@ wxString SCH_PIN_CONNECTION::GetDefaultNetName( const SCH_SHEET_PATH aPath )
|
|||
if( m_pin->IsPowerConnection() )
|
||||
return m_pin->GetName();
|
||||
|
||||
wxString name;
|
||||
if( m_net_name_map.count( aPath ) > 0 )
|
||||
return m_net_name_map.at( aPath );
|
||||
|
||||
try
|
||||
{
|
||||
name = m_net_name_map.at( aPath );
|
||||
}
|
||||
catch( const std::out_of_range& oor )
|
||||
{
|
||||
name = wxT( "Net-(" );
|
||||
wxString name = wxT( "Net-(" );
|
||||
|
||||
name << m_comp->GetRef( &aPath );
|
||||
name << m_comp->GetRef( &aPath );
|
||||
|
||||
// TODO(JE) do we need adoptTimestamp?
|
||||
if( /* adoptTimestamp && */ name.Last() == '?' )
|
||||
name << m_comp->GetTimeStamp();
|
||||
// TODO(JE) do we need adoptTimestamp?
|
||||
if( /* adoptTimestamp && */ name.Last() == '?' )
|
||||
name << m_comp->GetTimeStamp();
|
||||
|
||||
name << _( "-Pad" ) << m_pin->GetNumber() << _( ")" );
|
||||
name << _( "-Pad" ) << m_pin->GetNumber() << _( ")" );
|
||||
|
||||
m_net_name_map[ aPath ] = name;
|
||||
}
|
||||
m_net_name_map[ aPath ] = name;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue