Browse Source
Add CCW rotation to GAL canvas
Add CCW rotation to GAL canvas
This makes "rotate" into two separate TOOL_EVENTs, which each have a "multiplier" parameter. Also added is a namespace for 'free functions' that use TOOL_EVENT public interfaces (perhaps with other inputs too) to centralise some decision-making and calculations. Fixes: lp:1660731 * https://bugs.launchpad.net/kicad/+bug/1660731pull/3/merge
committed by
Maciej Suminski
9 changed files with 168 additions and 20 deletions
-
1pcbnew/CMakeLists.txt
-
10pcbnew/tools/common_actions.cpp
-
7pcbnew/tools/common_actions.h
-
21pcbnew/tools/drawing_tool.cpp
-
11pcbnew/tools/edit_tool.cpp
-
14pcbnew/tools/module_editor_tools.cpp
-
8pcbnew/tools/pcb_editor_control.cpp
-
48pcbnew/tools/tool_event_utils.cpp
-
68pcbnew/tools/tool_event_utils.h
@ -0,0 +1,48 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
|
|||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <tools/tool_event_utils.h>
|
|||
|
|||
#include <tools/common_actions.h>
|
|||
|
|||
#include <pcb_base_edit_frame.h>
|
|||
|
|||
|
|||
bool TOOL_EVT_UTILS::IsRotateToolEvt( const TOOL_EVENT& aEvt ) |
|||
{ |
|||
return aEvt.IsAction( &COMMON_ACTIONS::rotateCw ) |
|||
|| aEvt.IsAction( &COMMON_ACTIONS::rotateCcw ); |
|||
} |
|||
|
|||
|
|||
int TOOL_EVT_UTILS::GetEventRotationAngle( const PCB_BASE_EDIT_FRAME& aFrame, |
|||
const TOOL_EVENT& aEvt ) |
|||
{ |
|||
wxASSERT_MSG( IsRotateToolEvt( aEvt ), |
|||
_( "Expected rotation event" ) ); |
|||
|
|||
const int rotAngle = aFrame.GetRotationAngle(); |
|||
const int angleMultiplier = aEvt.Parameter<intptr_t>(); |
|||
|
|||
return rotAngle * angleMultiplier; |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
|
|||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#ifndef TOOL_EVENT_UTILS_H |
|||
#define TOOL_EVENT_UTILS_H |
|||
|
|||
#include <tool/tool_interactive.h> |
|||
|
|||
|
|||
class PCB_BASE_EDIT_FRAME; |
|||
|
|||
|
|||
/** |
|||
* Namespace TOOL_EVT_UTILS |
|||
* |
|||
* Utility functions for dealing with various tool events. These are |
|||
* free functions, so they interface with any classes exclusively via |
|||
* the public interfaces, so they don't need to be subsumed into the |
|||
* "helped" classes. |
|||
*/ |
|||
namespace TOOL_EVT_UTILS |
|||
{ |
|||
/** |
|||
* Function isRotateToolEvt() |
|||
* |
|||
* @param aEvt event to check |
|||
* @return true if the event is a rotation action tool event |
|||
*/ |
|||
bool IsRotateToolEvt( const TOOL_EVENT& aEvt ); |
|||
|
|||
/** |
|||
* Function getEventRotationAngle() |
|||
* |
|||
* Helper function to get a rotation angle based on a frame's |
|||
* configured angle and the direction indicated by a rotation action event |
|||
* |
|||
* @param aFrame the PCB edit frame to use to get the base rotation |
|||
* step value from |
|||
* @param aEvt the tool event - should be a rotation action event |
|||
* and should have a rotation multiplier parameter |
|||
* |
|||
* @return the rotation angle in clockwise internal units |
|||
*/ |
|||
int GetEventRotationAngle( const PCB_BASE_EDIT_FRAME& aFrame, |
|||
const TOOL_EVENT& aEvt ); |
|||
}; |
|||
|
|||
#endif // TOOL_EVENT_UTILS_H |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue