Eeschema: fix connection indicator. (fixes lp:1476005).
* When multiple pins are in the same position and one is not connected, show connection indicator correctly. * LIB_PIN::IsVisible should be a const method so it can be called on DANGLING_END_ITEM children without having to discard const. * Test the (!IsVisible() && GetType() == PIN_POWER_IN) condition in a method LIB_PIN::IsPowerConnection to avoid duplicating that condition if the test needs to be performed in more than one place. (e.g. dunderheads like myself might forget about the necessary GetType() == PIN_POWER_IN and just check visibility.) * Coding style fix: break a couple lines that were above the 99-column maximum. * Add and/or improve Doxygen comments on SCH_COMPONENT::IsPinDanglingStateChanged and SCH_COMPONENT::IsDanglingStateChanged.
This commit is contained in:
parent
5013fa2c2f
commit
e94ebf561e
|
@ -383,7 +383,13 @@ public:
|
||||||
*
|
*
|
||||||
* @return True if draw object is visible otherwise false.
|
* @return True if draw object is visible otherwise false.
|
||||||
*/
|
*/
|
||||||
bool IsVisible() { return ( m_attributes & PIN_INVISIBLE ) == 0; }
|
bool IsVisible() const { return ( m_attributes & PIN_INVISIBLE ) == 0; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether this pin forms an implicit power connection: i.e., is hidden
|
||||||
|
* and of type POWER_IN.
|
||||||
|
*/
|
||||||
|
bool IsPowerConnection() const { return !IsVisible() && GetType() == PIN_POWER_IN; }
|
||||||
|
|
||||||
int GetPenSize() const;
|
int GetPenSize() const;
|
||||||
|
|
||||||
|
|
|
@ -1628,9 +1628,11 @@ void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_COMPONENT::IsPinDanglingStateChanged( std::vector<DANGLING_END_ITEM> &aItemList, LIB_PINS& aLibPins, unsigned aPin )
|
bool SCH_COMPONENT::IsPinDanglingStateChanged( std::vector<DANGLING_END_ITEM> &aItemList,
|
||||||
|
LIB_PINS& aLibPins, unsigned aPin )
|
||||||
{
|
{
|
||||||
bool previousState;
|
bool previousState;
|
||||||
|
|
||||||
if( aPin < m_isDangling.size() )
|
if( aPin < m_isDangling.size() )
|
||||||
{
|
{
|
||||||
previousState = m_isDangling[aPin];
|
previousState = m_isDangling[aPin];
|
||||||
|
@ -1646,8 +1648,20 @@ bool SCH_COMPONENT::IsPinDanglingStateChanged( std::vector<DANGLING_END_ITEM> &a
|
||||||
|
|
||||||
BOOST_FOREACH( DANGLING_END_ITEM& each_item, aItemList )
|
BOOST_FOREACH( DANGLING_END_ITEM& each_item, aItemList )
|
||||||
{
|
{
|
||||||
if( each_item.GetItem() == aLibPins[aPin] )
|
// Some people like to stack pins on top of each other in a symbol to indicate
|
||||||
|
// internal connection. While technically connected, it is not particularly useful
|
||||||
|
// to display them that way, so skip any pins that are in the same symbol as this
|
||||||
|
// one.
|
||||||
|
//
|
||||||
|
// Do not make this exception for hidden pins, because those actually make internal
|
||||||
|
// connections to a power net.
|
||||||
|
const LIB_PIN* item_pin = dynamic_cast<const LIB_PIN*>( each_item.GetItem() );
|
||||||
|
|
||||||
|
if( item_pin
|
||||||
|
&& !item_pin->IsPowerConnection()
|
||||||
|
&& std::find( aLibPins.begin(), aLibPins.end(), item_pin) != aLibPins.end() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch( each_item.GetType() )
|
switch( each_item.GetType() )
|
||||||
{
|
{
|
||||||
case PIN_END:
|
case PIN_END:
|
||||||
|
@ -1869,7 +1883,7 @@ void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||||
|
|
||||||
aNetListItems.push_back( item );
|
aNetListItems.push_back( item );
|
||||||
|
|
||||||
if( ( (int) pin->GetType() == (int) PIN_POWER_IN ) && !pin->IsVisible() )
|
if( pin->IsPowerConnection() )
|
||||||
{
|
{
|
||||||
// There is an associated PIN_LABEL.
|
// There is an associated PIN_LABEL.
|
||||||
item = new NETLIST_OBJECT();
|
item = new NETLIST_OBJECT();
|
||||||
|
|
|
@ -402,12 +402,30 @@ public:
|
||||||
void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList );
|
void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if the component's dangling state has changed for one given pin index.
|
* Test if the component's dangling state has changed for one given pin index. As
|
||||||
|
* a side effect, actually update the dangling status for that pin.
|
||||||
|
*
|
||||||
|
* @param aItemList - list of all DANGLING_END_ITEMs to be tested
|
||||||
|
* @param aLibPins - list of all the LIB_PIN items in this component's symbol
|
||||||
|
* @param aPin - index into aLibPins that identifies the pin to test
|
||||||
|
* @return true if the pin's state has changed.
|
||||||
*/
|
*/
|
||||||
bool IsPinDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList, LIB_PINS& aLibPins, unsigned aPin );
|
bool IsPinDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList,
|
||||||
|
LIB_PINS& aLibPins, unsigned aPin );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the component's dangling state has changed for all pins. As a side
|
||||||
|
* effect, actually update the dangling status for all pins (does not short-circuit).
|
||||||
|
*
|
||||||
|
* @param aItemList - list of all DANGLING_END_ITEMs to be tested
|
||||||
|
* @return true if any pin's state has changed.
|
||||||
|
*/
|
||||||
bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList );
|
bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether any pin has dangling status. Does NOT update the internal status,
|
||||||
|
* only checks the existing status.
|
||||||
|
*/
|
||||||
bool IsDangling() const;
|
bool IsDangling() const;
|
||||||
|
|
||||||
wxPoint GetPinPhysicalPosition( LIB_PIN* Pin );
|
wxPoint GetPinPhysicalPosition( LIB_PIN* Pin );
|
||||||
|
|
Loading…
Reference in New Issue