Update unit handling in the preview ruler
* Make the ruler able to switch to mils after creation * Cleanup an unused flag in Pcbnew dimensions * Move unit changed notification into EDA_DRAW_FRAME so more frames to use it. * Allow switching units when GerbView ruler tool is active
This commit is contained in:
parent
5828416960
commit
3a570c27f0
|
@ -188,6 +188,10 @@ bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
|
|||
|
||||
void EDA_DRAW_FRAME::unitsChangeRefresh()
|
||||
{
|
||||
// Notify all tools the units have changed
|
||||
if( m_toolManager )
|
||||
m_toolManager->RunAction( ACTIONS::updateUnits, true );
|
||||
|
||||
UpdateStatusBar();
|
||||
UpdateMsgPanel();
|
||||
}
|
||||
|
|
|
@ -473,6 +473,9 @@ TOOL_ACTION ACTIONS::millimetersUnits( "common.Control.metricUnits",
|
|||
_( "Millimeters" ), _( "Use millimeters" ),
|
||||
unit_mm_xpm, AF_NONE, (void*) EDA_UNITS::MILLIMETRES );
|
||||
|
||||
TOOL_ACTION ACTIONS::updateUnits( "common.Control.updateUnits",
|
||||
AS_GLOBAL );
|
||||
|
||||
TOOL_ACTION ACTIONS::toggleUnits( "common.Control.toggleUnits",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'U', LEGACY_HK_NAME( "Switch Units" ),
|
||||
|
|
|
@ -569,7 +569,9 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
Activate();
|
||||
|
||||
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
|
||||
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() );
|
||||
|
||||
EDA_UNITS units = m_frame->GetUserUnits();
|
||||
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, units );
|
||||
|
||||
view.Add( &ruler );
|
||||
view.SetVisible( &ruler, false );
|
||||
|
@ -662,6 +664,17 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
view.Update( &ruler, KIGFX::GEOMETRY );
|
||||
}
|
||||
|
||||
else if( evt->IsAction( &ACTIONS::toggleUnits )
|
||||
|| evt->IsAction( &ACTIONS::updateUnits ) )
|
||||
{
|
||||
if( m_frame->GetUserUnits() != units )
|
||||
{
|
||||
units = m_frame->GetUserUnits();
|
||||
ruler.SwitchUnits( units );
|
||||
view.Update( &ruler, KIGFX::GEOMETRY );
|
||||
}
|
||||
}
|
||||
|
||||
else if( evt->IsClick( BUT_RIGHT ) )
|
||||
{
|
||||
m_menu.ShowContextMenu( m_selection );
|
||||
|
|
|
@ -70,13 +70,12 @@ public:
|
|||
return wxT( "RULER_ITEM" );
|
||||
}
|
||||
|
||||
void SwitchUnits()
|
||||
{
|
||||
if( m_userUnits == EDA_UNITS::INCHES )
|
||||
m_userUnits = EDA_UNITS::MILLIMETRES;
|
||||
else
|
||||
m_userUnits = EDA_UNITS::INCHES;
|
||||
}
|
||||
/**
|
||||
* Switch the ruler units
|
||||
*
|
||||
* @param aUnits is the new unit system the ruler should use
|
||||
*/
|
||||
void SwitchUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
|
||||
|
||||
private:
|
||||
const TWO_POINT_GEOMETRY_MANAGER& m_geomMgr;
|
||||
|
|
|
@ -142,6 +142,7 @@ public:
|
|||
static TOOL_ACTION inchesUnits;
|
||||
static TOOL_ACTION milsUnits;
|
||||
static TOOL_ACTION millimetersUnits;
|
||||
static TOOL_ACTION updateUnits;
|
||||
static TOOL_ACTION toggleUnits;
|
||||
static TOOL_ACTION togglePolarCoords;
|
||||
static TOOL_ACTION resetLocalCoords;
|
||||
|
|
|
@ -292,7 +292,6 @@ protected:
|
|||
wxString m_prefix; ///< String prepended to the value
|
||||
wxString m_suffix; ///< String appended to the value
|
||||
EDA_UNITS m_units; ///< 0 = inches, 1 = mm
|
||||
bool m_useMils; ///< If inches, use mils.
|
||||
bool m_autoUnits; ///< If true, follow the currently selected UI units
|
||||
DIM_UNITS_FORMAT m_unitsFormat; ///< How to render the units suffix
|
||||
int m_precision; ///< Number of digits to display after decimal
|
||||
|
|
|
@ -621,10 +621,6 @@ void PCB_BASE_FRAME::unitsChangeRefresh()
|
|||
{
|
||||
EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
|
||||
|
||||
// Notify all tools the units have changed
|
||||
if( m_toolManager )
|
||||
m_toolManager->RunAction( PCB_ACTIONS::updateUnits, true );
|
||||
|
||||
UpdateGridSelectBox();
|
||||
}
|
||||
|
||||
|
|
|
@ -304,9 +304,6 @@ TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties",
|
|||
_( "Properties..." ), _( "Displays item properties dialog" ),
|
||||
config_xpm );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::updateUnits( "pcbnew.InteractiveEdit.updateUnits",
|
||||
AS_GLOBAL );
|
||||
|
||||
|
||||
// FOOTPRINT_EDITOR_TOOLS
|
||||
//
|
||||
|
|
|
@ -418,7 +418,6 @@ public:
|
|||
static TOOL_ACTION selectionTool;
|
||||
static TOOL_ACTION pickerTool;
|
||||
static TOOL_ACTION measureTool;
|
||||
static TOOL_ACTION updateUnits;
|
||||
static TOOL_ACTION drillOrigin;
|
||||
static TOOL_ACTION placeFileOrigin;
|
||||
static TOOL_ACTION appendBoard;
|
||||
|
|
|
@ -297,12 +297,12 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
else if( evt->IsAction( &ACTIONS::toggleUnits )
|
||||
|| evt->IsAction( &PCB_ACTIONS::updateUnits ) )
|
||||
|| evt->IsAction( &ACTIONS::updateUnits ) )
|
||||
{
|
||||
if( frame()->GetUserUnits() != units )
|
||||
{
|
||||
units = frame()->GetUserUnits();
|
||||
ruler.SwitchUnits();
|
||||
ruler.SwitchUnits( units );
|
||||
view.Update( &ruler, KIGFX::GEOMETRY );
|
||||
canvas()->Refresh();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue