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
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>
================================================================================
+eeschema:
......
......@@ -104,7 +104,8 @@ BOARD::~BOARD()
wxString BOARD::GetLayerName( int aLayerIndex ) const
{
// 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
// over-ridden by BOARD::SetLayerName()
......@@ -117,7 +118,8 @@ wxString BOARD::GetLayerName( int aLayerIndex ) const
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 )
return false;
......@@ -127,10 +129,13 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
return false;
// 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 )
return false;
if( ++layer == GetCopperLayerCount() )
layer = LAST_COPPER_LAYER;
}
m_Layer[aLayerIndex].m_Name = aLayerName;
......
......@@ -519,11 +519,17 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
fprintf( aFile, "ZoneGridSize %d\n", g_GridRoutingSize );
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 )
{
fprintf( aFile, "Layer[%d] %s %s\n", layer,
CONV_TO_UTF8( aBoard->GetLayerName(layer) ),
LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
if( layerMask & 1 )
{
fprintf( aFile, "Layer[%d] %s %s\n", layer,
CONV_TO_UTF8( aBoard->GetLayerName(layer) ),
LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
}
}
fprintf( aFile, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth );
......
......@@ -698,8 +698,7 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
m_SelLayerBox->Clear();
int ii, jj;
for( ii = 0, jj = 0; ii <= EDGE_N; ii++ )
for( int layer=0, listNdx=0; layer <= EDGE_N; layer++ )
{
// List to append hotkeys in layer box selection
static const int HK_SwitchLayer[EDGE_N + 1] = {
......@@ -721,14 +720,17 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
HK_SWITCH_LAYER_TO_COMPONENT
};
if( (g_TabOneLayerMask[ii] & layer_mask) )
if( (g_TabOneLayerMask[layer] & layer_mask) )
{
wxString msg = m_Pcb->GetLayerName( ii );
msg = AddHotkeyName( msg, s_Board_Editor_Hokeys_Descr, HK_SwitchLayer[ii] );
wxString msg = m_Pcb->GetLayerName( layer );
msg = AddHotkeyName( msg, s_Board_Editor_Hokeys_Descr, HK_SwitchLayer[layer] );
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() );
jj++;
listNdx++;
}
}
......
......@@ -72,12 +72,12 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/* 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;
ActiveScreen = GetScreen();
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY );
if( EraseBg )
......@@ -85,9 +85,10 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC );
Trace_Pcb( DC, GR_OR );
TraceWorkSheet( DC, GetScreen(), 0 );
Trace_Pcb( DC, GR_OR );
Affiche_Status_Box();
if( DrawPanel->ManageCurseur )
......@@ -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:
void BOARD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
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