From 06637a17d667787822beec70af893c358f25effb Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 4 May 2016 14:59:14 +0200 Subject: [PATCH] Added 'Reset Grid Origin' hot key (GAL). --- include/origin_viewitem.h | 3 ++- pcbnew/tools/common_actions.cpp | 6 +++++- pcbnew/tools/common_actions.h | 3 ++- pcbnew/tools/pcbnew_control.cpp | 12 +++++++++++- pcbnew/tools/pcbnew_control.h | 3 ++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/origin_viewitem.h b/include/origin_viewitem.h index 02900fbd5b..7735641903 100644 --- a/include/origin_viewitem.h +++ b/include/origin_viewitem.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 CERN + * Copyright (C) 2013-2016 CERN * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -86,6 +86,7 @@ public: inline void SetPosition( const VECTOR2D& aPosition ) { m_position = aPosition; + ViewUpdate(); } inline const VECTOR2D& GetPosition() const diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index 348b85c238..f452719f66 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013-2015 CERN + * Copyright (C) 2013-2016 CERN * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -331,6 +331,10 @@ TOOL_ACTION COMMON_ACTIONS::gridSetOrigin( "common.Control.gridSetOrigin", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SET_GRID_ORIGIN ), "", "" ); +TOOL_ACTION COMMON_ACTIONS::gridResetOrigin( "common.Control.gridResetOrigin", + AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_GRID_ORIGIN ), + "", "" ); + TOOL_ACTION COMMON_ACTIONS::gridPreset( "common.Control.gridPreset", AS_GLOBAL, 0, "", "" ); diff --git a/pcbnew/tools/common_actions.h b/pcbnew/tools/common_actions.h index 79d10efbb9..fbedcdc2e7 100644 --- a/pcbnew/tools/common_actions.h +++ b/pcbnew/tools/common_actions.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 CERN + * Copyright (C) 2013-2016 CERN * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -230,6 +230,7 @@ public: static TOOL_ACTION gridNext; static TOOL_ACTION gridPrev; static TOOL_ACTION gridSetOrigin; + static TOOL_ACTION gridResetOrigin; static TOOL_ACTION gridPreset; // Track & via size control diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index c2493eae6d..90f00dd99e 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2014 CERN + * Copyright (C) 2014-2016 CERN * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -660,6 +660,15 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent ) } +int PCBNEW_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent ) +{ + getModel()->SetGridOrigin( wxPoint( 0, 0 ) ); + m_gridOrigin->SetPosition( VECTOR2D( 0, 0 ) ); + + return 0; +} + + int PCBNEW_CONTROL::GridPreset( const TOOL_EVENT& aEvent ) { long idx = aEvent.Parameter(); @@ -978,6 +987,7 @@ void PCBNEW_CONTROL::SetTransitions() Go( &PCBNEW_CONTROL::GridNext, COMMON_ACTIONS::gridNext.MakeEvent() ); Go( &PCBNEW_CONTROL::GridPrev, COMMON_ACTIONS::gridPrev.MakeEvent() ); Go( &PCBNEW_CONTROL::GridSetOrigin, COMMON_ACTIONS::gridSetOrigin.MakeEvent() ); + Go( &PCBNEW_CONTROL::GridResetOrigin, COMMON_ACTIONS::gridResetOrigin.MakeEvent() ); Go( &PCBNEW_CONTROL::GridPreset, COMMON_ACTIONS::gridPreset.MakeEvent() ); // Miscellaneous diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h index 78374f477e..1117b775be 100644 --- a/pcbnew/tools/pcbnew_control.h +++ b/pcbnew/tools/pcbnew_control.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2014 CERN + * Copyright (C) 2014-2016 CERN * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -80,6 +80,7 @@ public: int GridNext( const TOOL_EVENT& aEvent ); int GridPrev( const TOOL_EVENT& aEvent ); int GridSetOrigin( const TOOL_EVENT& aEvent ); + int GridResetOrigin( const TOOL_EVENT& aEvent ); int GridPreset( const TOOL_EVENT& aEvent ); // Miscellaneous