EESchema back annotate code refactoring and other minor changes.
* Push schematic back annotation code down into the appropriate class. * Minor improvements to back annotate file selection code and user prompt strings. * Minor tool bar tool tip capitalization fixes. * Change tool bar ID error from message dialog to a debug assert message.
This commit is contained in:
parent
115d1adbeb
commit
2694c524b4
|
@ -17,78 +17,14 @@
|
||||||
#include "sch_component.h"
|
#include "sch_component.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
const wxString BackAnnotateFileWildcard( wxT( "EESchema Back Annotation File (*.stf)|*.stf" ) );
|
||||||
* Function FillFootprintFieldForAllInstancesofComponent
|
|
||||||
* Search for component "aReference", and place a Footprint in Footprint field
|
|
||||||
* @param aReference = reference of the component to initialize
|
|
||||||
* @param aFootPrint = new value for the filed Footprint component
|
|
||||||
* @param aSetVisible = true to have the field visible, false to set the
|
|
||||||
* invisible flag
|
|
||||||
* @return true if the given component is found
|
|
||||||
* Note:
|
|
||||||
* the component is searched in the whole schematic, and because some
|
|
||||||
* components
|
|
||||||
* have more than one instance (multiple parts per package components)
|
|
||||||
* the search is not stopped when a reference is found (all instances must be
|
|
||||||
* found).
|
|
||||||
*/
|
|
||||||
bool SCH_EDIT_FRAME::FillFootprintFieldForAllInstancesofComponent( const wxString& aReference,
|
|
||||||
const wxString& aFootPrint,
|
|
||||||
bool aSetVisible )
|
|
||||||
{
|
|
||||||
SCH_SHEET_PATH* sheet;
|
|
||||||
SCH_ITEM* DrawList = NULL;
|
|
||||||
SCH_SHEET_LIST SheetList;
|
|
||||||
SCH_COMPONENT* Cmp;
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
for( sheet = SheetList.GetFirst();
|
|
||||||
sheet != NULL;
|
|
||||||
sheet = SheetList.GetNext() )
|
|
||||||
{
|
|
||||||
DrawList = (SCH_ITEM*) sheet->LastDrawList();
|
|
||||||
for( ; (DrawList != NULL); DrawList = DrawList->Next() )
|
|
||||||
{
|
|
||||||
if( DrawList->Type() != SCH_COMPONENT_T )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Cmp = (SCH_COMPONENT*) DrawList;
|
|
||||||
if( aReference.CmpNoCase( Cmp->GetRef( sheet ) ) == 0 )
|
|
||||||
{
|
|
||||||
// Found: Init Footprint Field
|
|
||||||
|
|
||||||
/* Give a reasonable value to the field position and
|
|
||||||
* orientation, if the text is empty at position 0, because
|
|
||||||
* it is probably not yet initialized
|
|
||||||
*/
|
|
||||||
if( Cmp->GetField( FOOTPRINT )->m_Text.IsEmpty()
|
|
||||||
&& ( Cmp->GetField( FOOTPRINT )->m_Pos == wxPoint( 0, 0 ) ) )
|
|
||||||
{
|
|
||||||
Cmp->GetField( FOOTPRINT )->m_Orient = Cmp->GetField(
|
|
||||||
VALUE )->m_Orient;
|
|
||||||
Cmp->GetField( FOOTPRINT )->m_Pos = Cmp->GetField(
|
|
||||||
VALUE )->m_Pos;
|
|
||||||
Cmp->GetField( FOOTPRINT )->m_Pos.y -= 100;
|
|
||||||
}
|
|
||||||
Cmp->GetField( FOOTPRINT )->m_Text = aFootPrint;
|
|
||||||
if( aSetVisible )
|
|
||||||
Cmp->GetField( FOOTPRINT )->m_Attributs &=
|
|
||||||
~TEXT_NO_VISIBLE;
|
|
||||||
else
|
|
||||||
Cmp->GetField( FOOTPRINT )->m_Attributs |= TEXT_NO_VISIBLE;
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeToVisible )
|
bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeToVisible )
|
||||||
{
|
{
|
||||||
int LineNum = 0;
|
int LineNum = 0;
|
||||||
char* cp, Ref[256], FootPrint[256], Line[1024];
|
char* cp, Ref[256], FootPrint[256], Line[1024];
|
||||||
|
SCH_SHEET_LIST SheetList;
|
||||||
|
|
||||||
while( GetLine( aFilename, Line, &LineNum, sizeof(Line) ) )
|
while( GetLine( aFilename, Line, &LineNum, sizeof(Line) ) )
|
||||||
{
|
{
|
||||||
|
@ -104,9 +40,7 @@ bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeT
|
||||||
|
|
||||||
wxString reference = FROM_UTF8( Ref );
|
wxString reference = FROM_UTF8( Ref );
|
||||||
wxString Footprint = FROM_UTF8( FootPrint );
|
wxString Footprint = FROM_UTF8( FootPrint );
|
||||||
FillFootprintFieldForAllInstancesofComponent( reference,
|
SheetList.SetComponentFootprint( reference, Footprint, aSetFieldAttributeToVisible );
|
||||||
Footprint,
|
|
||||||
aSetFieldAttributeToVisible );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,56 +48,44 @@ bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Backann footprint info to schematic.
|
|
||||||
*/
|
|
||||||
bool SCH_EDIT_FRAME::ReadInputStuffFile()
|
bool SCH_EDIT_FRAME::ReadInputStuffFile()
|
||||||
{
|
{
|
||||||
wxString Line, filename;
|
wxString title, filename;
|
||||||
FILE* StuffFile;
|
FILE* file;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
bool SetFieldToVisible = true;
|
bool visible = false;
|
||||||
|
|
||||||
filename = EDA_FileSelector( _( "Load Stuff File" ),
|
wxFileDialog dlg( this, _( "Load Back Annotate File" ), wxEmptyString, wxEmptyString,
|
||||||
wxEmptyString,
|
BackAnnotateFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||||
wxEmptyString,
|
|
||||||
wxT( ".stf" ),
|
|
||||||
wxT( "*.stf" ),
|
|
||||||
this,
|
|
||||||
wxFD_OPEN,
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
|
|
||||||
if( filename.IsEmpty() )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
Line = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
|
filename = dlg.GetPath();
|
||||||
Line += wxT( " " ) + filename;
|
title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
|
||||||
SetTitle( Line );
|
title += wxT( " " ) + filename;
|
||||||
|
SetTitle( title );
|
||||||
|
|
||||||
if( filename.IsEmpty() )
|
int response = wxMessageBox( _( "Do you want to make all the foot print fields visible?" ),
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
int diag = wxMessageBox(
|
|
||||||
_( "Set the foot print field to visible?" ),
|
|
||||||
_( "Field Display Option" ),
|
_( "Field Display Option" ),
|
||||||
wxYES_NO | wxICON_QUESTION | wxCANCEL, this );
|
wxYES_NO | wxICON_QUESTION | wxCANCEL, this );
|
||||||
|
|
||||||
if( diag == wxCANCEL )
|
if( response == wxCANCEL )
|
||||||
return false;
|
return false;
|
||||||
if( diag == wxYES )
|
|
||||||
SetFieldToVisible = true;
|
|
||||||
else
|
|
||||||
SetFieldToVisible = false;
|
|
||||||
|
|
||||||
StuffFile = wxFopen( filename, wxT( "rt" ) );
|
if( response == wxYES )
|
||||||
if( StuffFile == NULL )
|
visible = true;
|
||||||
|
|
||||||
|
file = wxFopen( filename, wxT( "rt" ) );
|
||||||
|
|
||||||
|
if( file == NULL )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Failed to open stuff file <%s>" ), filename.GetData() );
|
msg.Printf( _( "Failed to open back annotate file <%s>" ), filename.GetData() );
|
||||||
DisplayError( this, msg, 20 );
|
DisplayError( this, msg );
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessStuffFile( StuffFile, SetFieldToVisible );
|
ProcessStuffFile( file, visible );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -992,6 +992,50 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference,
|
||||||
|
const wxString& aFootPrint, bool aSetVisible )
|
||||||
|
{
|
||||||
|
SCH_COMPONENT* component;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
|
||||||
|
{
|
||||||
|
if( item->Type() != SCH_COMPONENT_T )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
component = (SCH_COMPONENT*) item;
|
||||||
|
|
||||||
|
if( aReference.CmpNoCase( component->GetRef( aSheetPath ) ) == 0 )
|
||||||
|
{
|
||||||
|
// Found: Init Footprint Field
|
||||||
|
|
||||||
|
/* Give a reasonable value to the field position and
|
||||||
|
* orientation, if the text is empty at position 0, because
|
||||||
|
* it is probably not yet initialized
|
||||||
|
*/
|
||||||
|
if( component->GetField( FOOTPRINT )->m_Text.IsEmpty()
|
||||||
|
&& ( component->GetField( FOOTPRINT )->m_Pos == wxPoint( 0, 0 ) ) )
|
||||||
|
{
|
||||||
|
component->GetField( FOOTPRINT )->m_Orient = component->GetField( VALUE )->m_Orient;
|
||||||
|
component->GetField( FOOTPRINT )->m_Pos = component->GetField( VALUE )->m_Pos;
|
||||||
|
component->GetField( FOOTPRINT )->m_Pos.y -= 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
component->GetField( FOOTPRINT )->m_Text = aFootPrint;
|
||||||
|
|
||||||
|
if( aSetVisible )
|
||||||
|
component->GetField( FOOTPRINT )->m_Attributs &= ~TEXT_NO_VISIBLE;
|
||||||
|
else
|
||||||
|
component->GetField( FOOTPRINT )->m_Attributs |= TEXT_NO_VISIBLE;
|
||||||
|
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
/* Class SCH_SCREENS to handle the list of screens in a hierarchy */
|
/* Class SCH_SCREENS to handle the list of screens in a hierarchy */
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
|
@ -448,6 +448,18 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCH_SHEET_PATH::SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
|
||||||
|
bool aSetVisible )
|
||||||
|
{
|
||||||
|
SCH_SCREEN* screen = LastScreen();
|
||||||
|
|
||||||
|
if( screen == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SCH_SHEET_PATH& SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 )
|
SCH_SHEET_PATH& SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 )
|
||||||
{
|
{
|
||||||
if( this == &d1 ) // Self assignment is bad!
|
if( this == &d1 ) // Self assignment is bad!
|
||||||
|
@ -786,3 +798,15 @@ SCH_ITEM* SCH_SHEET_LIST::MatchNextItem( wxFindReplaceData& aSearchData,
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCH_SHEET_LIST::SetComponentFootprint( const wxString& aReference,
|
||||||
|
const wxString& aFootPrint, bool aSetVisible )
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
for( SCH_SHEET_PATH* path = GetFirst(); path != NULL; path = GetNext() )
|
||||||
|
found = path->SetComponentFootprint( aReference, aFootPrint, aSetVisible );
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
|
@ -172,8 +172,7 @@ public:
|
||||||
* @param aFound - Please document me.
|
* @param aFound - Please document me.
|
||||||
* @return true if success else false
|
* @return true if success else false
|
||||||
*/
|
*/
|
||||||
bool BuildSheetPathInfoFromSheetPathValue( const wxString& aPath,
|
bool BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound = false );
|
||||||
bool aFound = false );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function UpdateAllScreenReferences
|
* Function UpdateAllScreenReferences
|
||||||
|
@ -202,8 +201,20 @@ public:
|
||||||
* @param aReferences List of references to populate.
|
* @param aReferences List of references to populate.
|
||||||
* @param aIncludePowerSymbols Set to false to only get normal components.
|
* @param aIncludePowerSymbols Set to false to only get normal components.
|
||||||
*/
|
*/
|
||||||
void GetComponents( SCH_REFERENCE_LIST& aReferences,
|
void GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true );
|
||||||
bool aIncludePowerSymbols = true );
|
|
||||||
|
/**
|
||||||
|
* Function SetFootprintField
|
||||||
|
* searches last sheet in the path for a component with \a aReference and set the footprint
|
||||||
|
* field to \a aFootPrint if found.
|
||||||
|
*
|
||||||
|
* @param aReference The reference designator of the component.
|
||||||
|
* @param aFootPrint The value to set the footprint fiield.
|
||||||
|
* @param aSetVisible The value to set the field visibility flag.
|
||||||
|
* @retrun True if \a aReference was found otherwise false.
|
||||||
|
*/
|
||||||
|
bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
|
||||||
|
bool aSetVisible );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the next schematic item in this sheet ojbect.
|
* Find the next schematic item in this sheet ojbect.
|
||||||
|
@ -405,6 +416,19 @@ public:
|
||||||
SCH_ITEM* aLastItem,
|
SCH_ITEM* aLastItem,
|
||||||
wxPoint * aFindLocation );
|
wxPoint * aFindLocation );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetFootprintField
|
||||||
|
* searches all the sheets for a component with \a aReference and set the footprint
|
||||||
|
* field to \a aFootPrint if found.
|
||||||
|
*
|
||||||
|
* @param aReference The reference designator of the component.
|
||||||
|
* @param aFootPrint The value to set the footprint fiield.
|
||||||
|
* @param aSetVisible The value to set the field visibility flag.
|
||||||
|
* @retrun True if \a aReference was found otherwise false.
|
||||||
|
*/
|
||||||
|
bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
|
||||||
|
bool aSetVisible );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,19 +100,19 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
||||||
|
|
||||||
m_HToolBar->AddSeparator();
|
m_HToolBar->AddSeparator();
|
||||||
m_HToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, wxBitmap( netlist_xpm ),
|
m_HToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, wxBitmap( netlist_xpm ),
|
||||||
_( "Netlist generation" ) );
|
_( "Generate netlist" ) );
|
||||||
|
|
||||||
m_HToolBar->AddTool( ID_GET_ANNOTATE, wxEmptyString, wxBitmap( annotate_xpm ),
|
m_HToolBar->AddTool( ID_GET_ANNOTATE, wxEmptyString, wxBitmap( annotate_xpm ),
|
||||||
_( "Annotate schematic" ) );
|
_( "Annotate schematic" ) );
|
||||||
|
|
||||||
m_HToolBar->AddTool( ID_GET_ERC, wxEmptyString, wxBitmap( erc_xpm ),
|
m_HToolBar->AddTool( ID_GET_ERC, wxEmptyString, wxBitmap( erc_xpm ),
|
||||||
_( "Schematic Electric Rules Check" ) );
|
_( "Perform electric rules check" ) );
|
||||||
|
|
||||||
m_HToolBar->AddTool( ID_GET_TOOLS, wxEmptyString, wxBitmap( tools_xpm ),
|
m_HToolBar->AddTool( ID_GET_TOOLS, wxEmptyString, wxBitmap( tools_xpm ),
|
||||||
_( "Bill of material and/or Cross references" ) );
|
_( "Generate bill of materials and/or cross references" ) );
|
||||||
|
|
||||||
m_HToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString, wxBitmap( backanno_xpm ),
|
m_HToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString, wxBitmap( backanno_xpm ),
|
||||||
_( "Backannotate footprint" ) );
|
_( "Back bnnotate component foot prints" ) );
|
||||||
|
|
||||||
// after adding the tools to the toolbar, must call Realize() to reflect the changes
|
// after adding the tools to the toolbar, must call Realize() to reflect the changes
|
||||||
m_HToolBar->Realize();
|
m_HToolBar->Realize();
|
||||||
|
@ -254,7 +254,7 @@ void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DisplayError( this, wxT( "OnSelectOptionToolbar() error" ) );
|
wxFAIL_MSG( wxT( "Unexpected select option tool bar ID." ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,6 +357,20 @@ public:
|
||||||
*/
|
*/
|
||||||
SCH_TEXT* GetLabel( const wxPoint& aPosition, int aAccuracy = 0 );
|
SCH_TEXT* GetLabel( const wxPoint& aPosition, int aAccuracy = 0 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetFootprintField
|
||||||
|
* searches screen for a component with \a aReference and set the footprint field to
|
||||||
|
* \a aFootPrint if found.
|
||||||
|
*
|
||||||
|
* @param aSheetPath The sheet path used to look up the reference designator.
|
||||||
|
* @param aReference The reference designator of the component.
|
||||||
|
* @param aFootPrint The value to set the footprint fiield.
|
||||||
|
* @param aSetVisible The value to set the field visibility flag.
|
||||||
|
* @retrun True if \a aReference was found otherwise false.
|
||||||
|
*/
|
||||||
|
bool SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference,
|
||||||
|
const wxString& aFootPrint, bool aSetVisible );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SelectBlockItems
|
* Function SelectBlockItems
|
||||||
* creates a list of items found when a block command is initiated. The items selected
|
* creates a list of items found when a block command is initiated. The items selected
|
||||||
|
|
Loading…
Reference in New Issue