From 9dca39f1d4b579993c0accb0f93a8f55a7aabcde Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Mon, 1 Oct 2007 04:14:29 +0000 Subject: [PATCH] SEGVIA::Show() & BOARD_ITEM::MenuText() --- change_log.txt | 7 ++++++ common/common.cpp | 17 ++++++------- pcbnew/class_board_item.cpp | 38 +++++++++++++++++++++-------- pcbnew/class_track.cpp | 48 +++++++++++++++++++++++++++++++++++-- pcbnew/class_track.h | 17 ++++++++++++- pcbnew/drc.cpp | 2 +- todo.txt | 2 ++ 7 files changed, 107 insertions(+), 24 deletions(-) diff --git a/change_log.txt b/change_log.txt index bc56d5f46d..3819568461 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,13 @@ Please add newer entries at the top, list the date and your name with email address. +2007-Sep-30 UPDATE Dick Hollenbeck +================================================================================ ++ pcbnew + Added dedicated Show() function for SEGVIA. Enhanced BOARD_ITEM::MenuText() + for SEGVIA. Added to todo.txt. + + 2007-Sep-29 UPDATE Dick Hollenbeck ================================================================================ + pcbnew diff --git a/common/common.cpp b/common/common.cpp index 51a10d08e8..846744dc10 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -265,7 +265,7 @@ void MyFree( void* pt_mem ) /**************************************************************/ -wxString ReturnPcbLayerName( int layer_number, bool is_filename ) +wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding ) /**************************************************************/ /* Return the name of the layer number "layer_number". @@ -273,7 +273,6 @@ wxString ReturnPcbLayerName( int layer_number, bool is_filename ) * (not internatinalized, no space) */ { - wxString layer_name; static const wxString layer_name_list[] = { _( "Copper " ), _( "Inner L1 " ), _( "Inner L2 " ), _( "Inner L3 " ), _( "Inner L4 " ), _( "Inner L5 " ), _( "Inner L6 " ), _( "Inner L7 " ), @@ -285,7 +284,8 @@ wxString ReturnPcbLayerName( int layer_number, bool is_filename ) _( "Edges Pcb" ), _( "--- " ), _( "--- " ), _( "--- " ) }; -// Same as layer_name_list, without space, not internationalized + + // Same as layer_name_list, without space, not internationalized static const wxString layer_name_list_for_filename[] = { wxT( "Copper" ), wxT( "InnerL1" ), wxT( "InnerL2" ), wxT( "InnerL3" ), wxT( "InnerL4" ), wxT( "InnerL5" ), wxT( "InnerL6" ), wxT( "InnerL7" ), @@ -297,15 +297,12 @@ wxString ReturnPcbLayerName( int layer_number, bool is_filename ) wxT( "EdgesPcb" ), wxT( "---" ), wxT( "---" ), wxT( "---" ) }; - if( layer_number >= 31 ) + if( (unsigned) layer_number >= 31u ) layer_number = 31; - if( is_filename ) - layer_name = layer_name_list_for_filename[layer_number]; - else - layer_name = layer_name_list[layer_number]; - - return layer_name; + return omitSpacePadding ? + layer_name_list_for_filename[layer_number] : + layer_name_list[layer_number]; } diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index a931c8ff0e..1f57039003 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 ) << wxT( ")" ); + text << wxT( " (" ) << ReturnPcbLayerName( item->m_Layer ).Trim() << wxT( ")" ); break; case TYPEPAD: @@ -47,7 +47,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const break; case TYPEDRAWSEGMENT: - text << _( "Pcb Graphic" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ); // @todo: extend text + text << _( "Pcb Graphic" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); // @todo: extend text break; case TYPETEXTE: @@ -56,7 +56,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() ); + text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); break; case TYPETEXTEMODULE: @@ -130,7 +130,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const { text << wxT( " [" ) << net->m_Netname << wxT( "]" ); } - text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ); + text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); break; case TYPEZONE: @@ -145,15 +145,33 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const { text << wxT( " [" ) << net->m_Netname << wxT( "]" ); } - text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ); + text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); break; case TYPEVIA: - text << _( "Via" ) << wxT( " " ) << ( (SEGVIA*) item )->m_NetCode; - net = aPcb->FindNet( ( (TRACK*) item )->m_NetCode ); - if( net ) { - text << wxT( " [" ) << net->m_Netname << wxT( "]" ); + SEGVIA* via = (SEGVIA*) item; + text << _( "Via" ) << wxT( " " ) << via->m_NetCode; + + int shape = via->Shape(); + if( shape == VIA_ENTERREE ) + text << wxT(" ") << _( "Blind" ); + else if( shape == VIA_BORGNE ) + text << wxT(" ") << _("Buried"); + // else say nothing about normal vias + + net = aPcb->FindNet( via->m_NetCode ); + if( net ) + { + text << wxT( " [" ) << net->m_Netname << wxT( "]" ); + } + + // say which layers, only two for now + int topLayer; + int botLayer; + via->ReturnLayerPair( &topLayer, &botLayer ); + text << _( " on " ) << ReturnPcbLayerName( topLayer).Trim() << wxT(" <-> ") + << ReturnPcbLayerName( botLayer ).Trim(); } break; @@ -170,7 +188,7 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const break; case TYPEEDGEZONE: - text << _( "Edge Zone" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ); // @todo: extend text + text << _( "Edge Zone" ) << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); // @todo: extend text break; default: diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 5fae6e59e8..cfae464319 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -816,6 +816,7 @@ bool TRACK::HitTest( const wxPoint& ref_pos ) #if defined(DEBUG) + /** * Function Show * is used to output the object tree, currently for debugging only. @@ -826,10 +827,10 @@ bool TRACK::HitTest( const wxPoint& ref_pos ) void TRACK::Show( int nestLevel, std::ostream& os ) { NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << - " shape=\"" << m_Shape << '"' << +// " shape=\"" << m_Shape << '"' << " layer=\"" << m_Layer << '"' << " width=\"" << m_Width << '"' << - " drill=\"" << m_Drill << '"' << +// " drill=\"" << m_Drill << '"' << " netcode=\"" << m_NetCode << "\">" << "" << ""; @@ -837,6 +838,49 @@ void TRACK::Show( int nestLevel, std::ostream& os ) os << "\n"; } + +/** + * 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 + * of nesting of this object within the overall tree. + * @param os The ostream& to output to. + */ +void SEGVIA::Show( int nestLevel, std::ostream& os ) +{ + const char* cp; + + switch( Shape() ) + { + case VIA_NORMALE: cp = "through"; break; + case VIA_ENTERREE: cp = "blind"; break; + case VIA_BORGNE: cp = "buried"; break; + default: + case VIA_NOT_DEFINED: cp = "undefined"; break; + } + + int topLayer; + int botLayer; + + ReturnLayerPair( &topLayer, &botLayer ); + + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << + " type=\"" << cp << '"' << + " layers=\"" << ReturnPcbLayerName( topLayer).Trim().mb_str() << "," + << ReturnPcbLayerName( botLayer ).Trim().mb_str() << '"' << + " width=\"" << m_Width << '"' << + " drill=\"" << m_Drill << '"' << + " netcode=\"" << m_NetCode << "\">" << + ""; + + os << "\n"; +} + + + + + + #endif diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index b501fb7e1c..283f1b3de8 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -146,6 +146,8 @@ public: return wxT("TRACK"); } + +#if defined(DEBUG) /** * Function Show * is used to output the object tree, currently for debugging only. @@ -154,7 +156,7 @@ public: * @param os The ostream& to output to. */ void Show( int nestLevel, std::ostream& os ); - +#endif }; @@ -211,6 +213,19 @@ public: { return wxT("VIA"); } + + +#if defined(DEBUG) + /** + * 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 + * of nesting of this object within the overall tree. + * @param os The ostream& to output to. + */ + void Show( int nestLevel, std::ostream& os ); +#endif + }; diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 559c091e34..e5ad7ce315 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -581,7 +581,7 @@ int Drc( WinEDA_BasePcbFrame* frame, wxDC* DC, /* Le pad doit faire partie d'un net mais pas de probleme * si le pad est du meme net */ - if( /*pt_pad->m_NetCode &&*/ net_code_ref == pt_pad->m_NetCode ) + if( /*pt_pad->m_NetCode &&*/ net_code_ref == pt_pad->m_NetCode ) continue; /* Test DRC pour les pads */ diff --git a/todo.txt b/todo.txt index 7107c309c1..c841941e3a 100644 --- a/todo.txt +++ b/todo.txt @@ -51,3 +51,5 @@ understanding by new developers. *** Implement the graying in/out of "Edit/Undo", "Edit/Redo" menu items, when Undo/Redo stack is empty/filled. +*** There is no way to truly edit a via, such as changing its layers. +