From ebcc1ac062c2307c311b0fb348a3d168a8867b88 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 19 Dec 2022 12:27:34 +0000 Subject: [PATCH] Use current cursorPos when creating sheet pins. Fixes https://gitlab.com/kicad/code/kicad/issues/13206 --- eeschema/tools/sch_drawing_tools.cpp | 14 +++++++------- eeschema/tools/sch_drawing_tools.h | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index bb2d8d8d62..f2e764af7c 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -732,7 +732,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) return 0; } - previewItem = createSheetPin( sheet, label ); + previewItem = createSheetPin( sheet, label, cursorPos ); } break; @@ -743,9 +743,8 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - cursorPos = static_cast( aEvent.HasPosition() ? - aEvent.Position() : - controls->GetMousePosition() ); + cursorPos = static_cast( aEvent.HasPosition() ? aEvent.Position() + : controls->GetMousePosition() ); m_frame->PushTool( aEvent ); @@ -1071,7 +1070,8 @@ SCH_HIERLABEL* SCH_DRAWING_TOOLS::importHierLabel( SCH_SHEET* aSheet ) } -SCH_SHEET_PIN* SCH_DRAWING_TOOLS::createSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel ) +SCH_SHEET_PIN* SCH_DRAWING_TOOLS::createSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel, + const VECTOR2I& aPosition ) { SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings(); wxString text; @@ -1101,7 +1101,7 @@ SCH_SHEET_PIN* SCH_DRAWING_TOOLS::createSheetPin( SCH_SHEET* aSheet, SCH_HIERLAB m_lastSheetPinType = sheetPin->GetShape(); - sheetPin->SetPosition( (VECTOR2I) getViewControls()->GetCursorPosition() ); + sheetPin->SetPosition( aPosition ); return sheetPin; } @@ -1360,7 +1360,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) } else { - item = createSheetPin( sheet, label ); + item = createSheetPin( sheet, label, cursorPos ); if( item->Type() == SCH_SHEET_PIN_T ) { diff --git a/eeschema/tools/sch_drawing_tools.h b/eeschema/tools/sch_drawing_tools.h index 65001b5bfd..f3a0d65e0e 100644 --- a/eeschema/tools/sch_drawing_tools.h +++ b/eeschema/tools/sch_drawing_tools.h @@ -66,7 +66,8 @@ private: SCH_HIERLABEL* importHierLabel( SCH_SHEET* aSheet ); - SCH_SHEET_PIN* createSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel ); + SCH_SHEET_PIN* createSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL* aLabel, + const VECTOR2I& aPosition ); void sizeSheet( SCH_SHEET* aSheet, const VECTOR2I& aPos );