Fixed a bug in search function in Eeschema: search for a component reference in a complex hierarchy was broken
This commit is contained in:
parent
6e61193075
commit
8b5ba9ff69
|
@ -111,8 +111,9 @@ SCH_SHEET* SCH_SHEET_PATH::Last()
|
|||
*/
|
||||
SCH_SCREEN* SCH_SHEET_PATH::LastScreen()
|
||||
{
|
||||
if( m_numSheets )
|
||||
return m_sheets[m_numSheets - 1]->m_AssociatedScreen;
|
||||
SCH_SHEET* lastSheet = Last();
|
||||
if( lastSheet )
|
||||
return lastSheet->m_AssociatedScreen;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -123,8 +124,9 @@ SCH_SCREEN* SCH_SHEET_PATH::LastScreen()
|
|||
*/
|
||||
SCH_ITEM* SCH_SHEET_PATH::LastDrawList()
|
||||
{
|
||||
if( m_numSheets && m_sheets[m_numSheets - 1]->m_AssociatedScreen )
|
||||
return m_sheets[m_numSheets - 1]->m_AssociatedScreen->EEDrawList;
|
||||
SCH_SHEET* lastSheet = Last();
|
||||
if( lastSheet && lastSheet->m_AssociatedScreen )
|
||||
return lastSheet->m_AssociatedScreen->EEDrawList;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -333,7 +335,7 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData,
|
|||
}
|
||||
else
|
||||
{
|
||||
if( drawItem->Matches( aSearchData ) )
|
||||
if( drawItem->Matches( aSearchData, Last() ) )
|
||||
return drawItem;
|
||||
}
|
||||
|
||||
|
@ -631,7 +633,7 @@ SCH_ITEM* SCH_SHEET_LIST::MatchNextItem( wxFindReplaceData& aSearchData,
|
|||
}
|
||||
else
|
||||
{
|
||||
if( drawItem->Matches( aSearchData ) )
|
||||
if( drawItem->Matches( aSearchData, sheet ) )
|
||||
{
|
||||
if( aSheetFoundIn )
|
||||
*aSheetFoundIn = sheet;
|
||||
|
|
|
@ -420,7 +420,28 @@ void SCH_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData )
|
||||
bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void * aAuxData )
|
||||
{
|
||||
if( aAuxData && m_FieldId == REFERENCE )
|
||||
{
|
||||
SCH_COMPONENT* pSch = (SCH_COMPONENT*) m_Parent;
|
||||
SCH_SHEET_PATH* sheet = (SCH_SHEET_PATH*) aAuxData;
|
||||
wxString fulltext = pSch->GetRef( sheet );
|
||||
if( m_AddExtraText )
|
||||
{
|
||||
/* For more than one part per package, we must add the part selection
|
||||
* A, B, ... or 1, 2, .. to the reference. */
|
||||
int part_id = pSch->GetUnitSelection( sheet );
|
||||
#if defined(KICAD_GOST)
|
||||
fulltext.Append( '.' );
|
||||
part_id = '1' - 1 + part_id;
|
||||
#else
|
||||
part_id = 'A' - 1 + part_id;
|
||||
#endif
|
||||
fulltext.Append( part_id );
|
||||
}
|
||||
return SCH_ITEM::Matches( fulltext, aSearchData );
|
||||
}
|
||||
|
||||
return SCH_ITEM::Matches( m_Text, aSearchData );
|
||||
}
|
||||
|
|
|
@ -119,9 +119,13 @@ public:
|
|||
* Compare schematic field text against search string.
|
||||
*
|
||||
* @param aSearchData - Criteria to search against.
|
||||
* @param aAuxData - a pointer on auxiliary data, if needed.
|
||||
* the sheet path is needed for REFERENCE field because m_Text
|
||||
* value is just the valeur displayed, and in complex hierarchies
|
||||
* this is only one of all references (one per sheet path)
|
||||
* @return True if this field text matches the search criteria.
|
||||
*/
|
||||
virtual bool Matches( wxFindReplaceData& aSearchData );
|
||||
virtual bool Matches( wxFindReplaceData& aSearchData, void * aAuxData );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1153,19 +1153,30 @@ void SCH_COMPONENT::Mirror_Y(int aYaxis_position)
|
|||
}
|
||||
|
||||
|
||||
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData )
|
||||
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void * aAuxData )
|
||||
{
|
||||
if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS ) )
|
||||
{
|
||||
if( !GetField( REFERENCE )->Matches( aSearchData ) )
|
||||
return GetField( VALUE )->Matches( aSearchData );
|
||||
// Search reference.
|
||||
// reference is a special field because a part identifier is added
|
||||
// in multi parts per package
|
||||
// the .m_AddExtraText of the field msut be set to add this identifier:
|
||||
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
if( Entry && Entry->GetPartCount() > 1 )
|
||||
GetField( REFERENCE )->m_AddExtraText = true;
|
||||
else
|
||||
GetField( REFERENCE )->m_AddExtraText = false;
|
||||
|
||||
if( GetField( REFERENCE )->Matches( aSearchData, aAuxData ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
for( size_t i = 0; i < NUMBER_OF_FIELDS; i++ )
|
||||
if( GetField( VALUE )->Matches( aSearchData, aAuxData ) )
|
||||
return true;
|
||||
|
||||
if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS ) )
|
||||
return false;
|
||||
|
||||
for( size_t i = VALUE+1; i < NUMBER_OF_FIELDS; i++ )
|
||||
{
|
||||
if( GetField( i )->Matches( aSearchData ) )
|
||||
if( GetField( i )->Matches( aSearchData, aAuxData ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -353,9 +353,12 @@ public:
|
|||
* Compare schematic component reference and value fields against search string.
|
||||
*
|
||||
* @param aSearchData - Criteria to search against.
|
||||
* @param aAuxData - a pointer on auxiliary data, if needed.
|
||||
* When searching string in REFERENCE field we must know the sheet path
|
||||
* This param is used in this case
|
||||
* @return True if this component reference or value field matches the search criteria.
|
||||
*/
|
||||
virtual bool Matches( wxFindReplaceData& aSearchData );
|
||||
virtual bool Matches( wxFindReplaceData& aSearchData, void * aAuxData );
|
||||
|
||||
#if defined (DEBUG)
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ wxPoint SCH_TEXT::GetSchematicTextOffset()
|
|||
}
|
||||
|
||||
|
||||
bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData )
|
||||
bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void * aAuxData )
|
||||
{
|
||||
return SCH_ITEM::Matches( m_Text, aSearchData );
|
||||
}
|
||||
|
|
|
@ -149,9 +149,10 @@ public:
|
|||
* Compare schematic text entry against search string.
|
||||
*
|
||||
* @param aSearchData - Criterial to search against.
|
||||
* @param aAuxData - a pointer on auxiliary data, if needed. Can be null
|
||||
* @return True if this schematic text item matches the search criteria.
|
||||
*/
|
||||
virtual bool Matches( wxFindReplaceData& aSearchData );
|
||||
virtual bool Matches( wxFindReplaceData& aSearchData, void * aAuxData );
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os );
|
||||
|
|
|
@ -100,9 +100,13 @@ public:
|
|||
* objects derived from EDA_BaseStruct.
|
||||
*
|
||||
* @param aSearchData - The search criteria.
|
||||
* @param aAuxData - a pointer on auxiliary data, if needed (NULL if not used).
|
||||
* When searching string in REFERENCE field we must know the sheet path
|
||||
* This param is used in such cases
|
||||
* @return True if this schematic text item matches the search criteria.
|
||||
*/
|
||||
virtual bool Matches( wxFindReplaceData& aSearchData ) { return false; }
|
||||
virtual bool Matches( wxFindReplaceData& aSearchData, void * aAuxData )
|
||||
{ return false; }
|
||||
|
||||
/**
|
||||
* Compare schematic item against search string.
|
||||
|
|
Loading…
Reference in New Issue