Introduce new action to switch to mils as a unit

This commit is contained in:
Ian McInerney 2020-10-04 00:34:23 +01:00
parent 7a4900b8dc
commit b1bd1f2a97
29 changed files with 366 additions and 65 deletions

View File

@ -441,6 +441,7 @@ set( BMAPS_MID
tools
undo
unit_inch
unit_mil
unit_mm
unknown
unlocked

View File

@ -0,0 +1,29 @@
/* Do not modify this file, it was automatically generated by the
* PNG2cpp CMake script, using a *.png file as input.
*/
#include <bitmaps_png/bitmaps_list.h>
static const unsigned char png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x04, 0x00, 0x00, 0x00, 0x03, 0x43, 0x84,
0x45, 0x00, 0x00, 0x00, 0xc1, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0x63, 0x60, 0x18, 0xda, 0xc0,
0xe8, 0x80, 0xd1, 0x01, 0x06, 0x06, 0x13, 0x07, 0xe3, 0xff, 0x26, 0x0e, 0xb4, 0xd5, 0x04, 0x01,
0x38, 0x34, 0x19, 0x28, 0x98, 0x34, 0x18, 0x87, 0x1a, 0xaf, 0x34, 0x99, 0x67, 0xa4, 0x62, 0x64,
0x0b, 0xa1, 0xc1, 0x36, 0x25, 0x18, 0x25, 0xe0, 0xd4, 0x04, 0x12, 0x36, 0xfe, 0x6d, 0xfc, 0xd8,
0xf8, 0xb5, 0xf1, 0x2b, 0xe3, 0x5f, 0x60, 0xfa, 0xbe, 0x36, 0x1b, 0x01, 0xe7, 0x99, 0xb8, 0x02,
0x35, 0x5d, 0xd4, 0xe3, 0x36, 0x0a, 0x03, 0xd2, 0xe7, 0x80, 0x74, 0xa0, 0xf1, 0x7f, 0x43, 0x13,
0x42, 0x9a, 0x80, 0xc2, 0x66, 0x81, 0xa8, 0x34, 0x48, 0x19, 0x41, 0x4d, 0x20, 0x61, 0x74, 0x7a,
0x28, 0x6b, 0xa2, 0x23, 0x60, 0x62, 0x30, 0x63, 0x28, 0x63, 0xe0, 0xc0, 0x2a, 0xc7, 0xc9, 0x50,
0xc5, 0x60, 0x05, 0x54, 0x81, 0x02, 0x94, 0x18, 0x72, 0x18, 0xb6, 0x31, 0x9c, 0x61, 0xa8, 0xc1,
0x69, 0x64, 0x1d, 0x50, 0x76, 0x07, 0x43, 0x01, 0x83, 0x0a, 0x84, 0xcb, 0x01, 0x54, 0x7a, 0x86,
0x04, 0x58, 0x03, 0x73, 0x8d, 0x0a, 0xd0, 0x8c, 0x1d, 0x40, 0x81, 0x5a, 0xbc, 0x36, 0x6d, 0x03,
0xba, 0x47, 0x09, 0xdd, 0x4f, 0x56, 0x40, 0x97, 0x73, 0xe2, 0xf0, 0x53, 0x39, 0xd0, 0xc7, 0x4c,
0x0c, 0xa3, 0x00, 0x15, 0x00, 0x00, 0x89, 0x8d, 0x81, 0x76, 0x63, 0xa4, 0xd2, 0x82, 0x00, 0x00,
0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
};
const BITMAP_OPAQUE unit_mil_xpm[1] = {{ png, sizeof( png ), "unit_mil_xpm" }};
//EOF

View File

@ -468,6 +468,7 @@ EXTERN_BITMAP( triangle_down_xpm )
EXTERN_BITMAP( undelete_xpm )
EXTERN_BITMAP( undo_xpm )
EXTERN_BITMAP( unit_inch_xpm )
EXTERN_BITMAP( unit_mil_xpm )
EXTERN_BITMAP( unit_mm_xpm )
EXTERN_BITMAP( unknown_xpm )
EXTERN_BITMAP( unlocked_xpm )

View File

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="26"
width="26"
version="1.1"
id="svg2"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="unit_mil.svg">
<metadata
id="metadata22">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2560"
inkscape:window-height="1412"
id="namedview20"
showgrid="true"
inkscape:snap-to-guides="false"
inkscape:snap-grids="true"
inkscape:zoom="21.730769"
inkscape:cx="9.8938053"
inkscape:cy="16.773451"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
showguides="true"
inkscape:guide-bbox="true"
inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid2999"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
spacingx="0.5"
spacingy="0.5"
originx="0"
originy="0" />
</sodipodi:namedview>
<defs
id="defs4">
<marker
inkscape:stockid="Arrow2Mend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Mend"
style="overflow:visible;">
<path
id="path3800"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(0.6) rotate(180) translate(0,0)" />
</marker>
<marker
inkscape:stockid="Arrow2Mstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Mstart"
style="overflow:visible">
<path
id="path3797"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(0.6) translate(0,0)" />
</marker>
<marker
inkscape:stockid="TriangleInS"
orient="auto"
refY="0.0"
refX="0.0"
id="TriangleInS"
style="overflow:visible">
<path
id="path3912"
d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
transform="scale(-0.2)" />
</marker>
<marker
inkscape:stockid="Arrow1Sstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Sstart"
style="overflow:visible">
<path
id="path3785"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
transform="scale(0.2) translate(6,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Mstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Mstart"
style="overflow:visible">
<path
id="path3779"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
transform="scale(0.4) translate(10,0)" />
</marker>
<marker
id="d"
refY="0"
refX="0"
overflow="visible"
orient="auto"
style="overflow:visible">
<path
d="M 5.77,0 -2.88,5 V -5 l 8.65,5 z"
transform="scale(0.4,0.4)"
id="path7"
inkscape:connector-curvature="0"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt" />
</marker>
<marker
id="c"
refY="0"
refX="0"
overflow="visible"
orient="auto"
style="overflow:visible">
<path
d="M 5.77,0 -2.88,5 V -5 l 8.65,5 z"
transform="scale(-0.4,-0.4)"
id="path10"
inkscape:connector-curvature="0"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt" />
</marker>
</defs>
<path
style="opacity:0.80000000000000004;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;marker-start:url(#Arrow2Mstart);marker-end:url(#Arrow2Mend)"
inkscape:connector-curvature="0"
id="path14"
d="m 2,18.5 22,0"
sodipodi:nodetypes="cc" />
<path
inkscape:connector-curvature="0"
id="path3816"
d="M 5.5,6.5 V 14"
style="fill:none;stroke:#333333;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cccc"
style="fill:none;stroke:#333333;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 5.5,9 C 5.5,9 6.5,7 8,7 9,7 9.5,8 9.5,8.75 9.5,10 9.5,14 9.5,14"
id="path3818"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path3820"
d="M 9.5,9 C 9.5,9 10.5,7 12,7 13,7 13.5,8 13.5,8.75 13.5,10 13.5,14 13.5,14"
style="fill:none;stroke:#333333;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:nodetypes="cccc" />
<path
sodipodi:nodetypes="cc"
style="fill:none;stroke:#333333;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 17,6.5 V 14"
id="path3822"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#333333;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 20.5,3 V 14"
id="path3004"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path4193"
d="M 17,3 V 5"
style="fill:none;stroke:#333333;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -181,6 +181,37 @@ void KIID::ConvertTimestampToUuid()
}
bool IsImperialUnit( EDA_UNITS aUnit )
{
switch( aUnit )
{
case EDA_UNITS::INCHES:
case EDA_UNITS::MILS:
return true;
default:
return false;
}
return false;
}
bool IsMetricUnit( EDA_UNITS aUnit )
{
switch( aUnit )
{
case EDA_UNITS::MILLIMETRES:
return true;
default:
return false;
}
return false;
}
/**
* Global variables definitions.
*

View File

@ -22,10 +22,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <tool/actions.h>
#include <bitmaps.h>
#include <common.h>
#include <frame_type.h>
#include <tool/actions.h>
// Actions, being statically-defined, require specialized I18N handling. We continue to
// use the _() macro so that string harvesting by the I18N framework doesn't have to be
@ -458,20 +458,25 @@ TOOL_ACTION ACTIONS::gridProperties( "common.Control.gridProperties",
_( "Grid Properties..." ), _( "Set grid dimensions" ),
grid_select_xpm );
TOOL_ACTION ACTIONS::imperialUnits( "common.Control.imperialUnits",
TOOL_ACTION ACTIONS::inchesUnits( "common.Control.imperialUnits",
AS_GLOBAL, 0, "",
_( "Imperial" ), _( "Use inches and mils" ),
unit_inch_xpm );
_( "Inches" ), _( "Use inches" ),
unit_inch_xpm, AF_NONE, (void*) EDA_UNITS::INCHES );
TOOL_ACTION ACTIONS::metricUnits( "common.Control.metricUnits",
TOOL_ACTION ACTIONS::milsUnits( "common.Control.mils",
AS_GLOBAL, 0, "",
_( "Metric" ), _( "Use millimeters" ),
unit_mm_xpm );
_( "Mils" ), _( "Use mils" ),
unit_mil_xpm, AF_NONE, (void*) EDA_UNITS::MILS );
TOOL_ACTION ACTIONS::millimetersUnits( "common.Control.metricUnits",
AS_GLOBAL, 0, "",
_( "Millimeters" ), _( "Use millimeters" ),
unit_mm_xpm, AF_NONE, (void*) EDA_UNITS::MILLIMETRES );
TOOL_ACTION ACTIONS::toggleUnits( "common.Control.toggleUnits",
AS_GLOBAL,
MD_CTRL + 'U', LEGACY_HK_NAME( "Switch Units" ),
_( "Switch units" ), _( "Switch between inches and millimeters" ),
_( "Switch units" ), _( "Switch between imperial and metric units" ),
unit_mm_xpm );
TOOL_ACTION ACTIONS::togglePolarCoords( "common.Control.togglePolarCoords",

View File

@ -44,6 +44,8 @@
void COMMON_TOOLS::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<EDA_DRAW_FRAME>();
m_metricUnit = EDA_UNITS::MILLIMETRES;
m_imperialUnit = EDA_UNITS::INCHES;
GRID_SETTINGS& settings = m_toolMgr->GetSettings()->m_Window.grid;
@ -483,25 +485,27 @@ int COMMON_TOOLS::GridProperties( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::MetricUnits( const TOOL_EVENT& aEvent )
int COMMON_TOOLS::SwitchUnits( const TOOL_EVENT& aEvent )
{
m_frame->ChangeUserUnits( EDA_UNITS::MILLIMETRES );
return 0;
}
EDA_UNITS newUnit = aEvent.Parameter<EDA_UNITS>();
if( IsMetricUnit( newUnit ) )
m_metricUnit = newUnit;
else if( IsImperialUnit( newUnit ) )
m_imperialUnit = newUnit;
else
wxASSERT_MSG( false, "Invalid unit for the frame" );
int COMMON_TOOLS::ImperialUnits( const TOOL_EVENT& aEvent )
{
m_frame->ChangeUserUnits( EDA_UNITS::INCHES );
m_frame->ChangeUserUnits( newUnit );
return 0;
}
int COMMON_TOOLS::ToggleUnits( const TOOL_EVENT& aEvent )
{
m_frame->ChangeUserUnits( m_frame->GetUserUnits() == EDA_UNITS::INCHES ?
EDA_UNITS::MILLIMETRES :
EDA_UNITS::INCHES );
m_frame->ChangeUserUnits( IsImperialUnit( m_frame->GetUserUnits() ) ?
m_metricUnit :
m_imperialUnit );
return 0;
}
@ -615,8 +619,9 @@ void COMMON_TOOLS::setTransitions()
Go( &COMMON_TOOLS::GridProperties, ACTIONS::gridProperties.MakeEvent() );
// Units and coordinates
Go( &COMMON_TOOLS::ImperialUnits, ACTIONS::imperialUnits.MakeEvent() );
Go( &COMMON_TOOLS::MetricUnits, ACTIONS::metricUnits.MakeEvent() );
Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::inchesUnits.MakeEvent() );
Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::milsUnits.MakeEvent() );
Go( &COMMON_TOOLS::SwitchUnits, ACTIONS::millimetersUnits.MakeEvent() );
Go( &COMMON_TOOLS::ToggleUnits, ACTIONS::toggleUnits.MakeEvent() );
Go( &COMMON_TOOLS::TogglePolarCoords, ACTIONS::togglePolarCoords.MakeEvent() );
Go( &COMMON_TOOLS::ResetLocalCoords, ACTIONS::resetLocalCoords.MakeEvent() );

View File

@ -44,7 +44,7 @@ GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) :
wxArrayString gridsList;
int i = ID_POPUP_GRID_START;
BuildChoiceList( &gridsList, settings, m_parent->GetUserUnits() != EDA_UNITS::INCHES );
BuildChoiceList( &gridsList, settings, IsMetricUnit( m_parent->GetUserUnits() ) );
for( const wxString& grid : gridsList )
Append( i++, grid, wxEmptyString, wxITEM_CHECK );

View File

@ -198,8 +198,9 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
auto autoZoomCond =
@ -249,8 +250,9 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateOptToolbar()
m_optionsToolBar->AddScaledSeparator( this );
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::inchesUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddScaledSeparator( this );

View File

@ -339,8 +339,9 @@ void LIB_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) );
mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );

View File

@ -121,8 +121,9 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->SetIcon( unit_mm_xpm );
unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );

View File

@ -158,8 +158,9 @@ void LIB_EDIT_FRAME::ReCreateOptToolbar()
}
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::inchesUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( EE_ACTIONS::showElectricalTypes, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( EE_ACTIONS::showComponentTree, ACTION_TOOLBAR::TOGGLE );

View File

@ -179,8 +179,9 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->SetIcon( unit_mm_xpm );
unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );

View File

@ -378,8 +378,9 @@ void SCH_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) );
mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );

View File

@ -169,8 +169,9 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar()
}
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::inchesUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( EE_ACTIONS::toggleHiddenPins, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( EE_ACTIONS::toggleForceHV, ACTION_TOOLBAR::TOGGLE );

View File

@ -1189,8 +1189,9 @@ void GERBVIEW_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::togglePolarCoords, CHECK( cond.PolarCoordinates() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) );
mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );

View File

@ -189,8 +189,9 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->SetIcon( unit_mm_xpm );
unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu );

View File

@ -249,8 +249,9 @@ void GERBVIEW_FRAME::ReCreateOptToolbar()
m_optionsToolBar->AddScaledSeparator( this );
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::inchesUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddScaledSeparator( this );

View File

@ -207,6 +207,9 @@ enum class EDA_UNITS
MILS = 5,
};
bool IsImperialUnit( EDA_UNITS aUnit );
bool IsMetricUnit( EDA_UNITS aUnit );
/**
* Instantiate the current locale within a scope in which you are expecting

View File

@ -139,8 +139,9 @@ public:
static TOOL_ACTION gridProperties;
// Units
static TOOL_ACTION imperialUnits;
static TOOL_ACTION metricUnits;
static TOOL_ACTION inchesUnits;
static TOOL_ACTION milsUnits;
static TOOL_ACTION millimetersUnits;
static TOOL_ACTION toggleUnits;
static TOOL_ACTION togglePolarCoords;
static TOOL_ACTION resetLocalCoords;

View File

@ -69,8 +69,7 @@ public:
int ToggleCursorStyle( const TOOL_EVENT& aEvent );
// Units control
int ImperialUnits( const TOOL_EVENT& aEvent );
int MetricUnits( const TOOL_EVENT& aEvent );
int SwitchUnits( const TOOL_EVENT& aEvent );
int ToggleUnits( const TOOL_EVENT& aEvent );
int TogglePolarCoords( const TOOL_EVENT& aEvent );
int ResetLocalCoords( const TOOL_EVENT& aEvent );
@ -114,6 +113,10 @@ private:
std::vector<VECTOR2I> m_grids; // grids from APP_SETTINGS converted to internal units
// and with the user grid appended
// The last used units in each system (used for toggling between metric and imperial)
EDA_UNITS m_imperialUnit;
EDA_UNITS m_metricUnit;
};
#endif

View File

@ -917,8 +917,9 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) );
mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );

View File

@ -310,8 +310,9 @@ void FOOTPRINT_VIEWER_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );

View File

@ -148,8 +148,9 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->SetIcon( unit_mm_xpm );
unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );

View File

@ -257,8 +257,9 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->SetIcon( unit_mm_xpm );
unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
viewMenu->Add( unitsSubMenu );
viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );

View File

@ -527,8 +527,9 @@ void PCB_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
mgr->SetConditions( ACTIONS::togglePolarCoords, CHECK( cond.PolarCoordinates() ) );
mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) );
mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );

View File

@ -190,8 +190,9 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::inchesUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddScaledSeparator( this );

View File

@ -120,8 +120,9 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateOptToolbar()
m_optionsToolBar->AddScaledSeparator( this );
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::inchesUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddScaledSeparator( this );

View File

@ -342,8 +342,9 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar()
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::inchesUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddScaledSeparator( this );