eeschema: Prevent invalid '0' element in components
In the component, an m_unit/m_convert element is 1-indexed as opposed to the library where they are 0-indexed. The 0-index in the library is reserved for those elements that are shared across all conversion/unit whereas it is invalid for the component. Fixes: lp:1824764 * https://bugs.launchpad.net/kicad/+bug/1824764
This commit is contained in:
parent
9092048dbc
commit
c4be74a9d0
|
@ -986,7 +986,7 @@ bool LIB_PART::HasConversion() const
|
|||
{
|
||||
for( const LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.m_Convert > 1 )
|
||||
if( item.m_Convert > LIB_ITEM::LIB_CONVERT::BASE )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow()
|
|||
|
||||
if( m_part != nullptr && m_part->HasConversion() )
|
||||
{
|
||||
if( m_cmp->GetConvert() > 1 )
|
||||
if( m_cmp->GetConvert() > LIB_ITEM::LIB_CONVERT::BASE )
|
||||
m_cbAlternateSymbol->SetValue( true );
|
||||
}
|
||||
else
|
||||
|
@ -252,7 +252,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnBrowseLibrary( wxCommandEvent& event
|
|||
for( int ii = 1; ii <= entry->GetUnitCount(); ii++ )
|
||||
m_unitChoice->Append( LIB_PART::SubReference( ii, false ) );
|
||||
|
||||
if( unit < 0 || unit >= m_unitChoice->GetCount() )
|
||||
if( unit < 0 || static_cast<unsigned>( unit )>= m_unitChoice->GetCount() )
|
||||
unit = 0;
|
||||
|
||||
m_unitChoice->SetSelection( unit );
|
||||
|
@ -405,15 +405,15 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow()
|
|||
m_cmp->SetLibId( id, Prj().SchSymbolLibTable(), Prj().SchLibs()->GetCacheLibrary() );
|
||||
|
||||
// For symbols with multiple shapes (De Morgan representation) Set the selected shape:
|
||||
int conversion = m_cbAlternateSymbol->IsEnabled()
|
||||
? m_cbAlternateSymbol->GetValue()
|
||||
: 0;
|
||||
m_cmp->SetConvert( conversion );
|
||||
if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
|
||||
m_cmp->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN );
|
||||
else
|
||||
m_cmp->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
|
||||
|
||||
//Set the part selection in multiple part per package
|
||||
int unit_selection = m_unitChoice->IsEnabled()
|
||||
? m_unitChoice->GetSelection() + 1
|
||||
: 0;
|
||||
: 1;
|
||||
m_cmp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
|
||||
m_cmp->SetUnit( unit_selection );
|
||||
|
||||
|
|
|
@ -372,14 +372,14 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent )
|
|||
|
||||
aComponent->SetConvert( aComponent->GetConvert() + 1 );
|
||||
|
||||
// ensure m_Convert = 0, 1 or 2
|
||||
// 0 and 1 = shape 1 = not converted
|
||||
// ensure m_Convert = 1 or 2
|
||||
// 1 = shape 1 = not converted
|
||||
// 2 = shape 2 = first converted shape
|
||||
// > 2 is not used but could be used for more shapes
|
||||
// like multiple shapes for a programmable component
|
||||
// When m_Convert = val max, return to the first shape
|
||||
if( aComponent->GetConvert() > 2 )
|
||||
aComponent->SetConvert( 1 );
|
||||
if( aComponent->GetConvert() > LIB_ITEM::LIB_CONVERT::DEMORGAN )
|
||||
aComponent->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
|
||||
|
||||
// The alternate symbol may cause a change in the connection status so test the
|
||||
// connections so the connection indicators are drawn correctly.
|
||||
|
|
|
@ -68,11 +68,9 @@ void LIB_ITEM::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
|
|||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Unit" ), msg, BROWN ) );
|
||||
|
||||
if( m_Convert == 0 )
|
||||
msg = _( "All" );
|
||||
else if( m_Convert == 1 )
|
||||
if( m_Convert == LIB_ITEM::LIB_CONVERT::BASE )
|
||||
msg = _( "no" );
|
||||
else if( m_Convert == 2 )
|
||||
else if( m_Convert == LIB_ITEM::LIB_CONVERT::DEMORGAN )
|
||||
msg = _( "yes" );
|
||||
else
|
||||
msg = wxT( "?" );
|
||||
|
|
|
@ -92,7 +92,6 @@ class LIB_ITEM : public EDA_ITEM
|
|||
* @param aColor Draw color
|
||||
*/
|
||||
virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) {}
|
||||
|
||||
|
||||
friend class LIB_PART;
|
||||
|
||||
|
@ -134,6 +133,10 @@ public:
|
|||
|
||||
virtual ~LIB_ITEM() { }
|
||||
|
||||
|
||||
// Define the enums for basic
|
||||
enum LIB_CONVERT : int { BASE = 1, DEMORGAN = 2 };
|
||||
|
||||
/**
|
||||
* Provide a user-consumable name of the object type. Perform localization when
|
||||
* called so that run-time language selection works.
|
||||
|
|
|
@ -193,8 +193,8 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) :
|
|||
void SCH_COMPONENT::Init( const wxPoint& pos )
|
||||
{
|
||||
m_Pos = pos;
|
||||
m_unit = 0; // In multi unit chip - which unit to draw.
|
||||
m_convert = 0; // De Morgan Handling
|
||||
m_unit = 1; // In multi unit chip - which unit to draw.
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
|
||||
|
||||
// The rotation/mirror transformation matrix. pos normal
|
||||
m_transform = TRANSFORM();
|
||||
|
|
|
@ -228,7 +228,7 @@ LIB_VIEW_FRAME::~LIB_VIEW_FRAME()
|
|||
void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
|
||||
{
|
||||
m_unit = aUnit > 0 ? aUnit : 1;
|
||||
m_convert = aConvert > 0 ? aConvert : 1;
|
||||
m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
|
||||
m_selection_changed = false;
|
||||
|
||||
// Update canvas
|
||||
|
@ -546,7 +546,7 @@ bool LIB_VIEW_FRAME::ReCreateListLib()
|
|||
m_libraryName = libs[0];
|
||||
m_entryName = wxEmptyString;
|
||||
m_unit = 1;
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
}
|
||||
|
||||
bool cmp_changed = ReCreateListCmp();
|
||||
|
@ -577,7 +577,7 @@ bool LIB_VIEW_FRAME::ReCreateListCmp()
|
|||
{
|
||||
m_libraryName = wxEmptyString;
|
||||
m_entryName = wxEmptyString;
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
m_unit = 1;
|
||||
return true;
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ bool LIB_VIEW_FRAME::ReCreateListCmp()
|
|||
{
|
||||
// Select the first library entry when the previous entry name does not exist in
|
||||
// the current library.
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
m_unit = 1;
|
||||
index = 0;
|
||||
changed = true;
|
||||
|
@ -665,7 +665,7 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
|
|||
if( m_selection_changed )
|
||||
{
|
||||
m_unit = 1;
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
m_selection_changed = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -144,11 +144,11 @@ void LIB_VIEW_FRAME::onSelectSymbolBodyStyle( wxCommandEvent& aEvent )
|
|||
{
|
||||
default:
|
||||
case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT:
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
break;
|
||||
|
||||
case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT:
|
||||
m_convert = 2;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::DEMORGAN;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue