From 24ed7f50f514cb1e3696f61d947013e91b9686aa Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 28 Sep 2014 16:44:47 +0200 Subject: [PATCH] Pcbnew: fix Bug #1370321 (Change Segment function applies last netclass used). Also update main toolbar track width and via size info in pns router mode, when starting a track, and other very minor update issue. --- include/wxPcbStruct.h | 13 +++++++++++++ pcbnew/editrack.cpp | 2 +- pcbnew/files.cpp | 7 ++----- pcbnew/hotkeys_board_editor.cpp | 4 ++++ pcbnew/modedit.cpp | 5 ----- pcbnew/onleftclick.cpp | 4 +--- pcbnew/onrightclick.cpp | 11 ++--------- pcbnew/pcbframe.cpp | 14 ++++++++++++++ pcbnew/router/router_tool.cpp | 6 ++++++ 9 files changed, 43 insertions(+), 23 deletions(-) diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 3fa7bae3c9..4b01014e73 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -514,6 +514,19 @@ public: */ void ReCreateLayerBox( bool aForceResizeToolbar = true ); + + /** + * Function SetCurrentNetClass + * Must be called after a netclass selection (or after a netclass parameter change + * calls BOARD_DESIGN_SETTINGS::SetCurrentNetClass() and update trace width and via size + * combo boxes on main toolbar + * Initialize vias and tracks values displayed in comb boxes of the auxiliary toolbar + * and some others parameters (netclass name ....) + * @param aNetClassName = the new netclass name + * @return true if lists of tracks and vias sizes are modified + */ + bool SetCurrentNetClass( const wxString& aNetClassName ); + /** * Function OnModify * must be called after a board change to set the modified flag. diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 03f3fe3fcb..309e7e9c5d 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -167,7 +167,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) // Display info about track Net class, and init track and vias sizes: g_CurrentTrackSegment->SetNetCode( GetBoard()->GetHighLightNetCode() ); - GetDesignSettings().SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() ); + SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() ); g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); g_CurrentTrackSegment->SetWidth( GetDesignSettings().GetCurrentTrackWidth() ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index d373b54d05..208ad446c1 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -559,7 +559,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in GetBoard()->m_Status_Pcb = 0; // Update info shown by the horizontal toolbars - GetDesignSettings().SetCurrentNetClass( NETCLASS::Default ); + SetCurrentNetClass( NETCLASS::Default ); ReFillLayerWidget(); ReCreateLayerBox(); @@ -573,9 +573,6 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in // See case RATSNEST_VISIBLE: in BOARD::SetElementVisibility() GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() ); - updateTraceWidthSelectBox(); - updateViaSizeSelectBox(); - // Display the loaded board: Zoom_Automatique( false ); @@ -681,7 +678,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF // Select default Netclass before writing file. // Useful to save default values in headers - GetDesignSettings().SetCurrentNetClass( NETCLASS::Default ); + SetCurrentNetClass( NETCLASS::Default ); ClearMsgPanel(); diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 7057f65326..3be8c527f9 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -668,7 +668,11 @@ bool PCB_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand ) case PCB_TRACE_T: case PCB_VIA_T: if( aIdCommand == HK_EDIT_ITEM ) + { + // Be sure the corresponding netclass is selected before edit: + SetCurrentNetClass( ( (BOARD_CONNECTED_ITEM*)item )->GetNetClassName() ); evt_type = ID_POPUP_PCB_EDIT_TRACKSEG; + } break; diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 7e90c8a314..6455891282 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -818,11 +818,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) { - wxPoint pos; - double angle = 900; // Necessary +- 900 (+- 90 degrees). - // Be prudent: because RotateMarkedItems is used to rotate some items - // used the same value as RotateMarkedItems - switch( transform ) { case ID_MODEDIT_MODULE_ROTATE: diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index cb3dfeaa8a..4cc84c7371 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -166,10 +166,8 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case PCB_TRACE_T: case PCB_VIA_T: case PCB_PAD_T: - GetDesignSettings().SetCurrentNetClass( + SetCurrentNetClass( ((BOARD_CONNECTED_ITEM*)DrawStruct)->GetNetClassName() ); - updateTraceWidthSelectBox(); - updateViaSizeSelectBox(); break; default: diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 87e81294df..91b1b7cbc5 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -464,9 +464,7 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) wxPoint cursorPosition = GetCrossHairPosition(); wxString msg; - GetDesignSettings().SetCurrentNetClass( Track->GetNetClassName() ); - updateTraceWidthSelectBox(); - updateViaSizeSelectBox(); + SetCurrentNetClass( Track->GetNetClassName() ); int flags = Track->GetFlags(); @@ -834,12 +832,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu ) if( flags ) // Currently in edit, no others commands possible return; - if( GetDesignSettings().GetCurrentNetClassName() != Pad->GetNetClassName() ) - { - GetDesignSettings().SetCurrentNetClass( Pad->GetNetClassName() ); - updateTraceWidthSelectBox(); - updateViaSizeSelectBox(); - } + SetCurrentNetClass( Pad->GetNetClassName() ); wxString msg = Pad->GetSelectMenuText(); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 51ea1b451d..a27fac240c 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -1079,3 +1079,17 @@ void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) dlg.ShowModal(); } + + +bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName ) +{ + bool change = GetDesignSettings().SetCurrentNetClass( aNetClassName ); + + if( change ) + { + updateTraceWidthSelectBox(); + updateViaSizeSelectBox(); + } + + return change; +} diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index d14681ede8..9f699de35b 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -534,7 +534,13 @@ void ROUTER_TOOL::performRouting() frame->SetActiveLayer( ToLAYER_ID( m_startLayer ) ); if( m_startItem && m_startItem->Net() >= 0 ) + { highlightNet( true, m_startItem->Net() ); + // Update track width and via size shown in main toolbar comboboxes + frame->SetCurrentNetClass( m_startItem->Parent()->GetNetClass()->GetName() ); + } + else + frame->SetCurrentNetClass( NETCLASS::Default ); ctls->ForceCursorPosition( false ); ctls->SetAutoPan( true );