2017-02-20 18:10:20 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014-2016 CERN
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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 _COMMON_TOOLS_H
|
|
|
|
#define _COMMON_TOOLS_H
|
|
|
|
|
|
|
|
#include <tool/tool_interactive.h>
|
|
|
|
|
|
|
|
class EDA_DRAW_FRAME;
|
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* COMMON_TOOLS
|
2017-02-20 18:10:20 +00:00
|
|
|
*
|
|
|
|
* Handles actions that are shared between different applications
|
|
|
|
*/
|
|
|
|
|
|
|
|
class COMMON_TOOLS : public TOOL_INTERACTIVE
|
|
|
|
{
|
|
|
|
public:
|
2020-10-05 19:26:33 +00:00
|
|
|
COMMON_TOOLS();
|
2019-05-14 19:21:10 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
~COMMON_TOOLS() override { }
|
2017-02-20 18:10:20 +00:00
|
|
|
|
|
|
|
/// @copydoc TOOL_BASE::Reset()
|
|
|
|
void Reset( RESET_REASON aReason ) override;
|
|
|
|
|
2019-06-27 11:47:24 +00:00
|
|
|
int SelectionTool( const TOOL_EVENT& aEvent );
|
|
|
|
|
2017-02-20 18:10:20 +00:00
|
|
|
// View controls
|
2019-04-11 01:23:34 +00:00
|
|
|
int ZoomRedraw( const TOOL_EVENT& aEvent );
|
2017-02-20 18:10:20 +00:00
|
|
|
int ZoomInOut( const TOOL_EVENT& aEvent );
|
|
|
|
int ZoomInOutCenter( const TOOL_EVENT& aEvent );
|
|
|
|
int ZoomCenter( const TOOL_EVENT& aEvent );
|
2017-02-23 04:31:26 +00:00
|
|
|
int ZoomFitScreen( const TOOL_EVENT& aEvent );
|
2020-09-11 07:51:00 +00:00
|
|
|
int ZoomFitObjects( const TOOL_EVENT& aEvent );
|
2017-02-23 04:31:26 +00:00
|
|
|
int ZoomPreset( const TOOL_EVENT& aEvent );
|
2017-02-20 18:10:20 +00:00
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
int CenterContents( const TOOL_EVENT& aEvent );
|
|
|
|
|
2018-10-03 16:26:33 +00:00
|
|
|
int PanControl( const TOOL_EVENT& aEvent );
|
|
|
|
|
2017-03-18 20:03:24 +00:00
|
|
|
// Cursor control
|
2018-10-03 16:26:33 +00:00
|
|
|
int CursorControl( const TOOL_EVENT& aEvent );
|
2017-03-18 20:03:24 +00:00
|
|
|
int ToggleCursor( const TOOL_EVENT& aEvent );
|
2019-05-13 20:42:40 +00:00
|
|
|
int ToggleCursorStyle( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
// Units control
|
2020-10-03 23:34:23 +00:00
|
|
|
int SwitchUnits( const TOOL_EVENT& aEvent );
|
2019-05-13 20:42:40 +00:00
|
|
|
int ToggleUnits( const TOOL_EVENT& aEvent );
|
2019-05-17 11:52:38 +00:00
|
|
|
int TogglePolarCoords( const TOOL_EVENT& aEvent );
|
2019-05-28 14:39:14 +00:00
|
|
|
int ResetLocalCoords( const TOOL_EVENT& aEvent );
|
2017-03-18 20:03:24 +00:00
|
|
|
|
2020-10-05 19:26:33 +00:00
|
|
|
void SetLastUnits( EDA_UNITS aUnit );
|
|
|
|
EDA_UNITS GetLastMetricUnits() { return m_metricUnit; }
|
|
|
|
EDA_UNITS GetLastImperialUnits() { return m_imperialUnit; }
|
|
|
|
|
2017-02-20 18:10:20 +00:00
|
|
|
// Grid control
|
|
|
|
int GridNext( const TOOL_EVENT& aEvent );
|
|
|
|
int GridPrev( const TOOL_EVENT& aEvent );
|
|
|
|
int GridPreset( const TOOL_EVENT& aEvent );
|
2020-06-14 15:08:47 +00:00
|
|
|
int GridFast1( const TOOL_EVENT& aEvent );
|
|
|
|
int GridFast2( const TOOL_EVENT& aEvent );
|
2019-05-13 20:42:40 +00:00
|
|
|
int ToggleGrid( const TOOL_EVENT& aEvent );
|
2019-05-13 21:49:05 +00:00
|
|
|
int GridProperties( const TOOL_EVENT& aEvent );
|
2019-06-19 17:34:02 +00:00
|
|
|
int GridPreset( int idx );
|
2020-06-12 10:58:56 +00:00
|
|
|
int OnGridChanged();
|
2017-02-20 18:10:20 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
int SwitchCanvas( const TOOL_EVENT& aEvent );
|
2019-06-19 17:34:02 +00:00
|
|
|
|
|
|
|
private:
|
2020-09-11 07:51:00 +00:00
|
|
|
/**
|
|
|
|
* Enum ZOOM_FIT_TYPE_T
|
|
|
|
* is the set of "Zoom to Fit" types that can be performed
|
|
|
|
*/
|
|
|
|
enum ZOOM_FIT_TYPE_T
|
|
|
|
{
|
|
|
|
ZOOM_FIT_ALL, // Zoom to fall all items in view INCLUDING page and border
|
|
|
|
ZOOM_FIT_OBJECTS, // Zoom to fit all items in view EXCLUDING page and border
|
|
|
|
};
|
|
|
|
|
2017-02-20 18:10:20 +00:00
|
|
|
///> Sets up handlers for various events.
|
2017-07-31 12:30:51 +00:00
|
|
|
void setTransitions() override;
|
2017-02-20 18:10:20 +00:00
|
|
|
|
|
|
|
///> Pointer to the currently used edit frame.
|
|
|
|
EDA_DRAW_FRAME* m_frame;
|
|
|
|
|
2018-05-25 11:59:57 +00:00
|
|
|
int doZoomInOut( bool aDirection, bool aCenterOnCursor );
|
|
|
|
|
|
|
|
///> Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
|
|
|
|
int doZoomToPreset( int idx, bool aCenterOnCursor );
|
2020-06-12 10:58:56 +00:00
|
|
|
|
2020-09-11 07:51:00 +00:00
|
|
|
int doZoomFit( ZOOM_FIT_TYPE_T aFitType );
|
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
std::vector<VECTOR2I> m_grids; // grids from APP_SETTINGS converted to internal units
|
2020-06-23 10:16:34 +00:00
|
|
|
// and with the user grid appended
|
2020-10-03 23:34:23 +00:00
|
|
|
|
|
|
|
// The last used units in each system (used for toggling between metric and imperial)
|
|
|
|
EDA_UNITS m_imperialUnit;
|
|
|
|
EDA_UNITS m_metricUnit;
|
2017-02-20 18:10:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|