eemodern: clean printf debug gibberish, implement inline drag, move & cursor warp/reference point options
This commit is contained in:
parent
af30eca3cb
commit
bc52f0a03b
|
@ -380,12 +380,15 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
else if( evt->IsDrag( BUT_LEFT ) )
|
else if( evt->IsDrag( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
bool empty = m_selection.Empty();
|
bool empty = m_selection.Empty();
|
||||||
|
|
||||||
|
// selection is empty? try to start dragging the item under the point where drag started
|
||||||
if( empty )
|
if( empty )
|
||||||
{
|
{
|
||||||
m_selection = RequestSelection( movableItems );
|
m_selection = RequestSelection( movableItems );
|
||||||
empty = m_selection.Empty();
|
empty = m_selection.Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// selection STILL empty? attempt a rectangle multi-selection
|
||||||
if( m_additive || m_subtractive || empty || m_frame->GetDragAlwaysSelects() )
|
if( m_additive || m_subtractive || empty || m_frame->GetDragAlwaysSelects() )
|
||||||
{
|
{
|
||||||
selectMultiple();
|
selectMultiple();
|
||||||
|
@ -596,6 +599,13 @@ SELECTION& EE_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] )
|
||||||
clearSelection();
|
clearSelection();
|
||||||
SelectPoint( cursorPos, aFilterList );
|
SelectPoint( cursorPos, aFilterList );
|
||||||
m_selection.SetIsHover( true );
|
m_selection.SetIsHover( true );
|
||||||
|
m_selection.ClearReferencePoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_selection.Size() == 1 )
|
||||||
|
{
|
||||||
|
VECTOR2I refP = ((SCH_ITEM*) m_selection.GetItem( 0 ))->GetPosition();
|
||||||
|
m_selection.SetReferencePoint( refP );
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_selection;
|
return m_selection;
|
||||||
|
|
|
@ -129,6 +129,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
VECTOR2I originalCursorPos = controls->GetCursorPosition();
|
VECTOR2I originalCursorPos = controls->GetCursorPosition();
|
||||||
bool moveMode;
|
bool moveMode;
|
||||||
|
|
||||||
|
m_anchorPoint.reset();
|
||||||
|
|
||||||
// Be sure that there is at least one item that we can move. If there's no selection try
|
// Be sure that there is at least one item that we can move. If there's no selection try
|
||||||
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
|
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
|
||||||
SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
|
SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
|
||||||
|
@ -178,6 +180,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_cursor = controls->GetCursorPosition();
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -280,7 +284,17 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( selection.HasReferencePoint() )
|
if( selection.HasReferencePoint() )
|
||||||
{
|
{
|
||||||
VECTOR2I delta = m_cursor - selection.GetReferencePoint();
|
m_anchorPoint = selection.GetReferencePoint();
|
||||||
|
if( m_frame->GetMoveWarpsCursor() )
|
||||||
|
{
|
||||||
|
getViewControls()->WarpCursor( *m_anchorPoint );
|
||||||
|
m_cursor = *m_anchorPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_anchorPoint )
|
||||||
|
{
|
||||||
|
VECTOR2I delta = m_cursor - (*m_anchorPoint);
|
||||||
|
|
||||||
// Drag items to the current cursor position
|
// Drag items to the current cursor position
|
||||||
for( EDA_ITEM* item : selection )
|
for( EDA_ITEM* item : selection )
|
||||||
|
@ -293,7 +307,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
updateView( item );
|
updateView( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
selection.SetReferencePoint( m_cursor );
|
m_anchorPoint = m_cursor;
|
||||||
}
|
}
|
||||||
else if( selection.Size() == 1 )
|
else if( selection.Size() == 1 )
|
||||||
{
|
{
|
||||||
|
@ -320,7 +334,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
//
|
//
|
||||||
m_cursor = controls->GetCursorPosition();
|
m_cursor = controls->GetCursorPosition();
|
||||||
VECTOR2I delta( m_cursor - prevPos );
|
VECTOR2I delta( m_cursor - prevPos );
|
||||||
selection.SetReferencePoint( m_cursor );
|
m_anchorPoint = m_cursor;
|
||||||
|
|
||||||
m_moveOffset += delta;
|
m_moveOffset += delta;
|
||||||
prevPos = m_cursor;
|
prevPos = m_cursor;
|
||||||
|
@ -422,16 +436,23 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_moveInProgress = false;
|
m_moveInProgress = false;
|
||||||
m_frame->SetNoToolSelected();
|
m_frame->SetNoToolSelected();
|
||||||
|
m_anchorPoint.reset();
|
||||||
selection.ClearReferencePoint();
|
|
||||||
|
|
||||||
for( EDA_ITEM* item : selection )
|
for( EDA_ITEM* item : selection )
|
||||||
item->ClearEditFlags();
|
item->ClearEditFlags();
|
||||||
|
|
||||||
if( restore_state )
|
if( restore_state )
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
|
||||||
m_frame->RollbackSchematicFromUndo();
|
m_frame->RollbackSchematicFromUndo();
|
||||||
|
|
||||||
|
if( unselect )
|
||||||
|
{
|
||||||
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -654,16 +675,14 @@ bool SCH_MOVE_TOOL::updateModificationPoint( SELECTION& aSelection )
|
||||||
// hierarchical sheets or components can have the anchor outside the view)
|
// hierarchical sheets or components can have the anchor outside the view)
|
||||||
if( item->IsMovableFromAnchorPoint() )
|
if( item->IsMovableFromAnchorPoint() )
|
||||||
{
|
{
|
||||||
wxPoint pos = item->GetPosition();
|
m_anchorPoint = item->GetPosition();
|
||||||
aSelection.SetReferencePoint( pos );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...otherwise modify items with regard to the grid-snapped cursor position
|
// ...otherwise modify items with regard to the grid-snapped cursor position
|
||||||
m_cursor = getViewControls()->GetCursorPosition( true );
|
m_cursor = getViewControls()->GetCursorPosition( true );
|
||||||
aSelection.SetReferencePoint( m_cursor );
|
m_anchorPoint = m_cursor;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,8 @@ private:
|
||||||
///> Last cursor position (needed for getModificationPoint() to avoid changes
|
///> Last cursor position (needed for getModificationPoint() to avoid changes
|
||||||
///> of edit reference point).
|
///> of edit reference point).
|
||||||
VECTOR2I m_cursor;
|
VECTOR2I m_cursor;
|
||||||
|
|
||||||
|
boost::optional<VECTOR2I> m_anchorPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //KICAD_SCH_MOVE_TOOL_H
|
#endif //KICAD_SCH_MOVE_TOOL_H
|
||||||
|
|
Loading…
Reference in New Issue