Another go at fixing units changes for rulers.

The previous fix only worked for hot-key changes.  This should
include using the toolbar, menu, etc.
This commit is contained in:
Jeff Young 2018-10-10 10:48:16 +01:00
parent e79e2f0175
commit ab67d2f81a
6 changed files with 34 additions and 19 deletions

View File

@ -30,6 +30,7 @@
#include <view/view.h> #include <view/view.h>
#include "footprint_info_impl.h" #include "footprint_info_impl.h"
#include <project.h> #include <project.h>
#include <tools/pcb_actions.h>
PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aFrameType, const wxString& aTitle, FRAME_T aFrameType, const wxString& aTitle,
@ -103,3 +104,16 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
} }
} }
void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
{
PCB_BASE_FRAME::unitsChangeRefresh();
ReCreateAuxiliaryToolbar();
if( m_toolManager )
m_toolManager->RunAction( PCB_ACTIONS::updateUnits, true );
}

View File

@ -209,6 +209,8 @@ protected:
* duplicateItem(BOARD_ITEM*, bool) above * duplicateItem(BOARD_ITEM*, bool) above
*/ */
virtual void duplicateItems( bool aIncrement ) = 0; virtual void duplicateItems( bool aIncrement ) = 0;
void unitsChangeRefresh() override;
}; };
#endif #endif

View File

@ -908,14 +908,6 @@ void PCB_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & )
} }
void PCB_EDIT_FRAME::unitsChangeRefresh()
{
PCB_BASE_EDIT_FRAME::unitsChangeRefresh(); // Update the grid size select box.
ReCreateAuxiliaryToolbar();
}
bool PCB_EDIT_FRAME::IsElementVisible( GAL_LAYER_ID aElement ) const bool PCB_EDIT_FRAME::IsElementVisible( GAL_LAYER_ID aElement ) const
{ {
return GetBoard()->IsElementVisible( aElement ); return GetBoard()->IsElementVisible( aElement );
@ -1271,10 +1263,10 @@ void PCB_EDIT_FRAME::InstallFootprintPropertiesDialog( MODULE* Module, wxDC* DC
int retvalue = dlg->ShowModal(); int retvalue = dlg->ShowModal();
/* retvalue = /* retvalue =
* FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_ABORT if abort, * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_UPDATE_FP if update footprint
* FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_EXCHANGE_FP if exchange module, * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_EXCHANGE_FP if change footprint
* FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_EDIT_OK for normal edit
* FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_MODEDIT for a goto editor command * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_MODEDIT for a goto editor command
* FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_EDIT_OK for normal edit
*/ */
dlg->Close(); dlg->Close();

View File

@ -209,8 +209,6 @@ protected:
*/ */
void syncLayerVisibilities(); void syncLayerVisibilities();
virtual void unitsChangeRefresh() override;
/** /**
* Function doAutoSave * Function doAutoSave
* performs auto save when the board has been modified and not saved within the * performs auto save when the board has been modified and not saved within the

View File

@ -165,6 +165,10 @@ TOOL_ACTION PCB_ACTIONS::cutToClipboard( "pcbnew.InteractiveEdit.CutToClipboard"
_( "Cut" ), _( "Cut selected content to clipboard" ), _( "Cut" ), _( "Cut selected content to clipboard" ),
cut_xpm ); cut_xpm );
TOOL_ACTION PCB_ACTIONS::updateUnits( "pcbnew.InteractiveEdit.updateUnits",
AS_GLOBAL, 0,
"", "" );
void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags ) void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags )
{ {
@ -1196,8 +1200,9 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
Activate(); Activate();
frame()->SetToolID( toolID, wxCURSOR_PENCIL, _( "Measure distance" ) ); frame()->SetToolID( toolID, wxCURSOR_PENCIL, _( "Measure distance" ) );
EDA_UNITS_T units = frame()->GetUserUnits();
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, frame()->GetUserUnits() ); KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, units );
view.Add( &ruler ); view.Add( &ruler );
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
@ -1252,13 +1257,16 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
view.Update( &ruler, KIGFX::GEOMETRY ); view.Update( &ruler, KIGFX::GEOMETRY );
} }
else if( evt->IsAction( &PCB_ACTIONS::switchUnits ) ) else if( evt->IsAction( &PCB_ACTIONS::switchUnits )
|| evt->IsAction( &PCB_ACTIONS::updateUnits ) )
{ {
if( frame()->GetUserUnits() != units )
{
units = frame()->GetUserUnits();
ruler.SwitchUnits(); ruler.SwitchUnits();
view.SetVisible( &ruler, true );
view.Update( &ruler, KIGFX::GEOMETRY ); view.Update( &ruler, KIGFX::GEOMETRY );
} }
}
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {

View File

@ -365,6 +365,7 @@ public:
static TOOL_ACTION measureTool; static TOOL_ACTION measureTool;
static TOOL_ACTION switchCursor; static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits; static TOOL_ACTION switchUnits;
static TOOL_ACTION updateUnits;
static TOOL_ACTION deleteItemCursor; static TOOL_ACTION deleteItemCursor;
static TOOL_ACTION clearHighlight; static TOOL_ACTION clearHighlight;
static TOOL_ACTION highlightNet; static TOOL_ACTION highlightNet;