From eae1a7498d0cfad3521a36ba00c4ae007526884c Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Thu, 1 May 2008 06:21:07 +0000 Subject: [PATCH] layer name in *.brd file fixes --- change_log.txt | 6 ++++++ pcbnew/class_board.cpp | 11 ++++++++--- pcbnew/ioascii.cpp | 14 ++++++++++---- pcbnew/tool_pcb.cpp | 16 +++++++++------- pcbnew/tracepcb.cpp | 12 +++++------- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/change_log.txt b/change_log.txt index e9868cc7be..5bda6ba995 100644 --- a/change_log.txt +++ b/change_log.txt @@ -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 +================================================================================ ++pcbnew + * Fixed bugs in layer name handling within the BOARD + + 2008-Apr-30 UPDATE Jean-Pierre Charras ================================================================================ +eeschema: diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 91c6d246ee..6239e77c33 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -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; layerGetCopperLayerCount() ); - for( int layer=0; layerGetCopperLayerCount(); ++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 ); diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 72a5992b87..ce1c3e3221 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -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++; } } diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 7aee53e262..d6c6d95f7f 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -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 );