pcbnew: Remove legacy Magnetize() from GAL picker
Magnetic items handled by GRID_HELPER in GAL. Also includes the standard keyboard modifier shift to change magnetic items on/off
This commit is contained in:
parent
416e64a334
commit
1ff9931333
|
@ -255,7 +255,7 @@ VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDrag
|
|||
}
|
||||
|
||||
|
||||
VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, LSET& aLayers )
|
||||
VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers )
|
||||
{
|
||||
double worldScale = m_frame->GetGalCanvas()->GetGAL()->GetWorldScale();
|
||||
int snapRange = (int) ( m_snapSize / worldScale );
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, BOARD_ITEM* aItem );
|
||||
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem );
|
||||
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, LSET& aLayers );
|
||||
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers );
|
||||
|
||||
void SetSnap( bool aSnap )
|
||||
{
|
||||
|
|
|
@ -1061,7 +1061,7 @@ int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
|
||||
picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1, false ) );
|
||||
picker->SetSnapping( false );
|
||||
picker->SetLayerSet( LSET::AllCuMask() );
|
||||
picker->Activate();
|
||||
Wait();
|
||||
|
||||
|
|
|
@ -25,18 +25,11 @@
|
|||
#include "picker_tool.h"
|
||||
#include "pcb_actions.h"
|
||||
#include "grid_helper.h"
|
||||
#include <pcbnew_id.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include "tool_event_utils.h"
|
||||
#include "selection_tool.h"
|
||||
|
||||
|
||||
extern bool Magnetize( PCB_BASE_EDIT_FRAME* frame, int aCurrentTool,
|
||||
wxSize aGridSize, wxPoint on_grid, wxPoint* curpos );
|
||||
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::pickerTool( "pcbnew.Picker", AS_GLOBAL, 0, "", "", NULL, AF_ACTIVATE );
|
||||
|
||||
|
||||
|
@ -51,30 +44,23 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
GRID_HELPER grid( frame() );
|
||||
|
||||
setControls();
|
||||
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
// TODO: magnetic pad & track processing needs to move to VIEW_CONTROLS.
|
||||
wxPoint pos( controls->GetMousePosition().x, controls->GetMousePosition().y );
|
||||
frame()->SetMousePosition( pos );
|
||||
VECTOR2I cursorPos = controls->GetCursorPosition();
|
||||
|
||||
wxRealPoint gridSize = frame()->GetScreen()->GetGridSize();
|
||||
wxSize igridsize;
|
||||
igridsize.x = KiROUND( gridSize.x );
|
||||
igridsize.y = KiROUND( gridSize.y );
|
||||
|
||||
if( Magnetize( frame(), ID_PCB_HIGHLIGHT_BUTT, igridsize, pos, &pos ) )
|
||||
controls->ForceCursorPosition( true, pos );
|
||||
else
|
||||
controls->ForceCursorPosition( false );
|
||||
if( m_cursorSnapping )
|
||||
{
|
||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||
cursorPos = grid.BestSnapAnchor( cursorPos, m_layerMask );
|
||||
}
|
||||
|
||||
if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
bool getNext = false;
|
||||
|
||||
m_picked = VECTOR2D( controls->GetCursorPosition() );
|
||||
m_picked = cursorPos;
|
||||
|
||||
if( m_clickHandler )
|
||||
{
|
||||
|
@ -139,6 +125,7 @@ void PICKER_TOOL::reset()
|
|||
m_cursorVisible = true;
|
||||
m_cursorCapture = false;
|
||||
m_autoPanning = false;
|
||||
m_layerMask = LSET::AllLayersMask();
|
||||
|
||||
m_picked = NULLOPT;
|
||||
m_clickHandler = NULLOPT;
|
||||
|
@ -150,8 +137,10 @@ void PICKER_TOOL::setControls()
|
|||
{
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
|
||||
// Ensure that the view controls do not handle our snapping as we use the GRID_HELPER
|
||||
controls->SetSnapping( false );
|
||||
|
||||
controls->ShowCursor( m_cursorVisible );
|
||||
controls->SetSnapping( m_cursorSnapping );
|
||||
controls->CaptureCursor( m_cursorCapture );
|
||||
controls->SetAutoPan( m_autoPanning );
|
||||
}
|
||||
|
|
|
@ -71,6 +71,12 @@ public:
|
|||
*/
|
||||
inline void SetCursorCapture( bool aEnable ) { m_cursorCapture = aEnable; }
|
||||
|
||||
/**
|
||||
* Function SetLayerSet()
|
||||
* Sets the tool's snap layer set
|
||||
*/
|
||||
inline void SetLayerSet( LSET aLayerSet ) { m_layerMask = aLayerSet; }
|
||||
|
||||
/**
|
||||
* Function SetClickHandler()
|
||||
* Sets a handler for mouse click event. Handler may decide to receive further click by
|
||||
|
@ -102,6 +108,9 @@ private:
|
|||
bool m_cursorCapture;
|
||||
bool m_autoPanning;
|
||||
|
||||
///> The layer set to use for optional snapping
|
||||
LSET m_layerMask;
|
||||
|
||||
///> Optional event handlers.
|
||||
OPT<CLICK_HANDLER> m_clickHandler;
|
||||
OPT<CANCEL_HANDLER> m_cancelHandler;
|
||||
|
|
|
@ -139,7 +139,6 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
|
|||
bool picking = true;
|
||||
|
||||
statusPopup.SetText( _( "Select reference item..." ) );
|
||||
picker->SetSnapping( false );
|
||||
picker->Activate();
|
||||
|
||||
picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool
|
||||
|
|
Loading…
Reference in New Issue