From 018292a8c6a3dff706674cef37ce2899fc0522ff Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 11 Mar 2011 10:53:28 -0500 Subject: [PATCH] PCBNew auxiliary tool bar changes and other minor improvements. * Remove clearance and net class name read only text boxes from PCBNew auxiliary tool bar. * Display full net class information in message panel when an object that supports net classes is selected. * Move coordinate string conversion function to EDA_DRAW_FRAME object and made it more versatile. * Refresh message panel text when units change. --- common/drawframe.cpp | 45 +++++++++++++ include/wxPcbStruct.h | 8 --- include/wxstruct.h | 13 +++- pcbnew/class_track.cpp | 34 ++++++---- pcbnew/dialogs/dialog_design_rules.cpp | 3 - pcbnew/editrack.cpp | 2 - pcbnew/files.cpp | 5 -- pcbnew/initpcb.cpp | 1 - pcbnew/ioascii.cpp | 2 - pcbnew/onleftclick.cpp | 2 - pcbnew/onrightclick.cpp | 4 -- pcbnew/pcbframe.cpp | 5 -- pcbnew/specctra_import.cpp | 2 - pcbnew/tool_onrightclick.cpp | 2 +- pcbnew/tool_pcb.cpp | 87 ++------------------------ 15 files changed, 86 insertions(+), 129 deletions(-) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 446df102b9..1826994bed 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -138,6 +138,17 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME() } +void EDA_DRAW_FRAME::unitsChangeRefresh() +{ + UpdateStatusBar(); + + EDA_ITEM* item = GetScreen()->GetCurItem(); + + if( item ) + item->DisplayInfo( this ); +} + + void EDA_DRAW_FRAME::EraseMsgBox() { if( MsgPanel ) @@ -793,3 +804,37 @@ void EDA_DRAW_FRAME::ClearMsgPanel( void ) MsgPanel->EraseMsgBox(); } + + +wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) +{ + wxString text; + const wxChar* format; + double value = To_User_Unit( g_UserUnit, aValue, m_InternalUnits ); + + if( g_UserUnit == INCHES ) + { + if( aConvertToMils ) + { + format = ( m_InternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.0f" ) : wxT( "%.1f" ); + value *= 1000; + } + else + { + format = ( m_InternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.3f" ) : wxT( "%.4f" ); + } + } + else + { + format = ( m_InternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.2f" ) : wxT( "%.3f" ); + } + + text.Printf( format, value ); + + if( g_UserUnit == INCHES ) + text += ( aConvertToMils ) ? _( " mils" ) : _( " in" ); + else + text += _( " mm" ); + + return text; +} diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index a26a4cad3c..dbf959c21c 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -55,7 +55,6 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME void updateTraceWidthSelectBox(); void updateViaSizeSelectBox(); - void updateDesignRulesSelectBoxes(); protected: @@ -120,12 +119,6 @@ public: // select current track width WinEDAChoiceBox* m_SelViaSizeBox; // a combo box to display and // select current via diameter - wxTextCtrl* m_ClearanceBox; // a text ctrl to display the - // current tracks and vias - // clearance - wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the - // current NetClass - bool m_TrackAndViasSizesList_Changed; bool m_show_microwave_tools; bool m_show_layer_manager_tools; @@ -1148,7 +1141,6 @@ public: */ virtual void SetLanguage( wxCommandEvent& event ); - DECLARE_EVENT_TABLE() }; diff --git a/include/wxstruct.h b/include/wxstruct.h index 9c5dce851b..a01089205c 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -258,7 +258,7 @@ protected: * default version only updates the status bar. Don't forget to call the default * in your derived class or the status bar will not get updated properly. */ - virtual void unitsChangeRefresh() { UpdateStatusBar(); } + virtual void unitsChangeRefresh(); public: EDA_DRAW_FRAME( wxWindow* father, int idtype, @@ -557,6 +557,17 @@ public: */ virtual void PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); + /** + * Function CoordinateToString + * is a helper to convert the integer coordinate \a aValue to a string in inches or mm + * according to the current user units setting. + * @param aValue The coordinate to convert. + * @param aConvertToMils Convert inch values to mils if true. This setting has no effect if + * the current user unit is millimeters. + * @return The converted string for display in user interface elements. + */ + wxString CoordinateToString( int aValue, bool aConvertToMils = false ); + DECLARE_EVENT_TABLE() }; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index b6479c2449..80a2afbd21 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -951,9 +951,28 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame ) { int trackLen = 0; Marque_Une_Piste( board, this, NULL, &trackLen, false ); - valeur_param( trackLen, msg ); + msg = frame->CoordinateToString( trackLen ); frame->AppendMsgPanel( _( "Track Length" ), msg, DARKCYAN ); } + + NETCLASS* netclass = GetNetClass(); + + if( netclass ) + { + frame->AppendMsgPanel( _( "NC Name" ), netclass->GetName(), DARKMAGENTA ); + frame->AppendMsgPanel( _( "NC Clearance" ), + frame->CoordinateToString( netclass->GetClearance(), true ), + DARKMAGENTA ); + frame->AppendMsgPanel( _( "NC Width" ), + frame->CoordinateToString( netclass->GetTrackWidth(), true ), + DARKMAGENTA ); + frame->AppendMsgPanel( _( "NC Via Size"), + frame->CoordinateToString( netclass->GetViaDiameter(), true ), + DARKMAGENTA ); + frame->AppendMsgPanel( _( "NC Via Drill"), + frame->CoordinateToString( netclass->GetViaDrill(), true ), + DARKMAGENTA ); + } } @@ -1041,7 +1060,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "Layer" ), msg, BROWN ); /* Display width */ - valeur_param( (unsigned) m_Width, msg ); + msg = frame->CoordinateToString( (unsigned) m_Width ); if( Type() == TYPE_VIA ) // Display Diam and Drill values { @@ -1051,7 +1070,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) // Display drill value int drill_value = GetDrillValue(); - valeur_param( (unsigned) drill_value, msg ); + msg = frame->CoordinateToString( (unsigned) drill_value ); wxString title = _( "Drill" ); title += wxT( " " ); @@ -1068,17 +1087,10 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "Width" ), msg, DARKCYAN ); } - NETCLASS* netclass = GetNetClass(); - if( netclass ) - { - msg = netclass->GetName(); - frame->AppendMsgPanel( _( "Net Class" ), msg, DARKCYAN ); - } - // Display segment length if( Type() != TYPE_VIA ) // Display Diam and Drill values { - valeur_param( wxRound( GetLength() ), msg ); + msg = frame->CoordinateToString( wxRound( GetLength() ) ); frame->AppendMsgPanel( _( "Segment Length" ), msg, DARKCYAN ); } } diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index b4fff093c5..9bc0a2f162 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -667,8 +667,6 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard() std::vector * vialist = &m_Parent->GetBoard()->m_ViasDimensionsList; vialist->erase( vialist->begin() + 1, vialist->end() ); vialist->insert( vialist->end(), m_ViasDimensionsList.begin(), m_ViasDimensionsList.end() ); - - m_Parent->m_TrackAndViasSizesList_Changed = true; } @@ -709,7 +707,6 @@ void DIALOG_DESIGN_RULES::OnOkButtonClick( wxCommandEvent& event ) EndModal( wxID_OK ); m_Pcb->SetCurrentNetClass( NETCLASS::Default ); - m_Parent->m_TrackAndViasSizesList_Changed = true; } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index d645162263..8a7703acc0 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -150,8 +150,6 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) // Display info about track Net class, and init track and vias sizes: g_CurrentTrackSegment->SetNet( g_HighLight_NetCode ); GetBoard()->SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() ); - m_TrackAndViasSizesList_Changed = true; - updateDesignRulesSelectBoxes(); g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); g_CurrentTrackSegment->m_Width = GetBoard()->GetCurrentTrackWidth(); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index b23507cf0d..246d879b48 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -142,8 +142,6 @@ the changes?" ) ) ) return false; } - m_TrackAndViasSizesList_Changed = true; - if( aAppend ) { GetScreen()->SetFileName( wxEmptyString ); @@ -273,14 +271,11 @@ this file again." ) ); // Update info shown by the horizontal toolbars GetBoard()->SetCurrentNetClass( NETCLASS::Default ); - m_TrackAndViasSizesList_Changed = true; - ReFillLayerWidget(); ReCreateLayerBox( NULL ); syncLayerWidget(); - updateDesignRulesSelectBoxes(); updateTraceWidthSelectBox(); updateViaSizeSelectBox(); diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 1085bba05c..f3eda1131a 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -42,7 +42,6 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) // delete the old BOARD and create a new BOARD so that the default // layer names are put into the BOARD. SetBoard( new BOARD( NULL, this ) ); - m_TrackAndViasSizesList_Changed = true; SetCurItem( NULL ); /* clear filename, to avoid overwriting an old file */ diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 9dd27c0f4c..0d5b4e699a 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -1116,7 +1116,6 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) board->SynchronizeNetsAndNetClasses(); - m_TrackAndViasSizesList_Changed = true; SetStatusText( wxEmptyString ); BestZoom(); return 1; @@ -1154,7 +1153,6 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile ) // Select default Netclass before writing file. // Useful to save default values in headers GetBoard()->SetCurrentNetClass( GetBoard()->m_NetClasses.GetDefault()->GetName() ); - m_TrackAndViasSizesList_Changed = true; WriteGeneralDescrPcb( aFile ); WriteSheetDescr( GetScreen(), aFile ); diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 622b93c63f..6c28015360 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -124,8 +124,6 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case TYPE_PAD: GetBoard()->SetCurrentNetClass( ((BOARD_CONNECTED_ITEM*)DrawStruct)->GetNetClassName() ); - m_TrackAndViasSizesList_Changed = true; - updateDesignRulesSelectBoxes(); break; default: diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index eeab3afa84..edba764a27 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -393,8 +393,6 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) wxString msg; GetBoard()->SetCurrentNetClass( Track->GetNetClassName() ); - m_TrackAndViasSizesList_Changed = true; - updateDesignRulesSelectBoxes(); int flags = Track->m_Flags; @@ -714,8 +712,6 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu ) return; GetBoard()->SetCurrentNetClass( Pad->GetNetClassName() ); - m_TrackAndViasSizesList_Changed = true; - updateDesignRulesSelectBoxes(); wxString msg = Pad->MenuText( GetBoard() ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 5a04af4c74..b3e996411d 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -271,7 +271,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_SelTrackWidthBox = NULL; m_SelViaSizeBox = NULL; m_SelLayerBox = NULL; - m_TrackAndViasSizesList_Changed = false; m_show_microwave_tools = false; m_show_layer_manager_tools = true; m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr; @@ -291,8 +290,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_Layers = new PCB_LAYER_WIDGET( this, DrawPanel, pointSize ); - m_TrackAndViasSizesList_Changed = true; - m_drc = new DRC( this ); // these 2 objects point to each other m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; @@ -513,7 +510,6 @@ void PCB_EDIT_FRAME::ShowDesignRulesEditor( wxCommandEvent& event ) if( returncode == wxID_OK ) // New rules, or others changes. { ReCreateLayerBox( NULL ); - updateDesignRulesSelectBoxes(); updateTraceWidthSelectBox(); updateViaSizeSelectBox(); OnModify(); @@ -653,7 +649,6 @@ void PCB_EDIT_FRAME::unitsChangeRefresh() updateTraceWidthSelectBox(); updateViaSizeSelectBox(); - updateDesignRulesSelectBoxes(); } diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index 896915ef46..a45f70312d 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -111,8 +111,6 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) SetLocaleTo_Default( ); // revert to the current locale - m_TrackAndViasSizesList_Changed = true; - OnModify(); GetBoard()->m_Status_Pcb = 0; diff --git a/pcbnew/tool_onrightclick.cpp b/pcbnew/tool_onrightclick.cpp index fc0172649a..f8c55b0e19 100644 --- a/pcbnew/tool_onrightclick.cpp +++ b/pcbnew/tool_onrightclick.cpp @@ -25,9 +25,9 @@ void PCB_EDIT_FRAME::ToolOnRightClick( wxCommandEvent& event ) case ID_TRACK_BUTT: { DIALOG_DESIGN_RULES dlg( this ); + if( dlg.ShowModal() == wxID_OK ) { - updateDesignRulesSelectBoxes(); updateTraceWidthSelectBox(); updateViaSizeSelectBox(); } diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index 9fd7e3067f..46dd42e90f 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -506,8 +506,6 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar() m_AuxiliaryToolBar = new WinEDA_Toolbar( TOOLBAR_AUX, this, ID_AUX_TOOLBAR, true ); - m_TrackAndViasSizesList_Changed = true; - /* Set up toolbar items */ // Creates box to display and choose tracks widths: @@ -526,24 +524,6 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar() m_AuxiliaryToolBar->AddControl( m_SelViaSizeBox ); m_AuxiliaryToolBar->AddSeparator(); - // Creates box to display tracks and vias clearance: - m_ClearanceBox = new wxTextCtrl( m_AuxiliaryToolBar, -1, - wxEmptyString, wxPoint( -1, -1 ), - wxSize( LISTBOX_WIDTH + 10, -1 ), - wxTE_READONLY ); - m_ClearanceBox->SetToolTip(_("Current NetClass clearance value") ); - m_AuxiliaryToolBar->AddControl( m_ClearanceBox ); - m_AuxiliaryToolBar->AddSeparator(); - - // Creates box to display the current NetClass: - m_NetClassSelectedBox = new wxTextCtrl( m_AuxiliaryToolBar, -1, - wxEmptyString, wxPoint( -1, -1 ), - wxSize( LISTBOX_WIDTH, -1 ), - wxTE_READONLY ); - m_NetClassSelectedBox->SetToolTip(_("Name of the current NetClass") ); - m_AuxiliaryToolBar->AddControl( m_NetClassSelectedBox ); - m_AuxiliaryToolBar->AddSeparator(); - // Creates box to display and choose strategy to handle tracks an vias sizes: m_AuxiliaryToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, wxEmptyString, @@ -572,44 +552,13 @@ an existing track use its width\notherwise, use current width setting" ), updateGridSelectBox(); updateTraceWidthSelectBox(); updateViaSizeSelectBox(); - updateDesignRulesSelectBoxes(); // after adding the buttons to the toolbar, must call Realize() m_AuxiliaryToolBar->Realize(); - - m_TrackAndViasSizesList_Changed = true; m_AuxiliaryToolBar->AddSeparator(); } -/* helper to convert an integer value to a string, using mils or mm - * according to g_UserUnit value - */ -static wxString ReturnStringValue( int aValue ) -{ - wxString text; - const wxChar* format; - double value = To_User_Unit( g_UserUnit, aValue, PCB_INTERNAL_UNIT ); - - if( g_UserUnit == INCHES ) - { - format = wxT( " %.1f" ); - value *= 1000; - } - else - format = wxT( " %.3f" ); - - text.Printf( format, value ); - - if( g_UserUnit == INCHES ) - text += _( " mils" ); - else - text += _( " mm" ); - - return text; -} - - void PCB_EDIT_FRAME::updateTraceWidthSelectBox() { if( m_SelTrackWidthBox == NULL ) @@ -621,7 +570,7 @@ void PCB_EDIT_FRAME::updateTraceWidthSelectBox() for( unsigned ii = 0; ii < GetBoard()->m_TrackWidthList.size(); ii++ ) { - msg = _( "Track" ) + ReturnStringValue( GetBoard()->m_TrackWidthList[ii] ); + msg = _( "Track " ) + CoordinateToString( GetBoard()->m_TrackWidthList[ii], true ); if( ii == 0 ) msg << _( " *" ); @@ -645,11 +594,12 @@ void PCB_EDIT_FRAME::updateViaSizeSelectBox() for( unsigned ii = 0; ii < GetBoard()->m_ViasDimensionsList.size(); ii++ ) { - msg = _( "Via" ); - msg << ReturnStringValue( GetBoard()->m_ViasDimensionsList[ii].m_Diameter ); + msg = _( "Via " ); + msg << CoordinateToString( GetBoard()->m_ViasDimensionsList[ii].m_Diameter, true ); if( GetBoard()->m_ViasDimensionsList[ii].m_Drill ) - msg << wxT("/") << ReturnStringValue( GetBoard()->m_ViasDimensionsList[ii].m_Drill ); + msg << wxT("/ ") + << CoordinateToString( GetBoard()->m_ViasDimensionsList[ii].m_Drill, true ); if( ii == 0 ) msg << _( " *" ); @@ -662,33 +612,6 @@ void PCB_EDIT_FRAME::updateViaSizeSelectBox() } -/** - * Function updateDesignRulesSelectBoxes - * update the displayed values: track widths, via sizes, clearance, Netclass name - * used when a netclass is selected - */ -void PCB_EDIT_FRAME::updateDesignRulesSelectBoxes() -{ - wxString nclname = GetBoard()->m_CurrentNetClassName; - wxString msg = _( "NetClass: " ) + nclname; - - if( m_NetClassSelectedBox ) - { - m_NetClassSelectedBox->Clear(); - m_NetClassSelectedBox->AppendText( msg ); - } - - NETCLASS* netclass = GetBoard()->m_NetClasses.Find( nclname ); - - if( m_ClearanceBox ) - { - wxString msg = _( "Clearance" ) + ReturnStringValue( netclass->GetClearance() ); - m_ClearanceBox->Clear(); - m_ClearanceBox->AppendText( msg ); - } -} - - WinEDALayerChoiceBox* PCB_EDIT_FRAME::ReCreateLayerBox( WinEDA_Toolbar* parent ) { if( m_SelLayerBox == NULL )