diff --git a/include/preview_items/ruler_item.h b/include/preview_items/ruler_item.h index d616478ef7..46fd3317ca 100644 --- a/include/preview_items/ruler_item.h +++ b/include/preview_items/ruler_item.h @@ -71,10 +71,14 @@ public: return wxT( "RULER_ITEM" ); } -private: + void UpdateUserUnits( EDA_UNITS_T aUserUnits ) + { + m_userUnits = aUserUnits; + } +private: const TWO_POINT_GEOMETRY_MANAGER& m_geomMgr; - const EDA_UNITS_T m_userUnits; + EDA_UNITS_T m_userUnits; }; } // PREVIEW diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index 7f44568cbd..129a861cf9 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -28,7 +28,7 @@ #include #include #include - +#include void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle ) { @@ -81,3 +81,13 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard ) m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); } } + + +void PCB_BASE_EDIT_FRAME::unitsChangeRefresh() +{ + PCB_BASE_FRAME::unitsChangeRefresh(); // Update the status bar. + + GetToolManager()->RunAction( PCB_ACTIONS::switchUnits, true ); // Notify tools. +} + + diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index 0417bbc75a..7ac61a7d73 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -204,6 +204,8 @@ protected: * duplicateItem(BOARD_ITEM*, bool) above */ virtual void duplicateItems( bool aIncrement ) = 0; + + void unitsChangeRefresh() override; }; #endif diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 129f00c731..d7c87f64de 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -59,6 +59,7 @@ #include #include +#include const wxChar PCB_BASE_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index becbee42c3..902f9a3fde 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -975,7 +975,7 @@ void PCB_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & ) void PCB_EDIT_FRAME::unitsChangeRefresh() { - PCB_BASE_FRAME::unitsChangeRefresh(); // Update the grid size select box. + PCB_BASE_EDIT_FRAME::unitsChangeRefresh(); // Update the grid size select box. ReCreateAuxiliaryToolbar(); } diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 88efeee0c5..d783798768 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1253,6 +1253,14 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) view.Update( &ruler, KIGFX::GEOMETRY ); } + else if( evt->IsAction( &PCB_ACTIONS::switchUnits ) ) + { + ruler.UpdateUserUnits( frame()->GetUserUnits() ); + + view.SetVisible( &ruler, true ); + view.Update( &ruler, KIGFX::GEOMETRY ); + } + else if( evt->IsClick( BUT_RIGHT ) ) { GetManager()->PassEvent();