Cleanup re-annotation code style
This commit is contained in:
parent
d08bf90576
commit
5abc85aa80
|
@ -39,8 +39,7 @@ WX_STRING_REPORTER_FILTERED::~WX_STRING_REPORTER_FILTERED()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
REPORTER& WX_STRING_REPORTER_FILTERED::Report( const wxString &aText,
|
REPORTER& WX_STRING_REPORTER_FILTERED::Report( const wxString &aText, SEVERITY aSeverity )
|
||||||
SEVERITY aSeverity )
|
|
||||||
{
|
{
|
||||||
if ( aSeverity < m_MinSeverity )
|
if ( aSeverity < m_MinSeverity )
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -71,7 +70,7 @@ void ReannotateFromPCBNew( SCH_EDIT_FRAME* aFrame, std::string& aNetlist )
|
||||||
false, //aIgnoreOtherProjects
|
false, //aIgnoreOtherProjects
|
||||||
false ); //aDryRun
|
false ); //aDryRun
|
||||||
|
|
||||||
if ( !backAnno.BackAnnotateSymbols( aNetlist ) )
|
if( !backAnno.BackAnnotateSymbols( aNetlist ) )
|
||||||
{
|
{
|
||||||
aNetlist = _( "Errors reported by Eeschema:\n" )
|
aNetlist = _( "Errors reported by Eeschema:\n" )
|
||||||
+ reporter.m_string.ToStdString(); //Assume the worst
|
+ reporter.m_string.ToStdString(); //Assume the worst
|
||||||
|
|
|
@ -95,7 +95,8 @@ wxString ActionMessage[] = {
|
||||||
|
|
||||||
|
|
||||||
DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE( PCB_EDIT_FRAME* aParentFrame )
|
DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE( PCB_EDIT_FRAME* aParentFrame )
|
||||||
: DIALOG_BOARD_REANNOTATE_BASE( aParentFrame ), m_modules( aParentFrame->GetBoard()->Modules() )
|
: DIALOG_BOARD_REANNOTATE_BASE( aParentFrame ),
|
||||||
|
m_modules( aParentFrame->GetBoard()->Modules() )
|
||||||
{
|
{
|
||||||
m_Config = Kiface().KifaceSettings();
|
m_Config = Kiface().KifaceSettings();
|
||||||
InitValues();
|
InitValues();
|
||||||
|
@ -120,9 +121,7 @@ DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE( PCB_EDIT_FRAME* aParentFrame )
|
||||||
m_Settings = aParentFrame->config();
|
m_Settings = aParentFrame->config();
|
||||||
wxArrayString gridslist;
|
wxArrayString gridslist;
|
||||||
GRID_MENU::BuildChoiceList( &gridslist, m_Settings,
|
GRID_MENU::BuildChoiceList( &gridslist, m_Settings,
|
||||||
aParentFrame->GetUserUnits() != EDA_UNITS::INCHES );
|
aParentFrame->GetUserUnits() != EDA_UNITS::INCHES );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if( -1 == m_GridIndex ) //If no default loaded
|
if( -1 == m_GridIndex ) //If no default loaded
|
||||||
m_GridIndex = m_Settings->m_Window.grid.last_size_idx; //Get the current grid size
|
m_GridIndex = m_Settings->m_Window.grid.last_size_idx; //Get the current grid size
|
||||||
|
@ -148,7 +147,7 @@ DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE( PCB_EDIT_FRAME* aParentFrame )
|
||||||
|
|
||||||
m_AnnotationChoice = ( m_SortCode >= (int) AnnotateWhat.size() ) ?
|
m_AnnotationChoice = ( m_SortCode >= (int) AnnotateWhat.size() ) ?
|
||||||
AnnotationChoice::AnnotateAll :
|
AnnotationChoice::AnnotateAll :
|
||||||
m_AnnotationChoice;
|
m_AnnotationChoice;
|
||||||
|
|
||||||
AnnotateWhat[m_AnnotationChoice]->SetValue( true );
|
AnnotateWhat[m_AnnotationChoice]->SetValue( true );
|
||||||
|
|
||||||
|
@ -267,15 +266,13 @@ void DIALOG_BOARD_REANNOTATE::FilterBackPrefix( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
/// Warn the user about the settings and try to reannotate the board
|
|
||||||
void DIALOG_BOARD_REANNOTATE::OnApplyClick( wxCommandEvent& event )
|
void DIALOG_BOARD_REANNOTATE::OnApplyClick( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxString warning;
|
wxString warning;
|
||||||
|
|
||||||
if( m_frame->GetBoard()->IsEmpty() )
|
if( m_frame->GetBoard()->IsEmpty() )
|
||||||
{
|
{
|
||||||
ShowReport( _( "No Board to reannotate!" ), RPT_SEVERITY_ERROR );
|
ShowReport( _( "No PCB to reannotate!" ), RPT_SEVERITY_ERROR );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,32 +298,35 @@ void DIALOG_BOARD_REANNOTATE::MakeSampleText( wxString& aMessage )
|
||||||
{
|
{
|
||||||
wxString tmp;
|
wxString tmp;
|
||||||
|
|
||||||
aMessage.Printf( "\n%s components will be reannotated. ",
|
aMessage.Printf( _( "\n%s components will be reannotated. " ),
|
||||||
_( AnnotateString[m_AnnotationChoice] ) );
|
_( AnnotateString[m_AnnotationChoice] ) );
|
||||||
|
|
||||||
if( !m_ExcludeList->GetValue().empty() )
|
if( !m_ExcludeList->GetValue().empty() )
|
||||||
aMessage += wxString::Format(
|
aMessage += wxString::Format( _( "\nAny reference types %s will not be annotated." ),
|
||||||
( "\nAny reference types %s will not be annotated." ), m_ExcludeList->GetValue() );
|
m_ExcludeList->GetValue() );
|
||||||
|
|
||||||
if( m_ExcludeLocked->GetValue() )
|
if( m_ExcludeLocked->GetValue() )
|
||||||
aMessage += wxString::Format( _( "\nLocked footprints will not be annotated" ) );
|
aMessage += wxString::Format( _( "\nLocked footprints will not be annotated" ) );
|
||||||
|
|
||||||
if( !m_AnnotateBack->GetValue() )
|
if( !m_AnnotateBack->GetValue() )
|
||||||
aMessage += wxString::Format(
|
aMessage += wxString::Format( _( "\nFront components will start at %s" ),
|
||||||
_( "\nFront components will start at %s" ), m_FrontRefDesStart->GetValue() );
|
m_FrontRefDesStart->GetValue() );
|
||||||
|
|
||||||
if( !m_AnnotateFront->GetValue() )
|
if( !m_AnnotateFront->GetValue() )
|
||||||
|
{
|
||||||
|
bool frontPlusOne = ( 0 == atoi( m_BackRefDesStart->GetValue() ) )
|
||||||
|
&& !m_AnnotateBack->GetValue();
|
||||||
|
|
||||||
aMessage += wxString::Format( _( "\nBack components will start at %s." ),
|
aMessage += wxString::Format( _( "\nBack components will start at %s." ),
|
||||||
( ( ( 0 == atoi( m_BackRefDesStart->GetValue() ) )
|
frontPlusOne ? _( "the last front component + 1" ) :
|
||||||
&& !m_AnnotateBack->GetValue() ) ?
|
m_BackRefDesStart->GetValue() );
|
||||||
_( "the last front component + 1" ).c_str() :
|
}
|
||||||
m_BackRefDesStart->GetValue().c_str() ) );
|
|
||||||
|
|
||||||
if( !m_FrontPrefix->GetValue().empty() )
|
if( !m_FrontPrefix->GetValue().empty() )
|
||||||
{
|
{
|
||||||
if( m_RemoveFrontPrefix->GetValue() )
|
if( m_RemoveFrontPrefix->GetValue() )
|
||||||
aMessage += wxString::Format(
|
aMessage += wxString::Format(
|
||||||
_( "\nFront components starting with %s will have the prefix removed." ),
|
_( "\nFront components starting with %s will have the prefix removed." ),
|
||||||
m_FrontPrefix->GetValue() );
|
m_FrontPrefix->GetValue() );
|
||||||
else
|
else
|
||||||
aMessage +=
|
aMessage +=
|
||||||
|
@ -338,30 +338,30 @@ void DIALOG_BOARD_REANNOTATE::MakeSampleText( wxString& aMessage )
|
||||||
{
|
{
|
||||||
if( m_RemoveBackPrefix->GetValue() )
|
if( m_RemoveBackPrefix->GetValue() )
|
||||||
aMessage += wxString::Format(
|
aMessage += wxString::Format(
|
||||||
_( "\nBack components starting with %s will have the prefix removed." ),
|
_( "\nBack components starting with %s will have the prefix removed." ),
|
||||||
m_BackPrefix->GetValue() );
|
m_BackPrefix->GetValue() );
|
||||||
else
|
else
|
||||||
aMessage +=
|
aMessage +=
|
||||||
wxString::Format( _( "\nBack components will have %s inserted as a prefix." ),
|
wxString::Format( _( "\nBack components will have %s inserted as a prefix." ),
|
||||||
m_BackPrefix->GetValue() );
|
m_BackPrefix->GetValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
aMessage += wxString::Format(
|
aMessage += wxString::Format(
|
||||||
_( "\nPrior to sorting on %s, the coordinates of which will be rounded to a %s, %s grid. " ),
|
_( "\nPrior to sorting by %s, the coordinates of which will be rounded to a %s, %s grid. " ),
|
||||||
( m_SortOnModules->GetValue() ? _( "footprints" ) : _( "references" ) ),
|
( m_SortOnModules->GetValue() ? _( "footprints" ) : _( "references" ) ),
|
||||||
MessageTextFromValue( m_Units, m_SortGridx, false ).c_str(),
|
MessageTextFromValue( m_Units, m_SortGridx, false ),
|
||||||
MessageTextFromValue( m_Units, m_SortGridy, false ).c_str() );
|
MessageTextFromValue( m_Units, m_SortGridy, false ) );
|
||||||
|
|
||||||
aMessage += wxString::Format( _( "\nThe schematic will %sbe updated." ),
|
if( m_UpdateSchematic->GetValue() )
|
||||||
( m_UpdateSchematic->GetValue() ? "" : _( "not " ) ) );
|
aMessage += _( "\nThe schematic will be updated." );
|
||||||
|
else
|
||||||
|
aMessage += _( "\nThe schematic will not be updated." );
|
||||||
|
|
||||||
ShowReport( aMessage, RPT_SEVERITY_INFO );
|
ShowReport( aMessage, RPT_SEVERITY_INFO );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
void DIALOG_BOARD_REANNOTATE::GetParameters()
|
||||||
/// Copies the dialog settings to the private variables
|
|
||||||
void DIALOG_BOARD_REANNOTATE::GetParameters( void )
|
|
||||||
{
|
{
|
||||||
m_SortCode = 0; //Convert radio button to sort direction code
|
m_SortCode = 0; //Convert radio button to sort direction code
|
||||||
|
|
||||||
|
@ -384,16 +384,20 @@ void DIALOG_BOARD_REANNOTATE::GetParameters( void )
|
||||||
|
|
||||||
if( m_GridIndex >= ( int ) m_Settings->m_Window.grid.sizes.size() )
|
if( m_GridIndex >= ( int ) m_Settings->m_Window.grid.sizes.size() )
|
||||||
{
|
{
|
||||||
m_SortGridx = DoubleValueFromString( EDA_UNITS::INCHES, m_Settings->m_Window.grid.user_grid_x, true );
|
m_SortGridx = DoubleValueFromString( EDA_UNITS::INCHES,
|
||||||
m_SortGridy = DoubleValueFromString( EDA_UNITS::INCHES, m_Settings->m_Window.grid.user_grid_y, true );
|
m_Settings->m_Window.grid.user_grid_x, true );
|
||||||
|
m_SortGridy = DoubleValueFromString( EDA_UNITS::INCHES,
|
||||||
|
m_Settings->m_Window.grid.user_grid_y, true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_SortGridx = DoubleValueFromString( EDA_UNITS::INCHES, m_Settings->m_Window.grid.sizes[ m_GridIndex ], true );
|
m_SortGridx = DoubleValueFromString( EDA_UNITS::INCHES,
|
||||||
|
m_Settings->m_Window.grid.sizes[ m_GridIndex ], true );
|
||||||
m_SortGridy = m_SortGridx;
|
m_SortGridy = m_SortGridx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for( wxRadioButton* button : AnnotateWhat )
|
for( wxRadioButton* button : AnnotateWhat )
|
||||||
{
|
{
|
||||||
if( button->GetValue() )
|
if( button->GetValue() )
|
||||||
|
@ -474,7 +478,7 @@ static bool ModuleCompare( const RefDesInfo& aA, const RefDesInfo& aB )
|
||||||
wxString DIALOG_BOARD_REANNOTATE::CoordTowxString( int aX, int aY )
|
wxString DIALOG_BOARD_REANNOTATE::CoordTowxString( int aX, int aY )
|
||||||
{
|
{
|
||||||
return wxString::Format( "%s, %s", MessageTextFromValue( m_Units, aX, false ),
|
return wxString::Format( "%s, %s", MessageTextFromValue( m_Units, aX, false ),
|
||||||
MessageTextFromValue( m_Units, aY, false ) );
|
MessageTextFromValue( m_Units, aY, false ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -482,13 +486,12 @@ wxString DIALOG_BOARD_REANNOTATE::CoordTowxString( int aX, int aY )
|
||||||
/// Break report into strings separated by \n and sent to the reporter
|
/// Break report into strings separated by \n and sent to the reporter
|
||||||
void DIALOG_BOARD_REANNOTATE::ShowReport( wxString aMessage, SEVERITY aSeverity )
|
void DIALOG_BOARD_REANNOTATE::ShowReport( wxString aMessage, SEVERITY aSeverity )
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t pos = 0, prev = 0;
|
size_t pos = 0, prev = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
pos = aMessage.ToStdString().find( '\n', prev );
|
pos = aMessage.ToStdString().find( '\n', prev );
|
||||||
m_MessageWindow->Report( ( aMessage.ToStdString().substr( prev, pos - prev ) ), aSeverity );
|
m_MessageWindow->Report( aMessage.ToStdString().substr( prev, pos - prev ), aSeverity );
|
||||||
prev = pos + 1;
|
prev = pos + 1;
|
||||||
} while( std::string::npos != pos );
|
} while( std::string::npos != pos );
|
||||||
|
|
||||||
|
@ -497,7 +500,7 @@ void DIALOG_BOARD_REANNOTATE::ShowReport( wxString aMessage, SEVERITY aSeverity
|
||||||
|
|
||||||
//
|
//
|
||||||
/// Create an audit trail of the changes
|
/// Create an audit trail of the changes
|
||||||
void DIALOG_BOARD_REANNOTATE::LogChangePlan( void )
|
void DIALOG_BOARD_REANNOTATE::LogChangePlan()
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
wxString message;
|
wxString message;
|
||||||
|
@ -563,7 +566,7 @@ void DIALOG_BOARD_REANNOTATE::LogModules( wxString& aMessage, std::vector<RefDes
|
||||||
//
|
//
|
||||||
/// Actually reannotate the board
|
/// Actually reannotate the board
|
||||||
/// @return false if fail, true if success
|
/// @return false if fail, true if success
|
||||||
bool DIALOG_BOARD_REANNOTATE::ReannotateBoard( void )
|
bool DIALOG_BOARD_REANNOTATE::ReannotateBoard()
|
||||||
{
|
{
|
||||||
std::string payload;
|
std::string payload;
|
||||||
std::vector<RefDesInfo> BadRefDes;
|
std::vector<RefDesInfo> BadRefDes;
|
||||||
|
@ -574,8 +577,9 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard( void )
|
||||||
|
|
||||||
if( !BuildModuleList( BadRefDes ) )
|
if( !BuildModuleList( BadRefDes ) )
|
||||||
{
|
{
|
||||||
ShowReport( "Selected options resulted in errors! Change them and try again.", RPT_SEVERITY_ERROR );
|
ShowReport( "Selected options resulted in errors! Change them and try again.",
|
||||||
return ( false );
|
RPT_SEVERITY_ERROR );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !BadRefDes.empty() )
|
if( !BadRefDes.empty() )
|
||||||
|
@ -592,7 +596,7 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard( void )
|
||||||
badrefdes += "at X, Y " + CoordTowxString( mod.x, mod.y ) + _( " on PCB " );
|
badrefdes += "at X, Y " + CoordTowxString( mod.x, mod.y ) + _( " on PCB " );
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowReport( ( message + badrefdes + "\n" ), RPT_SEVERITY_WARNING );
|
ShowReport( message + badrefdes + "\n", RPT_SEVERITY_WARNING );
|
||||||
message += _( "Yes will attempt reannotate. Proceed?" );
|
message += _( "Yes will attempt reannotate. Proceed?" );
|
||||||
|
|
||||||
if( !IsOK( m_frame, message ) )
|
if( !IsOK( m_frame, message ) )
|
||||||
|
@ -608,31 +612,31 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard( void )
|
||||||
{ // Create a netlist
|
{ // Create a netlist
|
||||||
newref = GetNewRefDes( mod );
|
newref = GetNewRefDes( mod );
|
||||||
|
|
||||||
if( NULL == newref )
|
if( nullptr == newref )
|
||||||
return ( false ); //Not found in changelist
|
return false; //Not found in changelist
|
||||||
|
|
||||||
netlist.AddComponent( //add to the netlist
|
//add to the netlist
|
||||||
new COMPONENT(
|
netlist.AddComponent( new COMPONENT( mod->GetFPID(), newref->NewRefDes,
|
||||||
mod->GetFPID(), newref->NewRefDes, mod->GetValue(), mod->GetPath() ) );
|
mod->GetValue(), mod->GetPath() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
netlist.Format( "pcb_netlist", &stringformatter, 0,
|
netlist.Format( "pcb_netlist", &stringformatter, 0,
|
||||||
CTL_OMIT_FILTERS | CTL_OMIT_NETS | CTL_OMIT_FILTERS );
|
CTL_OMIT_FILTERS | CTL_OMIT_NETS | CTL_OMIT_FILTERS );
|
||||||
|
|
||||||
payload = stringformatter.GetString(); //create netlist
|
payload = stringformatter.GetString(); //create netlist
|
||||||
|
|
||||||
bool attemptreannotate =
|
//Send netlist to eeSchema
|
||||||
m_frame->ReannotateSchematic( payload ); //Send netlist to eeSchema
|
bool attemptreannotate = m_frame->ReannotateSchematic( payload );
|
||||||
|
|
||||||
if( !attemptreannotate )
|
if( !attemptreannotate )
|
||||||
{ //Didn't get a valid reply
|
{ //Didn't get a valid reply
|
||||||
ShowReport( _( "\nReannotate failed!\n" ), RPT_SEVERITY_WARNING );
|
ShowReport( _( "\nReannotate failed!\n" ), RPT_SEVERITY_WARNING );
|
||||||
return ( false );
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //If updating schematic
|
} //If updating schematic
|
||||||
|
|
||||||
bool reannotateok = payload.size( ) == 0; //( 0 == payload.find( REANNOTATE_OK ) );
|
bool reannotateok = payload.size( ) == 0;
|
||||||
|
|
||||||
ShowReport( payload, reannotateok ? RPT_SEVERITY_ACTION : RPT_SEVERITY_ERROR );
|
ShowReport( payload, reannotateok ? RPT_SEVERITY_ACTION : RPT_SEVERITY_ERROR );
|
||||||
BOARD_COMMIT commit( m_frame );
|
BOARD_COMMIT commit( m_frame );
|
||||||
|
@ -644,8 +648,8 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard( void )
|
||||||
{ // Create a netlist
|
{ // Create a netlist
|
||||||
newref = GetNewRefDes( mod );
|
newref = GetNewRefDes( mod );
|
||||||
|
|
||||||
if( NULL == newref )
|
if( nullptr == newref )
|
||||||
return ( false );
|
return false;
|
||||||
|
|
||||||
commit.Modify( mod ); //Make a copy for undo
|
commit.Modify( mod ); //Make a copy for undo
|
||||||
mod->SetReference( newref->NewRefDes ); //Update the PCB reference
|
mod->SetReference( newref->NewRefDes ); //Update the PCB reference
|
||||||
|
@ -654,7 +658,7 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
commit.Push( "Geographic reannotation" );
|
commit.Push( "Geographic reannotation" );
|
||||||
return ( reannotateok );
|
return reannotateok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -721,7 +725,7 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
|
||||||
mod->Reference().GetPosition().y;
|
mod->Reference().GetPosition().y;
|
||||||
thismodule.roundedx = RoundToGrid( thismodule.x, m_SortGridx ); //Round to sort
|
thismodule.roundedx = RoundToGrid( thismodule.x, m_SortGridx ); //Round to sort
|
||||||
thismodule.roundedy = RoundToGrid( thismodule.y, m_SortGridy );
|
thismodule.roundedy = RoundToGrid( thismodule.y, m_SortGridy );
|
||||||
thismodule.Front = mod->GetLayer() == F_Cu ? true : false;
|
thismodule.Front = mod->GetLayer() == F_Cu;
|
||||||
thismodule.Action = UpdateRefDes; //Usually good
|
thismodule.Action = UpdateRefDes; //Usually good
|
||||||
|
|
||||||
if( thismodule.RefDesString.IsEmpty() )
|
if( thismodule.RefDesString.IsEmpty() )
|
||||||
|
@ -734,8 +738,8 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
|
||||||
thismodule.Action = InvalidRefDes; //do not change ref des such as 12 or +1, or L
|
thismodule.Action = InvalidRefDes; //do not change ref des such as 12 or +1, or L
|
||||||
}
|
}
|
||||||
|
|
||||||
thismodule.RefDesType =
|
//Get the type (R, C, etc)
|
||||||
thismodule.RefDesString.substr( 0, firstnum ); //Get the type (R, C, etc)
|
thismodule.RefDesType = thismodule.RefDesString.substr( 0, firstnum );
|
||||||
|
|
||||||
for( wxString excluded : m_ExcludeArray )
|
for( wxString excluded : m_ExcludeArray )
|
||||||
{
|
{
|
||||||
|
@ -783,20 +787,19 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
|
||||||
|
|
||||||
if( !m_FrontModules.empty() )
|
if( !m_FrontModules.empty() )
|
||||||
BuildChangeArray( m_FrontModules, atoi( m_FrontRefDesStart->GetValue() ),
|
BuildChangeArray( m_FrontModules, atoi( m_FrontRefDesStart->GetValue() ),
|
||||||
m_FrontPrefix->GetValue(), m_RemoveFrontPrefix->GetValue(),
|
m_FrontPrefix->GetValue(), m_RemoveFrontPrefix->GetValue(), aBadRefDes );
|
||||||
aBadRefDes ); //Create the ChangeArray for front
|
|
||||||
|
|
||||||
if( !m_BackModules.empty() )
|
if( !m_BackModules.empty() )
|
||||||
BuildChangeArray( m_BackModules, backstartrefdes, m_BackPrefix->GetValue(),
|
BuildChangeArray( m_BackModules, backstartrefdes, m_BackPrefix->GetValue(),
|
||||||
m_RemoveBackPrefix->GetValue(), aBadRefDes ); //and for the back
|
m_RemoveBackPrefix->GetValue(), aBadRefDes );
|
||||||
|
|
||||||
if( !m_ChangeArray.empty() )
|
if( !m_ChangeArray.empty() )
|
||||||
sort( m_ChangeArray.begin(), m_ChangeArray.end(),
|
sort( m_ChangeArray.begin(), m_ChangeArray.end(), ChangeArrayCompare );
|
||||||
ChangeArrayCompare ); //Sort the front modules
|
|
||||||
|
|
||||||
LogChangePlan();
|
LogChangePlan();
|
||||||
|
|
||||||
changearraysize = m_ChangeArray.size();
|
changearraysize = m_ChangeArray.size();
|
||||||
|
|
||||||
for( size_t i = 0; i < changearraysize; i++ ) //Scan through for duplicates if update or skip
|
for( size_t i = 0; i < changearraysize; i++ ) //Scan through for duplicates if update or skip
|
||||||
{
|
{
|
||||||
if( ( m_ChangeArray[i].Action != EmptyRefDes )
|
if( ( m_ChangeArray[i].Action != EmptyRefDes )
|
||||||
|
@ -806,7 +809,8 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
|
||||||
{
|
{
|
||||||
if( m_ChangeArray[i].NewRefDes == m_ChangeArray[j].NewRefDes )
|
if( m_ChangeArray[i].NewRefDes == m_ChangeArray[j].NewRefDes )
|
||||||
{
|
{
|
||||||
ShowReport( "Duplicate instances of " + m_ChangeArray[j].NewRefDes, RPT_SEVERITY_ERROR );
|
ShowReport( "Duplicate instances of " + m_ChangeArray[j].NewRefDes,
|
||||||
|
RPT_SEVERITY_ERROR );
|
||||||
|
|
||||||
if( errorcount++ > MAXERROR )
|
if( errorcount++ > MAXERROR )
|
||||||
{
|
{
|
||||||
|
@ -822,14 +826,15 @@ bool DIALOG_BOARD_REANNOTATE::BuildModuleList( std::vector<RefDesInfo>& aBadRefD
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( 0 == errorcount );
|
return ( 0 == errorcount );
|
||||||
} //void BuildModuleList( )
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
/// Scan through the module arrays and create the from -> to array
|
/// Scan through the module arrays and create the from -> to array
|
||||||
void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aModules,
|
void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aModules,
|
||||||
unsigned int aStartRefDes, wxString aPrefix, bool aRemovePrefix,
|
unsigned int aStartRefDes, wxString aPrefix,
|
||||||
std::vector<RefDesInfo>& aBadRefDes )
|
bool aRemovePrefix,
|
||||||
|
std::vector<RefDesInfo>& aBadRefDes )
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
RefDesChange change;
|
RefDesChange change;
|
||||||
|
@ -844,12 +849,11 @@ void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aModule
|
||||||
|
|
||||||
bool prefixpresent; //Prefix found
|
bool prefixpresent; //Prefix found
|
||||||
|
|
||||||
wxString logstring =
|
wxString logstring = ( aModules.front().Front ) ? _( "\n\nFront Modules" )
|
||||||
( aModules.front().Front ) ? _( "\n\nFront Modules" ) : _( "\n\nBack Modules" );
|
: _( "\n\nBack Modules" );
|
||||||
LogModules( logstring, aModules );
|
LogModules( logstring, aModules );
|
||||||
|
|
||||||
if( 0 != aStartRefDes ) //Initialize the change array if present
|
if( 0 != aStartRefDes ) //Initialize the change array if present
|
||||||
|
|
||||||
for( i = 0; i < m_RefDesTypes.size(); i++ )
|
for( i = 0; i < m_RefDesTypes.size(); i++ )
|
||||||
m_RefDesTypes[i].RefDesCount = aStartRefDes;
|
m_RefDesTypes[i].RefDesCount = aStartRefDes;
|
||||||
|
|
||||||
|
@ -883,25 +887,22 @@ void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<RefDesInfo>& aModule
|
||||||
Mod.RefDesType.erase( 0, prefixsize );
|
Mod.RefDesType.erase( 0, prefixsize );
|
||||||
|
|
||||||
for( i = 0; i < m_RefDesTypes.size(); i++ ) //See if it is in the types array
|
for( i = 0; i < m_RefDesTypes.size(); i++ ) //See if it is in the types array
|
||||||
|
|
||||||
if( m_RefDesTypes[i].RefDesType == Mod.RefDesType ) //Found it!
|
if( m_RefDesTypes[i].RefDesType == Mod.RefDesType ) //Found it!
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( i == m_RefDesTypes.size() )
|
if( i == m_RefDesTypes.size() )
|
||||||
{ //Wasn't in the types array so add it
|
{ //Wasn't in the types array so add it
|
||||||
newtype.RefDesType = Mod.RefDesType;
|
newtype.RefDesType = Mod.RefDesType;
|
||||||
newtype.RefDesCount =
|
newtype.RefDesCount = ( aStartRefDes == 0 ? 1 : aStartRefDes );
|
||||||
( aStartRefDes == 0 ? 1 : aStartRefDes ); //Add from start or 1
|
|
||||||
m_RefDesTypes.push_back( newtype );
|
m_RefDesTypes.push_back( newtype );
|
||||||
}
|
}
|
||||||
|
|
||||||
change.NewRefDes =
|
change.NewRefDes = m_RefDesTypes[i].RefDesType
|
||||||
m_RefDesTypes[i].RefDesType
|
+ std::to_string( m_RefDesTypes[i].RefDesCount++ );
|
||||||
+ std::to_string( m_RefDesTypes[i].RefDesCount++ ); //This is the new refdes
|
|
||||||
}
|
}
|
||||||
m_ChangeArray.push_back( change ); //Add to the change array
|
m_ChangeArray.push_back( change ); //Add to the change array
|
||||||
} //Loop
|
}
|
||||||
} //void BuildChangeArray( )
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
/// @returns the new refdes for this module
|
/// @returns the new refdes for this module
|
||||||
|
@ -910,10 +911,9 @@ RefDesChange* DIALOG_BOARD_REANNOTATE::GetNewRefDes( MODULE* aMod )
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for( i = 0; i < m_ChangeArray.size(); i++ )
|
for( i = 0; i < m_ChangeArray.size(); i++ )
|
||||||
|
|
||||||
if( aMod->m_Uuid == m_ChangeArray[i].Uuid )
|
if( aMod->m_Uuid == m_ChangeArray[i].Uuid )
|
||||||
return ( &m_ChangeArray[i] );
|
return ( &m_ChangeArray[i] );
|
||||||
|
|
||||||
ShowReport( _( "Module not found in changelist " ) + aMod->GetReference(), RPT_SEVERITY_ERROR );
|
ShowReport( _( "Module not found in changelist " ) + aMod->GetReference(), RPT_SEVERITY_ERROR );
|
||||||
return ( NULL ); //Should never happen
|
return nullptr; //Should never happen
|
||||||
}
|
}
|
||||||
|
|
|
@ -1059,7 +1059,7 @@ bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PCB_EDIT_FRAME::TestStandalone( void )
|
bool PCB_EDIT_FRAME::TestStandalone()
|
||||||
{
|
{
|
||||||
if( Kiface().IsSingle() )
|
if( Kiface().IsSingle() )
|
||||||
return false;
|
return false;
|
||||||
|
@ -1071,7 +1071,7 @@ bool PCB_EDIT_FRAME::TestStandalone( void )
|
||||||
if( !frame->IsShown() )
|
if( !frame->IsShown() )
|
||||||
{
|
{
|
||||||
wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
|
wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
|
||||||
KiCadSchematicFileExtension );
|
KiCadSchematicFileExtension );
|
||||||
|
|
||||||
// Maybe the file hasn't been converted to the new s-expression file format so
|
// Maybe the file hasn't been converted to the new s-expression file format so
|
||||||
// see if the legacy schematic file is still in play.
|
// see if the legacy schematic file is still in play.
|
||||||
|
@ -1093,7 +1093,9 @@ bool PCB_EDIT_FRAME::TestStandalone( void )
|
||||||
frame->Show( true );
|
frame->Show( true );
|
||||||
|
|
||||||
// bring ourselves back to the front
|
// bring ourselves back to the front
|
||||||
|
Raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; //Success!
|
return true; //Success!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -857,21 +857,18 @@ public:
|
||||||
bool FetchNetlistFromSchematic( NETLIST& aNetlist, FETCH_NETLIST_MODE aMode );
|
bool FetchNetlistFromSchematic( NETLIST& aNetlist, FETCH_NETLIST_MODE aMode );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ReannotateSchematic
|
* Sends a command to Eeschema to re-annotate the schematic
|
||||||
* @param aNetlist a NETLIST filled in by the caller.
|
* @param aNetlist a NETLIST filled in by the caller.
|
||||||
* aMessage is the error message from eeSchem
|
* aMessage is the error message from eeSchem
|
||||||
* if aCommit is false it just test, if true it updates the schematic
|
* if aCommit is false it just test, if true it updates the schematic
|
||||||
* @return false if failed due to standalone mode, true if a reply.
|
* @return false if failed due to standalone mode, true if a reply.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// Sends a Netlist packet to eeSchema.
|
|
||||||
/// @return true if success
|
|
||||||
bool ReannotateSchematic( std::string& aNetlist );
|
bool ReannotateSchematic( std::string& aNetlist );
|
||||||
|
|
||||||
|
/**
|
||||||
/// Test if standalone mode.
|
* Test if standalone mode.
|
||||||
/// @ return false if not in standalone.
|
* @return true if in standalone, opens eeSchema, and opens the schematic for this project
|
||||||
/// @return true if in standalone, opens eeSchema, and opens the schematic for this project
|
*/
|
||||||
bool TestStandalone( void );
|
bool TestStandalone( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue