From ce04867e841a861c7bae9403b16cc0c82a67bd9f Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Tue, 19 Feb 2008 00:30:10 +0000 Subject: [PATCH] BOARD::GetLayerName() --- pcbnew/class_board_item.cpp | 35 +++++----- pcbnew/class_edge_mod.cpp | 75 ++++++++++----------- pcbnew/class_module.cpp | 126 +++++++++++++++++++----------------- pcbnew/class_pad.cpp | 79 +++++++++++----------- pcbnew/class_track.cpp | 25 ++++--- 5 files changed, 178 insertions(+), 162 deletions(-) diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index 17b4eab527..b253d0f744 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -38,7 +38,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const case TYPEMODULE: text << _( "Footprint" ) << wxT( " " ) << ( (MODULE*) item )->GetReference(); - text << wxT( " (" ) << ReturnPcbLayerName( item->m_Layer ).Trim() << wxT( ")" ); + text << wxT( " (" ) << aPcb->GetLayerName( item->m_Layer ).Trim() << wxT( ")" ); break; case TYPEPAD: @@ -48,15 +48,15 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const if ( (pad->m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS ) text << _("all copper layers"); else if( (pad->m_Masque_Layer & CUIVRE_LAYER) == CUIVRE_LAYER ) - text << _("copper layer"); + text << aPcb->GetLayerName( COPPER_LAYER_N ).Trim(); else if( (pad->m_Masque_Layer & CMP_LAYER) == CMP_LAYER ) - text << _("cmp layer"); + text << aPcb->GetLayerName( LAYER_CMP_N ); else text << _("???"); text << _( ") of " ) << ( (MODULE*) GetParent() )->GetReference(); break; case TYPEDRAWSEGMENT: - text << _( "Pcb Graphic" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); // @todo: extend text + text << _( "Pcb Graphic" ) << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); // @todo: extend text break; case TYPETEXTE: @@ -65,7 +65,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const text << ( (TEXTE_PCB*) item )->m_Text; else text += ( (TEXTE_PCB*) item )->m_Text.Left( 10 ) + wxT( ".." ); - text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); + text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); break; case TYPETEXTEMODULE: @@ -128,7 +128,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const } text << cp; - text << wxT( " (" ) << ReturnPcbLayerName( ((EDGE_MODULE*) item )->m_Layer ).Trim() << wxT( ")" ); + text << wxT( " (" ) << aPcb->GetLayerName( ((EDGE_MODULE*) item )->m_Layer ).Trim() << wxT( ")" ); text << _( " of " ) << ( (MODULE*) GetParent() )->GetReference(); break; @@ -145,7 +145,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const { text << wxT( " [" ) << net->m_Netname << wxT( "]" ); } - text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim() + text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim() << wxT(" ") << _("Net:") << ((TRACK*)item)->GetNet() << wxT(" ") << _("Length:") << valeur_param( (int) ((TRACK*)item)->GetLength(), txt ); } @@ -154,9 +154,10 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const case TYPEZONE_CONTAINER: text = _( "Zone Outline" ); { - ZONE_CONTAINER* area = (ZONE_CONTAINER*) this; - int ncont = area->m_Poly->GetContour(area->m_CornerSelection); - if ( ncont ) text << wxT(" ") << _("(Cutout)"); + ZONE_CONTAINER* area = (ZONE_CONTAINER*) this; + int ncont = area->m_Poly->GetContour(area->m_CornerSelection); + if( ncont ) + text << wxT(" ") << _("(Cutout)"); } text << wxT( " " ); { @@ -164,7 +165,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp ); text << TimeStampText; } - if ( ((ZONE_CONTAINER*) item)->GetNet() >= 0 ) + if( ((ZONE_CONTAINER*) item)->GetNet() >= 0 ) { net = aPcb->FindNet( ( (ZONE_CONTAINER*) item )->GetNet() ); if( net ) @@ -172,12 +173,12 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const text << wxT( " [" ) << net->m_Netname << wxT( "]" ); } } - else // A netcode < 0 is an error flag (Netname not found or area not initialised) + else // A netcode < 0 is an error flag (Netname not found or area not initialised) { text << wxT( " [" ) << ( (ZONE_CONTAINER*) item )->m_Netname << wxT( "]" ); text << wxT(" <") << _("Not Found") << wxT(">"); } - text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); + text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); break; case TYPEZONE: @@ -193,7 +194,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const { text << wxT( " [" ) << net->m_Netname << wxT( "]" ); } - text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); + text << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim(); break; case TYPEVIA: @@ -221,8 +222,8 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const int topLayer; int botLayer; via->ReturnLayerPair( &topLayer, &botLayer ); - text << _( " on " ) << ReturnPcbLayerName( topLayer).Trim() << wxT(" <-> ") - << ReturnPcbLayerName( botLayer ).Trim(); + text << _( " on " ) << aPcb->GetLayerName( topLayer).Trim() << wxT(" <-> ") + << aPcb->GetLayerName( botLayer ).Trim(); } } break; @@ -238,7 +239,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const case TYPEMIRE: valeur_param( ((MIREPCB*)item)->m_Size, msg ); - text << _( "Target" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim() + text << _( "Target" ) << _( " on " ) << aPcb->GetLayerName( item->GetLayer() ).Trim() << wxT( " " ) << _( "size" ) << wxT( " " ) << msg ; break; diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 54bc4e5fa7..0a029d626a 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -28,7 +28,7 @@ /* class EDGE_MODULE ( contour de module ) */ /******************************************/ -EDGE_MODULE::EDGE_MODULE( MODULE* parent ) : +EDGE_MODULE::EDGE_MODULE( MODULE* parent ) : BOARD_ITEM( parent, TYPEEDGEMODULE ) { m_Width = 0; @@ -164,10 +164,10 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, zoom = screen->GetZoom(); type_trace = m_Shape; - - ux0 = m_Start.x - offset.x; + + ux0 = m_Start.x - offset.x; uy0 = m_Start.y - offset.y; - + dx = m_End.x - offset.x; dy = m_End.y - offset.y; @@ -269,7 +269,7 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, } -// see class_edge_mod.h +// see class_edge_mod.h void EDGE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) { wxString bufcar; @@ -277,7 +277,11 @@ void EDGE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) MODULE* module = (MODULE*) m_Parent; if( !module ) return; - + + BOARD* board = (BOARD*) module->m_Parent; + if( !board ) + return; + frame->MsgPanel->EraseMsgBox(); Affiche_1_Parametre( frame, 1, _( "Seg" ), wxEmptyString, DARKCYAN ); @@ -288,10 +292,9 @@ void EDGE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) Affiche_1_Parametre( frame, 24, _( "TimeStamp" ), bufcar, BROWN ); - Affiche_1_Parametre( frame, 34, _( "Mod Layer" ), ReturnPcbLayerName( module->GetLayer() ), RED ); + Affiche_1_Parametre( frame, 34, _( "Mod Layer" ), board->GetLayerName( module->GetLayer() ), RED ); - Affiche_1_Parametre( frame, 44, _( "Seg Layer" ), - ReturnPcbLayerName( module->GetLayer() ), RED ); + Affiche_1_Parametre( frame, 44, _( "Seg Layer" ), board->GetLayerName( module->GetLayer() ), RED ); valeur_param( m_Width, bufcar ); Affiche_1_Parametre( frame, 54, _( "Width" ), bufcar, BLUE ); @@ -334,7 +337,7 @@ bool EDGE_MODULE::Save( FILE* aFile ) const m_End0.x, m_End0.y, m_PolyCount, m_Width, m_Layer ); - + int* pInt; pInt = m_PolyList; for( int i=0; i 5); } - - + + /****************************************************************/ @@ -368,7 +371,7 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File, * - Segment (line) * - Arc * - Polygon - * + * */ { int ii, * ptr; @@ -459,12 +462,12 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File, if( m_Width > MAX_WIDTH ) m_Width = MAX_WIDTH; - // Check for a reasonnable layer: - // m_Layer must be >= FIRST_NON_COPPER_LAYER, but because microwave footprints - // can use the copper layers m_Layer < FIRST_NON_COPPER_LAYER is allowed. - // @todo: changes use of EDGE_MODULE these footprints and allows only m_Layer >= FIRST_NON_COPPER_LAYER - if ( (m_Layer < 0) || (m_Layer > LAST_NON_COPPER_LAYER) ) - m_Layer = SILKSCREEN_N_CMP; + // Check for a reasonnable layer: + // m_Layer must be >= FIRST_NON_COPPER_LAYER, but because microwave footprints + // can use the copper layers m_Layer < FIRST_NON_COPPER_LAYER is allowed. + // @todo: changes use of EDGE_MODULE these footprints and allows only m_Layer >= FIRST_NON_COPPER_LAYER + if ( (m_Layer < 0) || (m_Layer > LAST_NON_COPPER_LAYER) ) + m_Layer = SILKSCREEN_N_CMP; return error; } @@ -479,23 +482,23 @@ bool EDGE_MODULE::HitTest( const wxPoint& ref_pos ) { int uxf, uyf; int rayon, dist; - int dx, dy, spot_cX, spot_cY; + int dx, dy, spot_cX, spot_cY; int ux0, uy0; - ux0 = m_Start.x; + ux0 = m_Start.x; uy0 = m_Start.y; - - uxf = m_End.x; + + uxf = m_End.x; uyf = m_End.y; switch( m_Shape ) { case S_SEGMENT: /* recalcul des coordonnees avec ux0,uy0 = origine des coord. */ - spot_cX = ref_pos.x - ux0; + spot_cX = ref_pos.x - ux0; spot_cY = ref_pos.y - uy0; - - dx = uxf - ux0; + + dx = uxf - ux0; dy = uyf - uy0; if( DistanceTest( m_Width/2, dx, dy, spot_cX, spot_cY ) ) return true; @@ -522,7 +525,7 @@ bool EDGE_MODULE::HitTest( const wxPoint& ref_pos ) if( endAngle > 3600 ) { - stAngle -= 3600; + stAngle -= 3600; endAngle -= 3600; } @@ -532,7 +535,7 @@ bool EDGE_MODULE::HitTest( const wxPoint& ref_pos ) break; } - return false; // an unknown m_Shape also returns false + return false; // an unknown m_Shape also returns false } @@ -540,14 +543,14 @@ bool EDGE_MODULE::HitTest( const wxPoint& ref_pos ) /** * Function Show * is used to output the object tree, currently for debugging only. - * @param nestLevel An aid to prettier tree indenting, and is the level + * @param nestLevel An aid to prettier tree indenting, and is the level * of nesting of this object within the overall tree. * @param os The ostream& to output to. */ void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) { const char* cp; - + switch( m_Shape ) { case S_SEGMENT: cp = "line"; break; @@ -561,14 +564,14 @@ void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) case S_POLYGON: cp = "polygon"; break; default: cp = "??EDGE??"; break; } - + // for now, make it look like XML: - NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << " type=\"" << cp << "\">"; - + os << " "; os << " "; - + os << " \n"; } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 1f706f30c5..ffbc3d6e50 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -58,7 +58,7 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset /*************************************************/ /* Constructeur de la classe MODULE */ -MODULE::MODULE( BOARD* parent ) : +MODULE::MODULE( BOARD* parent ) : BOARD_ITEM( parent, TYPEMODULE ) { m_Pads = NULL; @@ -142,7 +142,7 @@ void MODULE::Copy( MODULE* Module ) m_CntRot90 = Module->m_CntRot90; m_CntRot180 = Module->m_CntRot180; m_LastEdit_Time = Module->m_LastEdit_Time; - m_Path = Module->m_Path; //is this correct behavior? + m_Path = Module->m_Path; //is this correct behavior? m_TimeStamp = GetTimeStamp(); /* Copy des structures auxiliaires: Reference et value */ @@ -210,9 +210,9 @@ void MODULE::Copy( MODULE* Module ) /* Copy des elements complementaires Drawings 3D */ m_3D_Drawings->Copy( Module->m_3D_Drawings ); - + Struct3D_Master* Struct3D, * NewStruct3D, * CurrStruct3D; - + Struct3D = (Struct3D_Master*) Module->m_3D_Drawings->Pnext; CurrStruct3D = m_3D_Drawings; for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext ) @@ -350,10 +350,10 @@ bool MODULE::Save( FILE* aFile ) const { char statusTxt[8]; BOARD_ITEM* item; - + if( GetState( DELETED ) ) return true; - + bool rc = false; fprintf( aFile, "$MODULE %s\n", CONV_TO_UTF8( m_LibRef ) ); @@ -364,7 +364,7 @@ bool MODULE::Save( FILE* aFile ) const statusTxt[0] = 'F'; else statusTxt[0] = '~'; - + if( m_ModuleStatus & MODULE_is_PLACED ) statusTxt[1] = 'P'; else @@ -388,7 +388,7 @@ bool MODULE::Save( FILE* aFile ) const } fprintf( aFile, "Sc %8.8lX\n", m_TimeStamp ); - fprintf( aFile, "AR %s\n", CONV_TO_UTF8(m_Path) ); + fprintf( aFile, "AR %s\n", CONV_TO_UTF8(m_Path) ); fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 ); // attributes @@ -405,7 +405,7 @@ bool MODULE::Save( FILE* aFile ) const // save reference if( !m_Reference->Save( aFile ) ) goto out; - + // save value if( !m_Value->Save( aFile ) ) goto out; @@ -422,9 +422,9 @@ bool MODULE::Save( FILE* aFile ) const break; default: -#if defined(DEBUG) +#if defined(DEBUG) printf( "MODULE::Save() ignoring type %d\n", item->Type() ); -#endif +#endif break; } } @@ -438,12 +438,12 @@ bool MODULE::Save( FILE* aFile ) const Write_3D_Descr( aFile ); fprintf( aFile, "$EndMODULE %s\n", CONV_TO_UTF8( m_LibRef ) ); - + rc = true; -out: +out: return rc; } - + /***************************************/ int MODULE::Write_3D_Descr( FILE* File ) const @@ -638,7 +638,7 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) case 'S': sscanf( PtLine, " %lX", &m_TimeStamp ); break; - + case 'O': /* (Op)tions de placement auto */ itmp1 = itmp2 = 0; @@ -657,19 +657,19 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) m_CntRot90 |= itmp1 << 4; break; - case 'A': - if(Line[1] == 't'){ - /* At = (At)tributs du module */ - if( strstr( PtLine, "SMD" ) ) - m_Attributs |= MOD_CMS; - if( strstr( PtLine, "VIRTUAL" ) ) - m_Attributs |= MOD_VIRTUAL; - } - if(Line[1] == 'R'){ - //alternate reference, e.g. /478C2408/478AD1B6 - sscanf( PtLine, " %s", BufLine ); - m_Path = CONV_FROM_UTF8(BufLine); - } + case 'A': + if(Line[1] == 't'){ + /* At = (At)tributs du module */ + if( strstr( PtLine, "SMD" ) ) + m_Attributs |= MOD_CMS; + if( strstr( PtLine, "VIRTUAL" ) ) + m_Attributs |= MOD_VIRTUAL; + } + if(Line[1] == 'R'){ + //alternate reference, e.g. /478C2408/478AD1B6 + sscanf( PtLine, " %s", BufLine ); + m_Path = CONV_FROM_UTF8(BufLine); + } break; case 'T': /* lecture des textes modules */ @@ -718,8 +718,8 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) else if( layer == CMP_N ) layer = SILKSCREEN_N_CMP; - DrawText->SetLayer( layer ); - + DrawText->SetLayer( layer ); + /* calcul de la position vraie */ DrawText->SetDrawCoord(); /* Lecture de la chaine "text" */ @@ -781,22 +781,22 @@ void MODULE::SetPosition( const wxPoint& newpos ) int deltaY = newpos.y - m_Pos.y; /* deplacement de l'ancre */ - m_Pos.x += deltaX; + m_Pos.x += deltaX; m_Pos.y += deltaY; /* deplacement de la reference */ - m_Reference->m_Pos.x += deltaX; + m_Reference->m_Pos.x += deltaX; m_Reference->m_Pos.y += deltaY; /* deplacement de la Valeur */ - m_Value->m_Pos.x += deltaX; + m_Value->m_Pos.x += deltaX; m_Value->m_Pos.y += deltaY; /* deplacement des pastilles */ D_PAD* pad = m_Pads; for( ; pad != NULL; pad = (D_PAD*) pad->Pnext ) { - pad->m_Pos.x += deltaX; + pad->m_Pos.x += deltaX; pad->m_Pos.y += deltaY; } @@ -816,7 +816,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) case TYPETEXTEMODULE: { TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct; - pt_texte->m_Pos.x += deltaX; + pt_texte->m_Pos.x += deltaX; pt_texte->m_Pos.y += deltaY; break; } @@ -1048,6 +1048,7 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) int pos; bool flag = FALSE; wxString msg; + BOARD* board = (BOARD*) m_Parent; frame->MsgPanel->EraseMsgBox(); /* Effacement de la zone message */ if( frame->m_Ident != PCB_FRAME ) @@ -1076,14 +1077,15 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) } pos += 12; - Affiche_1_Parametre( frame, pos, _( "Layer" ), ReturnPcbLayerName( m_Layer ), RED ); + Affiche_1_Parametre( frame, pos, _( "Layer" ), board->GetLayerName( m_Layer ), RED ); pos += 6; EDA_BaseStruct* PtStruct = m_Pads; nbpad = 0; while( PtStruct ) { - nbpad++; PtStruct = PtStruct->Pnext; + nbpad++; + PtStruct = PtStruct->Pnext; } msg.Printf( wxT( "%d" ), nbpad ); @@ -1126,22 +1128,22 @@ bool MODULE::HitTest( const wxPoint& refPos ) /* Calcul des coord souris dans le repere module */ int spot_cX = refPos.x - m_Pos.x; int spot_cY = refPos.y - m_Pos.y; - + RotatePoint( &spot_cX, &spot_cY, -m_Orient ); /* la souris est-elle dans ce rectangle : */ if( m_BoundaryBox.Inside( spot_cX, spot_cY ) ) return true; -/* no +/* no // The GENERAL_COLLECTOR needs these two tests in order to find a MODULE // when the user clicks on its text. Keep these 2, needed in OnRightClick(). if( m_Reference->HitTest( refPos ) ) return true; - + if( m_Value->HitTest( refPos ) ) return true; -*/ +*/ return false; } @@ -1171,18 +1173,18 @@ bool MODULE::HitTest( EDA_Rect& refArea ) } -// see class_module.h -SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, +// see class_module.h +SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ) { KICAD_T stype; SEARCH_RESULT result = SEARCH_CONTINUE; const KICAD_T* p = scanTypes; bool done = false; - + #if 0 && defined(DEBUG) std::cout << GetClass().mb_str() << ' '; -#endif +#endif while( !done ) { @@ -1193,23 +1195,23 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, result = inspector->Inspect( this, testData ); // inspect me ++p; break; - + case TYPEPAD: result = IterateForward( m_Pads, inspector, testData, p ); ++p; break; - + case TYPETEXTEMODULE: result = inspector->Inspect( m_Reference, testData ); if( result == SEARCH_QUIT ) break; - + result = inspector->Inspect( m_Value, testData ); if( result == SEARCH_QUIT ) break; // m_Drawings can hold TYPETEXTMODULE also, so fall thru - + case TYPEEDGEMODULE: result = IterateForward( m_Drawings, inspector, testData, p ); // skip over any types handled in the above call. @@ -1225,17 +1227,17 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, break; } break; - + default: done = true; break; } - + if( result == SEARCH_QUIT ) break; } - return result; + return result; } @@ -1243,24 +1245,26 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, /** * Function Show * is used to output the object tree, currently for debugging only. - * @param nestLevel An aid to prettier tree indenting, and is the level + * @param nestLevel An aid to prettier tree indenting, and is the level * of nesting of this object within the overall tree. * @param os The ostream& to output to. */ void MODULE::Show( int nestLevel, std::ostream& os ) { + BOARD* board = (BOARD*) m_Parent; + // for now, make it look like XML, expand on this later. NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << - " ref=\"" << m_Reference->m_Text.mb_str() << '"' << + " ref=\"" << m_Reference->m_Text.mb_str() << '"' << " value=\"" << m_Value->m_Text.mb_str() << '"' << - " layer=\"" << ReturnPcbLayerName(m_Layer,true).mb_str() << '"' << + " layer=\"" << board->GetLayerName(m_Layer).mb_str() << '"' << ">\n"; - NestedSpace( nestLevel+1, os ) << + NestedSpace( nestLevel+1, os ) << "\n"; - NestedSpace( nestLevel+1, os ) << "\n"; - + NestedSpace( nestLevel+1, os ) << "\n"; + EDA_BaseStruct* p; NestedSpace( nestLevel+1, os ) << "\n"; @@ -1268,19 +1272,19 @@ void MODULE::Show( int nestLevel, std::ostream& os ) for( ; p; p = p->Pnext ) p->Show( nestLevel+2, os ); NestedSpace( nestLevel+1, os ) << "\n"; - + NestedSpace( nestLevel+1, os ) << "\n"; p = m_Drawings; for( ; p; p = p->Pnext ) p->Show( nestLevel+2, os ); NestedSpace( nestLevel+1, os ) << "\n"; - + p = m_Son; for( ; p; p = p->Pnext ) { p->Show( nestLevel+1, os ); } - + NestedSpace( nestLevel, os ) << "\n"; } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index d34af53580..3532f3ce51 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -241,8 +241,8 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int WinEDA_BasePcbFrame* frame = NULL; wxPoint shape_pos; - PCB_SCREEN* screen = panel ? - (PCB_SCREEN*) panel->m_Parent->m_CurrentScreen : + PCB_SCREEN* screen = panel ? + (PCB_SCREEN*) panel->m_Parent->m_CurrentScreen : (PCB_SCREEN*) ActiveScreen; if ( panel ) // Use current frame setting @@ -263,7 +263,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int if( m_Masque_Layer & CMP_LAYER ) color = g_PadCMPColor; - + if( m_Masque_Layer & CUIVRE_LAYER ) color |= g_PadCUColor; @@ -330,40 +330,40 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int } - // if PAD_SMD pad and high contrast mode + // if PAD_SMD pad and high contrast mode if( m_Attribut==PAD_SMD && DisplayOpt.ContrastModeDisplay ) { - // when routing tracks + // when routing tracks if( frame && frame->m_ID_current_state == ID_TRACK_BUTT ) { int routeTop = screen->m_Route_Layer_TOP; int routeBot = screen->m_Route_Layer_BOTTOM; - - // if routing between copper and component layers, - // or the current layer is one of said 2 external copper layers, - // then highlight only the current layer. - if( ((1<m_Active_Layer) & (CUIVRE_LAYER | CMP_LAYER)) ) + + // if routing between copper and component layers, + // or the current layer is one of said 2 external copper layers, + // then highlight only the current layer. + if( ((1<m_Active_Layer) & (CUIVRE_LAYER | CMP_LAYER)) ) { if( !IsOnLayer( screen->m_Active_Layer ) ) { color &= ~MASKCOLOR; color |= DARKDARKGRAY; - } + } } - + // else routing between an internal signal layer and some other layer. - // grey out all PAD_SMD pads not on current or the single selected + // grey out all PAD_SMD pads not on current or the single selected // external layer. - else if( !IsOnLayer( screen->m_Active_Layer ) - && !IsOnLayer( routeTop ) - && !IsOnLayer( routeBot ) ) + else if( !IsOnLayer( screen->m_Active_Layer ) + && !IsOnLayer( routeTop ) + && !IsOnLayer( routeBot ) ) { color &= ~MASKCOLOR; color |= DARKDARKGRAY; } } - + // when not edting tracks, show PAD_SMD components not on active layer as greyed out else { @@ -371,7 +371,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int { color &= ~MASKCOLOR; color |= DARKDARKGRAY; - } + } } } @@ -382,7 +382,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int else color |= HIGHT_LIGHT_FLAG; } - + if( color & HIGHT_LIGHT_FLAG ) color = ColorRefs[color & MASKCOLOR].m_LightColor; @@ -401,7 +401,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int dy = dy0 = m_Size.y >> 1; /* demi dim dx et dy */ angle = m_Orient; - + bool DisplayIsol = DisplayOpt.DisplayPadIsol; if( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 ) DisplayIsol = FALSE; @@ -430,13 +430,13 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int /* calcul de l'entraxe de l'ellipse */ if( dx > dy ) /* ellipse horizontale */ { - delta_cx = dx - dy; + delta_cx = dx - dy; delta_cy = 0; rotdx = m_Size.y; } else /* ellipse verticale */ { - delta_cx = 0; + delta_cx = 0; delta_cy = dy - dx; rotdx = m_Size.x; } @@ -459,7 +459,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int if( DisplayIsol ) { rotdx = rotdx + g_DesignSettings.m_TrackClearence + g_DesignSettings.m_TrackClearence; - + GRCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, ux0 - delta_cx, uy0 - delta_cy, rotdx, color ); @@ -496,9 +496,9 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int if( DisplayIsol ) { - dx += g_DesignSettings.m_TrackClearence; + dx += g_DesignSettings.m_TrackClearence; dy += g_DesignSettings.m_TrackClearence; - + coord[0].x = -dx - ddy; coord[0].y = dy + ddx; @@ -536,7 +536,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int if( fillpad && hole ) { color = g_IsPrinting ? WHITE : BLACK; // ou DARKGRAY; - + if( draw_mode != GR_XOR ) GRSetDrawMode( DC, GR_COPY ); else @@ -552,7 +552,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int case PAD_OVAL: dx = m_Drill.x >> 1; dy = m_Drill.y >> 1; /* demi dim dx et dy */ - + /* calcul de l'entraxe de l'ellipse */ if( m_Drill.x > m_Drill.y ) /* ellipse horizontale */ { @@ -583,7 +583,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int { dx0 = MIN( dx0, dy0 ); int nc_color = BLUE; - + if( m_Masque_Layer & CMP_LAYER ) /* Trace forme \ */ GRLine( &panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0, cx0 + dx0, cy0 + dx0, 0, nc_color ); @@ -741,7 +741,7 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum ) int netcode; nn = sscanf( PtLine, "%d", &netcode ); SetNet( netcode ); - + /* Lecture du netname */ ReadDelimitedText( BufLine, PtLine, sizeof(BufLine) ); m_Netname = CONV_FROM_UTF8( StrPurge( BufLine ) ); @@ -799,7 +799,7 @@ bool D_PAD::Save( FILE* aFile ) const fprintf( aFile, "Sh \"%.4s\" %c %d %d %d %d %d\n", m_Padname, cshape, m_Size.x, m_Size.y, m_DeltaSize.x, m_DeltaSize.y, m_Orient ); - + fprintf( aFile, "Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y ); if( m_DrillShape == PAD_OVAL ) { @@ -840,7 +840,7 @@ bool D_PAD::Save( FILE* aFile ) const goto out; rc = true; - + out: return rc; } @@ -853,7 +853,7 @@ void D_PAD::Display_Infos( WinEDA_DrawFrame* frame ) /* Affiche en bas d'ecran les caract de la pastille demandee */ { int ii; - MODULE* Module; + MODULE* module; wxString Line; int pos = 1; @@ -874,10 +874,10 @@ void D_PAD::Display_Infos( WinEDA_DrawFrame* frame ) frame->MsgPanel->EraseMsgBox(); /* Recherche du module correspondant */ - Module = (MODULE*) m_Parent; - if( Module ) + module = (MODULE*) m_Parent; + if( module ) { - wxString msg = Module->m_Reference->m_Text; + wxString msg = module->GetReference(); Affiche_1_Parametre( frame, pos, _( "Module" ), msg, DARKCYAN ); ReturnStringPadName( Line ); pos += 8; @@ -894,6 +894,7 @@ void D_PAD::Display_Infos( WinEDA_DrawFrame* frame ) #endif wxString LayerInfo; + ii = 0; if( m_Masque_Layer & CUIVRE_LAYER ) ii = 2; @@ -1002,7 +1003,7 @@ void D_PAD::Display_Infos( WinEDA_DrawFrame* frame ) } - int module_orient = Module ? Module->m_Orient : 0; + int module_orient = module ? module->m_Orient : 0; if( module_orient ) Line.Printf( wxT( "%3.1f(+%3.1f)" ), (float) (m_Orient - module_orient) / 10, (float) module_orient / 10 ); @@ -1076,7 +1077,7 @@ bool D_PAD::HitTest( const wxPoint& ref_pos ) /************************************************************/ -int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) +int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) /************************************************************/ { int diff; @@ -1096,7 +1097,7 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) ) return diff; - // @todo check if export_gencad still works: + // @todo check if export_gencad still works: // specctra_export needs this, but maybe export_gencad does not. added on Jan 24 2008 by Dick. if( (diff = padref->m_Masque_Layer - padcmp->m_Masque_Layer) ) return diff; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 206bf90e10..8179563048 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -748,8 +748,9 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode ) // see class_track.h void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) { - wxString msg; - int text_pos; + wxString msg; + int text_pos; + BOARD* board = ((WinEDA_PcbFrame*)frame)->m_Pcb; #ifdef RATSNET_DEBUG DbgDisplayTrackInfos( this ); @@ -779,11 +780,12 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) /* Display NetName pour les segments de piste type cuivre */ text_pos += 15; + if( Type() == TYPETRACK || Type() == TYPEZONE || Type() == TYPEVIA ) { - EQUIPOT* equipot = ( (WinEDA_PcbFrame*) frame )->m_Pcb->FindNet( GetNet() ); + EQUIPOT* equipot = board->FindNet( GetNet() ); if( equipot ) msg = equipot->m_Netname; @@ -824,11 +826,11 @@ void TRACK::Display_Infos( WinEDA_DrawFrame* frame ) int top_layer, bottom_layer; Via->ReturnLayerPair( &top_layer, &bottom_layer ); - msg = ReturnPcbLayerName( top_layer, TRUE ) + wxT( "/" ) - + ReturnPcbLayerName( bottom_layer, TRUE ); + msg = board->GetLayerName( top_layer ) + wxT( "/" ) + + board->GetLayerName( bottom_layer ); } else - msg = ReturnPcbLayerName( m_Layer ); + msg = board->GetLayerName( m_Layer ); text_pos += 5; Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN ); @@ -978,13 +980,18 @@ void SEGVIA::Show( int nestLevel, std::ostream& os ) int topLayer; int botLayer; + BOARD* board = (BOARD*) m_Parent; + ReturnLayerPair( &topLayer, &botLayer ); NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << - " type=\"" << cp << '"' << - " layers=\"" << ReturnPcbLayerName( topLayer ).Trim().mb_str() << "," - << ReturnPcbLayerName( botLayer ).Trim().mb_str() << '"' << + " type=\"" << cp << '"'; + + if( board ) + os << " layers=\"" << board->GetLayerName( topLayer ).Trim().mb_str() << "," + << board->GetLayerName( botLayer ).Trim().mb_str() << '"'; + os << " width=\"" << m_Width << '"' << " drill=\"" << GetDrillValue() << '"' << " netcode=\"" << GetNet() << "\">" <<