Eeschema: fix rescue multiple unit symbol bug.
The code that checked for pin conflicts to determine if a symbol needed
rescued did not check either the pin convert setting so it was possible
for a pin from the other convert on symbols that do not have identical
units to appear to not have a pin conflict. Add tests for pin unit and
convert setting to prevent that from breaking the comparison. This must
have always been broken.
Fix the symbol preview widget to prevent drawing all symbols on top of
each other (if we need to do this the code will have to be revised) and
also show the convert if valid.
Fix broken symbol cache library when saving alias symbols.
Fixes https://gitlab.com/kicad/code/kicad/issues/3879
(cherry picked from commit e91f1f57dd
)
This commit is contained in:
parent
e6d49424cf
commit
5d0883c0e4
|
@ -715,6 +715,15 @@ bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTes
|
|||
for( LIB_PIN* eachOtherPin : otherPinList )
|
||||
{
|
||||
wxASSERT( eachOtherPin );
|
||||
|
||||
// Same unit?
|
||||
if( eachThisPin->GetUnit() != eachOtherPin->GetUnit() )
|
||||
continue;
|
||||
|
||||
// Same body stype?
|
||||
if( eachThisPin->GetConvert() != eachOtherPin->GetConvert() )
|
||||
continue;
|
||||
|
||||
// Same position?
|
||||
if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
|
||||
continue;
|
||||
|
@ -740,6 +749,7 @@ bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTes
|
|||
continue;
|
||||
|
||||
foundMatch = true;
|
||||
break; // Match found so seach is complete.
|
||||
}
|
||||
|
||||
if( !foundMatch )
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -245,8 +245,13 @@ void DIALOG_RESCUE_EACH::displayItemsInConflict()
|
|||
else
|
||||
{
|
||||
RESCUE_CANDIDATE& selected_part = m_Rescuer->m_all_candidates[row];
|
||||
m_previewOldWidget->DisplayPart( selected_part.GetCacheCandidate(), 0 );
|
||||
m_previewNewWidget->DisplayPart( selected_part.GetLibCandidate(), 0 );
|
||||
|
||||
m_previewOldWidget->DisplayPart( selected_part.GetCacheCandidate(),
|
||||
selected_part.GetUnit(),
|
||||
selected_part.GetConvert() );
|
||||
m_previewNewWidget->DisplayPart( selected_part.GetLibCandidate(),
|
||||
selected_part.GetUnit(),
|
||||
selected_part.GetConvert() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras ar wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
|
||||
* Copyright (C) 2015-2019 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -125,11 +125,15 @@ static wxFileName GetRescueLibraryFileName()
|
|||
|
||||
RESCUE_CASE_CANDIDATE::RESCUE_CASE_CANDIDATE( const wxString& aRequestedName,
|
||||
const wxString& aNewName,
|
||||
LIB_PART* aLibCandidate )
|
||||
LIB_PART* aLibCandidate,
|
||||
int aUnit,
|
||||
int aConvert )
|
||||
{
|
||||
m_requested_name = aRequestedName;
|
||||
m_new_name = aNewName;
|
||||
m_lib_candidate = aLibCandidate;
|
||||
m_unit = aUnit;
|
||||
m_convert = aConvert;
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,7 +174,9 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
|||
continue;
|
||||
|
||||
RESCUE_CASE_CANDIDATE candidate( part_name, case_insensitive_matches[0]->GetName(),
|
||||
case_insensitive_matches[0]->GetPart() );
|
||||
case_insensitive_matches[0]->GetPart(),
|
||||
each_component->GetUnit(),
|
||||
each_component->GetConvert() );
|
||||
|
||||
candidate_map[part_name] = candidate;
|
||||
}
|
||||
|
@ -213,12 +219,16 @@ bool RESCUE_CASE_CANDIDATE::PerformAction( RESCUER* aRescuer )
|
|||
RESCUE_CACHE_CANDIDATE::RESCUE_CACHE_CANDIDATE( const wxString& aRequestedName,
|
||||
const wxString& aNewName,
|
||||
LIB_PART* aCacheCandidate,
|
||||
LIB_PART* aLibCandidate )
|
||||
LIB_PART* aLibCandidate,
|
||||
int aUnit,
|
||||
int aConvert )
|
||||
{
|
||||
m_requested_name = aRequestedName;
|
||||
m_new_name = aNewName;
|
||||
m_cache_candidate = aCacheCandidate;
|
||||
m_lib_candidate = aLibCandidate;
|
||||
m_unit = aUnit;
|
||||
m_convert = aConvert;
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,7 +281,9 @@ void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer,
|
|||
// Check if the symbol has already been rescued.
|
||||
wxString new_name = LIB_ID::FixIllegalChars( part_name, LIB_ID::ID_SCH );
|
||||
|
||||
RESCUE_CACHE_CANDIDATE candidate( part_name, new_name, cache_match, lib_match );
|
||||
RESCUE_CACHE_CANDIDATE candidate( part_name, new_name, cache_match, lib_match,
|
||||
each_component->GetUnit(),
|
||||
each_component->GetConvert() );
|
||||
|
||||
candidate_map[part_name] = candidate;
|
||||
}
|
||||
|
@ -335,13 +347,17 @@ RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE(
|
|||
const LIB_ID& aRequestedId,
|
||||
const LIB_ID& aNewId,
|
||||
LIB_PART* aCacheCandidate,
|
||||
LIB_PART* aLibCandidate ) : RESCUE_CANDIDATE()
|
||||
LIB_PART* aLibCandidate,
|
||||
int aUnit,
|
||||
int aConvert ) : RESCUE_CANDIDATE()
|
||||
{
|
||||
m_requested_id = aRequestedId;
|
||||
m_requested_name = aRequestedId.Format();
|
||||
m_new_id = aNewId;
|
||||
m_lib_candidate = aLibCandidate;
|
||||
m_cache_candidate = aCacheCandidate;
|
||||
m_unit = aUnit;
|
||||
m_convert = aConvert;
|
||||
}
|
||||
|
||||
|
||||
|
@ -406,7 +422,9 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(
|
|||
libNickname.Replace( " ", "-" );
|
||||
LIB_ID new_id( libNickname, new_name + "-" + part_id.GetLibNickname().wx_str() );
|
||||
|
||||
RESCUE_SYMBOL_LIB_TABLE_CANDIDATE candidate( part_id, new_id, cache_match, lib_match );
|
||||
RESCUE_SYMBOL_LIB_TABLE_CANDIDATE candidate( part_id, new_id, cache_match, lib_match,
|
||||
each_component->GetUnit(),
|
||||
each_component->GetConvert() );
|
||||
|
||||
candidate_map[part_id] = candidate;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>
|
||||
* Copyright (C) 2015-2019 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -69,6 +69,8 @@ protected:
|
|||
wxString m_requested_name;
|
||||
wxString m_new_name;
|
||||
LIB_PART* m_lib_candidate;
|
||||
int m_unit;
|
||||
int m_convert;
|
||||
|
||||
public:
|
||||
virtual ~RESCUE_CANDIDATE() {}
|
||||
|
@ -95,6 +97,10 @@ public:
|
|||
*/
|
||||
virtual LIB_PART* GetLibCandidate() const { return m_lib_candidate; }
|
||||
|
||||
int GetUnit() const { return m_unit; }
|
||||
|
||||
int GetConvert() const { return m_convert; }
|
||||
|
||||
/**
|
||||
* Get a description of the action proposed, for displaying in the UI.
|
||||
*/
|
||||
|
@ -125,9 +131,11 @@ public:
|
|||
* @param aRequestedName - the name the schematic asks for
|
||||
* @param aNewName - the name we want to change it to
|
||||
* @param aLibCandidate - the part that will give us
|
||||
* @param aUnit The unit of the rescued symbol.
|
||||
* @param aConvert The body style of the rescued symbol.
|
||||
*/
|
||||
RESCUE_CASE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName,
|
||||
LIB_PART* aLibCandidate );
|
||||
LIB_PART* aLibCandidate, int aUnit = 0, int aConvert = 0 );
|
||||
|
||||
RESCUE_CASE_CANDIDATE() { m_lib_candidate = NULL; }
|
||||
|
||||
|
@ -156,9 +164,12 @@ public:
|
|||
* @param aNewName - the name we want to change it to
|
||||
* @param aCacheCandidate - the part from the cache
|
||||
* @param aLibCandidate - the part that would be loaded from the library
|
||||
* @param aUnit The unit of the rescued symbol.
|
||||
* @param aConvert The body style of the rescued symbol.
|
||||
*/
|
||||
RESCUE_CACHE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName,
|
||||
LIB_PART* aCacheCandidate, LIB_PART* aLibCandidate );
|
||||
LIB_PART* aCacheCandidate, LIB_PART* aLibCandidate,
|
||||
int aUnit = 0, int aConvert = 0 );
|
||||
|
||||
RESCUE_CACHE_CANDIDATE();
|
||||
|
||||
|
@ -191,9 +202,12 @@ public:
|
|||
* @param aNewName - the name we want to change it to
|
||||
* @param aCacheCandidate - the part from the cache
|
||||
* @param aLibCandidate - the part that would be loaded from the library
|
||||
* @param aUnit The unit of the rescued symbol.
|
||||
* @param aConvert The body style of the rescued symbol.
|
||||
*/
|
||||
RESCUE_SYMBOL_LIB_TABLE_CANDIDATE( const LIB_ID& aRequestedId, const LIB_ID& aNewId,
|
||||
LIB_PART* aCacheCandidate, LIB_PART* aLibCandidate);
|
||||
LIB_PART* aCacheCandidate, LIB_PART* aLibCandidate,
|
||||
int aUnit = 0, int aConvert = 0 );
|
||||
|
||||
RESCUE_SYMBOL_LIB_TABLE_CANDIDATE();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -57,7 +57,8 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway,
|
|||
|
||||
// Do not display the grid: the look is not good for a small canvas area.
|
||||
// But mainly, due to some strange bug I (JPC) was unable to fix, the grid creates
|
||||
// strange artifacts on Windows when eeschema is run from Kicad manager (but not in stand alone...).
|
||||
// strange artifacts on Windows when eeschema is run from Kicad manager (but not in
|
||||
// stand alone...).
|
||||
m_preview->GetGAL()->SetGridVisibility( false );
|
||||
|
||||
// Early initialization of the canvas background color,
|
||||
|
@ -141,7 +142,7 @@ void SYMBOL_PREVIEW_WIDGET::fitOnDrawArea()
|
|||
}
|
||||
|
||||
|
||||
void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit )
|
||||
void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, int aConvert )
|
||||
{
|
||||
KIGFX::VIEW* view = m_preview->GetView();
|
||||
auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
||||
|
@ -172,19 +173,16 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit )
|
|||
|
||||
// If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll
|
||||
// draw all of them.)
|
||||
if( part->IsMulti() && aUnit == 0 )
|
||||
aUnit = 1;
|
||||
|
||||
settings->m_ShowUnit = aUnit;
|
||||
settings->m_ShowUnit = ( part->IsMulti() && aUnit == 0 ) ? 1 : aUnit;
|
||||
|
||||
// For symbols having a De Morgan body style, use the first style
|
||||
settings->m_ShowConvert = part->HasConversion() ? 1 : 0;
|
||||
settings->m_ShowConvert =
|
||||
( part->HasConversion() && aConvert == 0 ) ? 1 : aConvert;
|
||||
|
||||
m_previewItem = new LIB_ALIAS( *alias, part );
|
||||
view->Add( m_previewItem );
|
||||
|
||||
// Get the symbole size, in internal units
|
||||
m_itemBBox = part->GetUnitBoundingBox( aUnit, 0 );
|
||||
m_itemBBox = part->GetUnitBoundingBox( settings->m_ShowUnit, settings->m_ShowConvert );
|
||||
|
||||
if( !m_preview->IsShown() )
|
||||
{
|
||||
|
@ -201,7 +199,7 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit )
|
|||
}
|
||||
|
||||
|
||||
void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit )
|
||||
void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit, int aConvert )
|
||||
{
|
||||
KIGFX::VIEW* view = m_preview->GetView();
|
||||
|
||||
|
@ -214,19 +212,21 @@ void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit )
|
|||
|
||||
if( aPart )
|
||||
{
|
||||
// If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll
|
||||
// draw all of them.)
|
||||
if( aPart->IsMulti() && aUnit == 0 )
|
||||
aUnit = 1;
|
||||
m_previewItem = new LIB_PART( *aPart );
|
||||
|
||||
// For symbols having a De Morgan body style, use the first style
|
||||
auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
||||
settings->m_ShowConvert = aPart->HasConversion() ? 1 : 0;
|
||||
m_previewItem = new LIB_PART( *aPart );
|
||||
// If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll
|
||||
// draw all of them.)
|
||||
settings->m_ShowUnit = ( aPart->IsMulti() && aUnit == 0 ) ? 1 : aUnit;
|
||||
|
||||
settings->m_ShowConvert =
|
||||
( aPart->HasConversion() && aConvert == 0 ) ? 1 : aConvert;
|
||||
|
||||
view->Add( m_previewItem );
|
||||
|
||||
// Get the symbole size, in internal units
|
||||
m_itemBBox = aPart->GetUnitBoundingBox( aUnit, 0 );
|
||||
m_itemBBox = aPart->GetUnitBoundingBox( settings->m_ShowUnit, settings->m_ShowConvert );
|
||||
|
||||
// Calculate the draw scale to fit the drawing area
|
||||
fitOnDrawArea();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -58,9 +58,9 @@ public:
|
|||
/**
|
||||
* Set the currently displayed symbol.
|
||||
*/
|
||||
void DisplaySymbol( const LIB_ID& aSymbolID, int aUnit );
|
||||
void DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, int aConvert = 0 );
|
||||
|
||||
void DisplayPart( LIB_PART* aPart, int aUnit );
|
||||
void DisplayPart( LIB_PART* aPart, int aUnit, int aConvert = 0 );
|
||||
|
||||
private:
|
||||
void onSize( wxSizeEvent& aEvent );
|
||||
|
|
Loading…
Reference in New Issue