Move PCBNew rotation increment to EDA_ANGLE.
This commit is contained in:
parent
c9487bad18
commit
5176512de3
|
@ -48,7 +48,8 @@ PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||||
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
||||||
const wxString& aFrameName ) :
|
const wxString& aFrameName ) :
|
||||||
PCB_BASE_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
|
PCB_BASE_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
|
||||||
m_rotationAngle( 900 ), m_undoRedoBlocked( false ),
|
m_rotationAngle( ANGLE_90 ),
|
||||||
|
m_undoRedoBlocked( false ),
|
||||||
m_selectionFilterPanel( nullptr ),
|
m_selectionFilterPanel( nullptr ),
|
||||||
m_appearancePanel( nullptr )
|
m_appearancePanel( nullptr )
|
||||||
{
|
{
|
||||||
|
@ -158,9 +159,10 @@ bool PCB_BASE_EDIT_FRAME::TryBefore( wxEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
|
void PCB_BASE_EDIT_FRAME::SetRotationAngle( EDA_ANGLE aRotationAngle )
|
||||||
{
|
{
|
||||||
wxCHECK2_MSG( aRotationAngle > 0 && aRotationAngle <= 900, aRotationAngle = 900,
|
wxCHECK2_MSG( aRotationAngle > ANGLE_0 && aRotationAngle <= ANGLE_90,
|
||||||
|
aRotationAngle = ANGLE_90,
|
||||||
wxT( "Invalid rotation angle, defaulting to 90." ) );
|
wxT( "Invalid rotation angle, defaulting to 90." ) );
|
||||||
|
|
||||||
m_rotationAngle = aRotationAngle;
|
m_rotationAngle = aRotationAngle;
|
||||||
|
|
|
@ -159,12 +159,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Return the angle used for rotate operations.
|
* Return the angle used for rotate operations.
|
||||||
*/
|
*/
|
||||||
int GetRotationAngle() const { return m_rotationAngle; }
|
EDA_ANGLE GetRotationAngle() const { return m_rotationAngle; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the angle used for rotate operations.
|
* Set the angle used for rotate operations.
|
||||||
*/
|
*/
|
||||||
void SetRotationAngle( int aRotationAngle );
|
void SetRotationAngle( EDA_ANGLE aRotationAngle );
|
||||||
|
|
||||||
void ShowTextPropertiesDialog( BOARD_ITEM* aText );
|
void ShowTextPropertiesDialog( BOARD_ITEM* aText );
|
||||||
void ShowGraphicItemPropertiesDialog( BOARD_ITEM* aItem );
|
void ShowGraphicItemPropertiesDialog( BOARD_ITEM* aItem );
|
||||||
|
@ -226,7 +226,7 @@ protected:
|
||||||
void unitsChangeRefresh() override;
|
void unitsChangeRefresh() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_rotationAngle; // Rotation step (in tenths of a degree)
|
EDA_ANGLE m_rotationAngle; // Rotation step (in tenths of a degree)
|
||||||
bool m_undoRedoBlocked;
|
bool m_undoRedoBlocked;
|
||||||
|
|
||||||
PANEL_SELECTION_FILTER* m_selectionFilterPanel;
|
PANEL_SELECTION_FILTER* m_selectionFilterPanel;
|
||||||
|
|
|
@ -192,7 +192,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
// assume dirty
|
// assume dirty
|
||||||
m_ZoneFillsDirty = true;
|
m_ZoneFillsDirty = true;
|
||||||
|
|
||||||
m_rotationAngle = 900;
|
m_rotationAngle = ANGLE_90;
|
||||||
m_aboutTitle = _( "KiCad PCB Editor" );
|
m_aboutTitle = _( "KiCad PCB Editor" );
|
||||||
|
|
||||||
// Must be created before the menus are created.
|
// Must be created before the menus are created.
|
||||||
|
@ -1048,7 +1048,7 @@ void PCB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
|
|
||||||
if( cfg )
|
if( cfg )
|
||||||
{
|
{
|
||||||
m_rotationAngle = cfg->m_RotationAngle;
|
m_rotationAngle = EDA_ANGLE( cfg->m_RotationAngle, TENTHS_OF_A_DEGREE_T );
|
||||||
m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
|
m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1063,7 +1063,7 @@ void PCB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
|
|
||||||
if( cfg )
|
if( cfg )
|
||||||
{
|
{
|
||||||
cfg->m_RotationAngle = m_rotationAngle;
|
cfg->m_RotationAngle = m_rotationAngle.AsTenthsOfADegree();
|
||||||
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
|
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
|
||||||
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
|
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
|
||||||
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
|
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
|
||||||
|
|
|
@ -1461,8 +1461,8 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
updateModificationPoint( selection );
|
updateModificationPoint( selection );
|
||||||
|
|
||||||
VECTOR2I refPt = selection.GetReferencePoint();
|
VECTOR2I refPt = selection.GetReferencePoint();
|
||||||
const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
|
EDA_ANGLE rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
|
||||||
|
|
||||||
// When editing footprints, all items have the same parent
|
// When editing footprints, all items have the same parent
|
||||||
if( IsFootprintEditor() )
|
if( IsFootprintEditor() )
|
||||||
|
@ -1484,7 +1484,7 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<BOARD_ITEM*>( item )->Rotate( refPt, EDA_ANGLE( rotateAngle, TENTHS_OF_A_DEGREE_T ) );
|
static_cast<BOARD_ITEM*>( item )->Rotate( refPt, rotateAngle );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_dragging )
|
if( !m_dragging )
|
||||||
|
|
|
@ -217,8 +217,8 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
|
||||||
*/
|
*/
|
||||||
if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
|
if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
|
||||||
{
|
{
|
||||||
const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
|
EDA_ANGLE rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
|
||||||
newItem->Rotate( newItem->GetPosition(), EDA_ANGLE( rotationAngle, TENTHS_OF_A_DEGREE_T ) );
|
newItem->Rotate( newItem->GetPosition(), rotationAngle );
|
||||||
view()->Update( &preview );
|
view()->Update( &preview );
|
||||||
}
|
}
|
||||||
else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
|
else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
|
||||||
|
|
|
@ -33,13 +33,15 @@ bool TOOL_EVT_UTILS::IsRotateToolEvt( const TOOL_EVENT& aEvt )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TOOL_EVT_UTILS::GetEventRotationAngle( const PCB_BASE_EDIT_FRAME& aFrame,
|
EDA_ANGLE TOOL_EVT_UTILS::GetEventRotationAngle( const PCB_BASE_EDIT_FRAME& aFrame,
|
||||||
const TOOL_EVENT& aEvt )
|
const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( IsRotateToolEvt( aEvt ), "Expected rotation event" );
|
wxASSERT_MSG( IsRotateToolEvt( aEvent ), "Expected rotation event" );
|
||||||
|
|
||||||
const int rotAngle = aFrame.GetRotationAngle();
|
EDA_ANGLE rotAngle = aFrame.GetRotationAngle();
|
||||||
const int angleMultiplier = aEvt.Parameter<intptr_t>();
|
const int angleMultiplier = aEvent.Parameter<intptr_t>();
|
||||||
|
|
||||||
return rotAngle * angleMultiplier;
|
wxASSERT_MSG( angleMultiplier == 1 || angleMultiplier == -1, "Expected 1 or -1" );
|
||||||
|
|
||||||
|
return angleMultiplier > 0 ? rotAngle : -rotAngle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
|
||||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
#define TOOL_EVENT_UTILS_H
|
#define TOOL_EVENT_UTILS_H
|
||||||
|
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
|
#include <eda_angle.h>
|
||||||
|
|
||||||
|
|
||||||
class PCB_BASE_EDIT_FRAME;
|
class PCB_BASE_EDIT_FRAME;
|
||||||
|
@ -33,10 +34,9 @@ class PCB_BASE_EDIT_FRAME;
|
||||||
/**
|
/**
|
||||||
* Namespace TOOL_EVT_UTILS
|
* Namespace TOOL_EVT_UTILS
|
||||||
*
|
*
|
||||||
* Utility functions for dealing with various tool events. These are
|
* Utility functions for dealing with various tool events. These are free functions, so they
|
||||||
* free functions, so they interface with any classes exclusively via
|
* interface with any classes exclusively via the public interfaces, so they don't need to be
|
||||||
* the public interfaces, so they don't need to be subsumed into the
|
* subsumed into the "helped" classes.
|
||||||
* "helped" classes.
|
|
||||||
*/
|
*/
|
||||||
namespace TOOL_EVT_UTILS
|
namespace TOOL_EVT_UTILS
|
||||||
{
|
{
|
||||||
|
@ -51,18 +51,16 @@ namespace TOOL_EVT_UTILS
|
||||||
/**
|
/**
|
||||||
* Function getEventRotationAngle()
|
* Function getEventRotationAngle()
|
||||||
*
|
*
|
||||||
* Helper function to get a rotation angle based on a frame's
|
* Helper function to get a rotation angle based on a frame's configured angle and the
|
||||||
* configured angle and the direction indicated by a rotation action event
|
* direction indicated by a rotation action event
|
||||||
*
|
*
|
||||||
* @param aFrame the PCB edit frame to use to get the base rotation
|
* @param aFrame the PCB edit frame to use to get the base rotation step value from
|
||||||
* step value from
|
* @param aEvt the tool event - should be a rotation action event and should have a rotation
|
||||||
* @param aEvt the tool event - should be a rotation action event
|
* multiplier parameter
|
||||||
* and should have a rotation multiplier parameter
|
|
||||||
*
|
*
|
||||||
* @return the rotation angle in clockwise internal units
|
* @return the clockwise rotation angle
|
||||||
*/
|
*/
|
||||||
int GetEventRotationAngle( const PCB_BASE_EDIT_FRAME& aFrame,
|
EDA_ANGLE GetEventRotationAngle( const PCB_BASE_EDIT_FRAME& aFrame, const TOOL_EVENT& aEvent );
|
||||||
const TOOL_EVENT& aEvt );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TOOL_EVENT_UTILS_H
|
#endif // TOOL_EVENT_UTILS_H
|
||||||
|
|
Loading…
Reference in New Issue