Commit eae1a749 authored by dickelbeck's avatar dickelbeck

layer name in *.brd file fixes

parent 0ac832f0
...@@ -6,6 +6,12 @@ Please add newer entries at the top, list the date and your name with ...@@ -6,6 +6,12 @@ Please add newer entries at the top, list the date and your name with
email address. email address.
2008-May-1 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
* Fixed bugs in layer name handling within the BOARD
2008-Apr-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Apr-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+eeschema: +eeschema:
......
...@@ -104,7 +104,8 @@ BOARD::~BOARD() ...@@ -104,7 +104,8 @@ BOARD::~BOARD()
wxString BOARD::GetLayerName( int aLayerIndex ) const wxString BOARD::GetLayerName( int aLayerIndex ) const
{ {
// copper layer names are stored in the BOARD. // copper layer names are stored in the BOARD.
if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount() ) if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount()
|| aLayerIndex == LAST_COPPER_LAYER )
{ {
// default names were set in BOARD::BOARD() but they may be // default names were set in BOARD::BOARD() but they may be
// over-ridden by BOARD::SetLayerName() // over-ridden by BOARD::SetLayerName()
...@@ -117,7 +118,8 @@ wxString BOARD::GetLayerName( int aLayerIndex ) const ...@@ -117,7 +118,8 @@ wxString BOARD::GetLayerName( int aLayerIndex ) const
bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName ) bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
{ {
if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount() ) if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount()
|| aLayerIndex==LAST_COPPER_LAYER )
{ {
if( aLayerName == wxEmptyString || aLayerName.Len() > 20 ) if( aLayerName == wxEmptyString || aLayerName.Len() > 20 )
return false; return false;
...@@ -127,10 +129,13 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName ) ...@@ -127,10 +129,13 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
return false; return false;
// ensure unique-ness of layer names // ensure unique-ness of layer names
for( int layer=0; layer<GetCopperLayerCount(); ++layer ) for( int layer=0; layer<GetCopperLayerCount() || layer==LAST_COPPER_LAYER; )
{ {
if( layer!=aLayerIndex && aLayerName == m_Layer[layer].m_Name ) if( layer!=aLayerIndex && aLayerName == m_Layer[layer].m_Name )
return false; return false;
if( ++layer == GetCopperLayerCount() )
layer = LAST_COPPER_LAYER;
} }
m_Layer[aLayerIndex].m_Name = aLayerName; m_Layer[aLayerIndex].m_Name = aLayerName;
......
...@@ -519,12 +519,18 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard ) ...@@ -519,12 +519,18 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
fprintf( aFile, "ZoneGridSize %d\n", g_GridRoutingSize ); fprintf( aFile, "ZoneGridSize %d\n", g_GridRoutingSize );
fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() ); fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() );
for( int layer=0; layer<aBoard->GetCopperLayerCount(); ++layer )
int layerMask = g_TabAllCopperLayerMask[aBoard->GetCopperLayerCount()-1];
for( int layer=0; layerMask; ++layer, layerMask>>=1 )
{
if( layerMask & 1 )
{ {
fprintf( aFile, "Layer[%d] %s %s\n", layer, fprintf( aFile, "Layer[%d] %s %s\n", layer,
CONV_TO_UTF8( aBoard->GetLayerName(layer) ), CONV_TO_UTF8( aBoard->GetLayerName(layer) ),
LAYER::ShowType( aBoard->GetLayerType( layer ) ) ); LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
} }
}
fprintf( aFile, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth ); fprintf( aFile, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth );
for( int ii = 0; ii < HISTORY_NUMBER; ii++ ) for( int ii = 0; ii < HISTORY_NUMBER; ii++ )
......
...@@ -698,8 +698,7 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) ...@@ -698,8 +698,7 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
m_SelLayerBox->Clear(); m_SelLayerBox->Clear();
int ii, jj; for( int layer=0, listNdx=0; layer <= EDGE_N; layer++ )
for( ii = 0, jj = 0; ii <= EDGE_N; ii++ )
{ {
// List to append hotkeys in layer box selection // List to append hotkeys in layer box selection
static const int HK_SwitchLayer[EDGE_N + 1] = { static const int HK_SwitchLayer[EDGE_N + 1] = {
...@@ -721,14 +720,17 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) ...@@ -721,14 +720,17 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
HK_SWITCH_LAYER_TO_COMPONENT HK_SWITCH_LAYER_TO_COMPONENT
}; };
if( (g_TabOneLayerMask[ii] & layer_mask) ) if( (g_TabOneLayerMask[layer] & layer_mask) )
{ {
wxString msg = m_Pcb->GetLayerName( ii ); wxString msg = m_Pcb->GetLayerName( layer );
msg = AddHotkeyName( msg, s_Board_Editor_Hokeys_Descr, HK_SwitchLayer[ii] ); msg = AddHotkeyName( msg, s_Board_Editor_Hokeys_Descr, HK_SwitchLayer[layer] );
m_SelLayerBox->Append( msg ); m_SelLayerBox->Append( msg );
m_SelLayerBox->SetClientData( jj, (void*) ii );
D(printf("appending layername=%s, ndx=%d, layer=%d\n", CONV_TO_UTF8(msg), listNdx, layer );)
m_SelLayerBox->SetClientData( listNdx, (void*) layer );
length = MAX( length, msg.Len() ); length = MAX( length, msg.Len() );
jj++; listNdx++;
} }
} }
......
...@@ -72,12 +72,12 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -72,12 +72,12 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/* Draw the BOARD, and others elements : axis, grid .. /* Draw the BOARD, and others elements : axis, grid ..
*/ */
{ {
PCB_SCREEN* Screen = (PCB_SCREEN*)GetScreen(); PCB_SCREEN* screen = GetScreen();
if( !m_Pcb || !Screen ) if( !m_Pcb || !screen )
return; return;
ActiveScreen = GetScreen(); ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
if( EraseBg ) if( EraseBg )
...@@ -85,9 +85,10 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -85,9 +85,10 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
Trace_Pcb( DC, GR_OR );
TraceWorkSheet( DC, GetScreen(), 0 ); TraceWorkSheet( DC, GetScreen(), 0 );
Trace_Pcb( DC, GR_OR );
Affiche_Status_Box(); Affiche_Status_Box();
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
...@@ -98,9 +99,6 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -98,9 +99,6 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
} }
#define DRAW_CUR_LAYER_LAST 1
/* should make the function below this one: /* should make the function below this one:
void BOARD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, void BOARD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset ); int aDrawMode, const wxPoint& offset = ZeroOffset );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment