Fixed relative coordinates reset when a tool forces the cursor position

Fixes: lp:1759044
* https://bugs.launchpad.net/kicad/+bug/1759044
This commit is contained in:
Maciej Suminski 2018-04-24 12:55:33 +02:00
parent 482fd866b3
commit 143d580596
3 changed files with 20 additions and 1 deletions

View File

@ -835,6 +835,15 @@ std::string TOOL_MANAGER::GetClipboard() const
} }
KIGFX::VC_SETTINGS TOOL_MANAGER::GetCurrentToolVC() const
{
if( TOOL_STATE* active = GetCurrentToolState() )
return active->vcSettings;
return m_viewControls->GetSettings();
}
TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName ) TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName )
{ {
static int currentId; static int currentId;

View File

@ -366,6 +366,12 @@ public:
*/ */
std::string GetClipboard() const; std::string GetClipboard() const;
/**
* Returns the view controls settings for the current tool or the general settings if there is
* no active tool.
*/
KIGFX::VC_SETTINGS& GetCurrentToolVC() const;
private: private:
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION; typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;

View File

@ -751,7 +751,11 @@ int PCBNEW_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent )
// Miscellaneous // Miscellaneous
int PCBNEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
{ {
VECTOR2I cursorPos = getViewControls()->GetCursorPosition(); auto vcSettings = m_toolMgr->GetCurrentToolVC();
// Use either the active tool forced cursor position or the general settings
VECTOR2I cursorPos = vcSettings.m_forceCursorPosition ? vcSettings.m_forcedPosition :
getViewControls()->GetCursorPosition();
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y ); m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
m_frame->UpdateStatusBar(); m_frame->UpdateStatusBar();