diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 1c0eea1b50..25826424ae 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -169,9 +169,13 @@ public: * Usually return true for small items (labels, junctions) and false for items which can * be large (hierarchical sheets, components). * - * @return false for a component + * Note: we used to try and be smart about this and return false for components in case + * they are big. However, this annoyed some users and we now have a preference which + * controls warping on move in general, so this was switched to true for components. + * + * @return true for a component */ - bool IsMovableFromAnchorPoint() override { return false; } + bool IsMovableFromAnchorPoint() override { return true; } void SetLibId( const LIB_ID& aName, PART_LIBS* aLibs=NULL ); void SetLibId( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aSymLibTable, PART_LIB* aCacheLib ); diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 9c45882d6f..8079879767 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -186,6 +186,7 @@ public: static TOOL_ACTION symbolProperties; static TOOL_ACTION deleteItemCursor; static TOOL_ACTION refreshPreview; + static TOOL_ACTION restartMove; static TOOL_ACTION explicitCrossProbe; static TOOL_ACTION pushPinLength; static TOOL_ACTION pushPinNameSize; diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index add336d319..bb6126d459 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -54,6 +54,9 @@ TOOL_ACTION EE_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview", AS_GLOBAL ); +TOOL_ACTION EE_ACTIONS::restartMove( "eeschema.EditorControl.restartMove", + AS_GLOBAL ); + TOOL_ACTION EE_ACTIONS::simProbe( "eeschema.Simulation.probe", AS_GLOBAL, 0, "", _( "Add a simulator probe" ), "" ); diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index a347327b59..a213a048ba 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -127,7 +127,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) KIGFX::VIEW_CONTROLS* controls = getViewControls(); controls->SetSnapping( true ); - VECTOR2I originalCursorPos = controls->GetCursorPosition(); m_anchorPos.reset(); @@ -153,12 +152,13 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // items so we can start again with the current m_isDragOperation. m_frame->RollbackSchematicFromUndo(); m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE ); + m_anchorPos = m_cursor - m_moveOffset; m_moveInProgress = false; controls->SetAutoPan( false ); // And give it a kick so it doesn't have to wait for the first mouse movement to // refresh. - m_toolMgr->RunAction( EE_ACTIONS::refreshPreview ); + m_toolMgr->RunAction( EE_ACTIONS::restartMove ); } return 0; @@ -187,7 +187,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) { controls->SetSnapping( !evt->Modifier( MD_ALT ) ); - if( evt->IsAction( &EE_ACTIONS::moveActivate ) + if( evt->IsAction( &EE_ACTIONS::moveActivate ) || evt->IsAction( &EE_ACTIONS::restartMove ) || evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::refreshPreview ) ) @@ -237,7 +237,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selection ) static_cast( item )->UpdateDanglingState( internalPoints ); } - +wxMessageBox( wxString::Format( "Size: %d", selection.Size() ) ); // Generic setup // for( EDA_ITEM* item : selection ) @@ -274,17 +274,16 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // m_cursor = controls->GetCursorPosition(); - if( selection.HasReferencePoint() ) + if( evt->IsAction( &EE_ACTIONS::restartMove ) ) + { + wxASSERT_MSG( m_anchorPos, "Should be already set from previous cmd" ); + } + else if( selection.Front()->GetFlags() & IS_NEW ) { m_anchorPos = selection.GetReferencePoint(); - - if( m_frame->GetMoveWarpsCursor() ) - { - getViewControls()->WarpCursor( *m_anchorPos ); - m_cursor = *m_anchorPos; - } } +wxMessageBox( wxString::Format( "Size: %d", selection.Size() ) ); if( m_anchorPos ) { VECTOR2I delta = m_cursor - (*m_anchorPos); @@ -302,16 +301,23 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) m_anchorPos = m_cursor; } - else if( selection.Size() == 1 ) + // For some items, moving the cursor to anchor is not good (for instance large + // hierarchical sheets or components can have the anchor outside the view) + else if( selection.Size() == 1 + && static_cast( selection.Front() )->IsMovableFromAnchorPoint() + && m_frame->GetMoveWarpsCursor() ) { - // Set the current cursor position to the first dragged item origin, - // so the movement vector can be computed later - updateModificationPoint( selection ); - m_cursor = originalCursorPos; + m_anchorPos = static_cast( selection.Front() )->GetPosition(); + getViewControls()->WarpCursor( *m_anchorPos ); + m_cursor = *m_anchorPos; } + // ...otherwise modify items with regard to the grid-snapped cursor position else { - updateModificationPoint( selection ); +wxMessageBox( wxString::Format( "WTF! Size: %d, %s", selection.Size(), +static_cast( selection.Front() )->IsMovableFromAnchorPoint() ? "is movable from anchor" : "NOT MOVABLE FROM ANCHOR" ) ); + m_cursor = getViewControls()->GetCursorPosition( true ); + m_anchorPos = m_cursor; } controls->SetCursorPosition( m_cursor, false ); @@ -642,33 +648,6 @@ void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta, bool isDrag ) } -bool SCH_MOVE_TOOL::updateModificationPoint( EE_SELECTION& aSelection ) -{ - if( m_moveInProgress && aSelection.HasReferencePoint() ) - return false; - - // When there is only one item selected, the reference point is its position... - if( aSelection.Size() == 1 ) - { - SCH_ITEM* item = static_cast( aSelection.Front() ); - - // For some items, moving the cursor to anchor is not good (for instance large - // hierarchical sheets or components can have the anchor outside the view) - if( item->IsMovableFromAnchorPoint() ) - { - m_anchorPos = item->GetPosition(); - return true; - } - } - - // ...otherwise modify items with regard to the grid-snapped cursor position - m_cursor = getViewControls()->GetCursorPosition( true ); - m_anchorPos = m_cursor; - - return true; -} - - void SCH_MOVE_TOOL::setTransitions() { Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::moveActivate.MakeEvent() ); diff --git a/eeschema/tools/sch_move_tool.h b/eeschema/tools/sch_move_tool.h index 7cfc67266e..9b0a8663bc 100644 --- a/eeschema/tools/sch_move_tool.h +++ b/eeschema/tools/sch_move_tool.h @@ -60,10 +60,6 @@ private: ///> moved. void addJunctionsIfNeeded( EE_SELECTION& aSelection ); - ///> Returns the right modification point (e.g. for rotation), depending on the number of - ///> selected items. - bool updateModificationPoint( EE_SELECTION& aSelection ); - ///> Sets up handlers for various events. void setTransitions() override;