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();
|
double worldScale = m_frame->GetGalCanvas()->GetGAL()->GetWorldScale();
|
||||||
int snapRange = (int) ( m_snapSize / worldScale );
|
int snapRange = (int) ( m_snapSize / worldScale );
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
|
|
||||||
VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, BOARD_ITEM* aItem );
|
VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, BOARD_ITEM* aItem );
|
||||||
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem );
|
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 )
|
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" ) );
|
m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
|
||||||
picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1, false ) );
|
picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1, false ) );
|
||||||
picker->SetSnapping( false );
|
picker->SetLayerSet( LSET::AllCuMask() );
|
||||||
picker->Activate();
|
picker->Activate();
|
||||||
Wait();
|
Wait();
|
||||||
|
|
||||||
|
|
|
@ -25,18 +25,11 @@
|
||||||
#include "picker_tool.h"
|
#include "picker_tool.h"
|
||||||
#include "pcb_actions.h"
|
#include "pcb_actions.h"
|
||||||
#include "grid_helper.h"
|
#include "grid_helper.h"
|
||||||
#include <pcbnew_id.h>
|
|
||||||
#include <pcb_edit_frame.h>
|
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include "tool_event_utils.h"
|
#include "tool_event_utils.h"
|
||||||
#include "selection_tool.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 );
|
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();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
GRID_HELPER grid( frame() );
|
GRID_HELPER grid( frame() );
|
||||||
|
|
||||||
setControls();
|
setControls();
|
||||||
|
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
// TODO: magnetic pad & track processing needs to move to VIEW_CONTROLS.
|
VECTOR2I cursorPos = controls->GetCursorPosition();
|
||||||
wxPoint pos( controls->GetMousePosition().x, controls->GetMousePosition().y );
|
|
||||||
frame()->SetMousePosition( pos );
|
|
||||||
|
|
||||||
wxRealPoint gridSize = frame()->GetScreen()->GetGridSize();
|
if( m_cursorSnapping )
|
||||||
wxSize igridsize;
|
{
|
||||||
igridsize.x = KiROUND( gridSize.x );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
igridsize.y = KiROUND( gridSize.y );
|
cursorPos = grid.BestSnapAnchor( cursorPos, m_layerMask );
|
||||||
|
}
|
||||||
if( Magnetize( frame(), ID_PCB_HIGHLIGHT_BUTT, igridsize, pos, &pos ) )
|
|
||||||
controls->ForceCursorPosition( true, pos );
|
|
||||||
else
|
|
||||||
controls->ForceCursorPosition( false );
|
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
bool getNext = false;
|
bool getNext = false;
|
||||||
|
|
||||||
m_picked = VECTOR2D( controls->GetCursorPosition() );
|
m_picked = cursorPos;
|
||||||
|
|
||||||
if( m_clickHandler )
|
if( m_clickHandler )
|
||||||
{
|
{
|
||||||
|
@ -139,6 +125,7 @@ void PICKER_TOOL::reset()
|
||||||
m_cursorVisible = true;
|
m_cursorVisible = true;
|
||||||
m_cursorCapture = false;
|
m_cursorCapture = false;
|
||||||
m_autoPanning = false;
|
m_autoPanning = false;
|
||||||
|
m_layerMask = LSET::AllLayersMask();
|
||||||
|
|
||||||
m_picked = NULLOPT;
|
m_picked = NULLOPT;
|
||||||
m_clickHandler = NULLOPT;
|
m_clickHandler = NULLOPT;
|
||||||
|
@ -150,8 +137,10 @@ void PICKER_TOOL::setControls()
|
||||||
{
|
{
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
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->ShowCursor( m_cursorVisible );
|
||||||
controls->SetSnapping( m_cursorSnapping );
|
|
||||||
controls->CaptureCursor( m_cursorCapture );
|
controls->CaptureCursor( m_cursorCapture );
|
||||||
controls->SetAutoPan( m_autoPanning );
|
controls->SetAutoPan( m_autoPanning );
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,12 @@ public:
|
||||||
*/
|
*/
|
||||||
inline void SetCursorCapture( bool aEnable ) { m_cursorCapture = aEnable; }
|
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()
|
* Function SetClickHandler()
|
||||||
* Sets a handler for mouse click event. Handler may decide to receive further click by
|
* 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_cursorCapture;
|
||||||
bool m_autoPanning;
|
bool m_autoPanning;
|
||||||
|
|
||||||
|
///> The layer set to use for optional snapping
|
||||||
|
LSET m_layerMask;
|
||||||
|
|
||||||
///> Optional event handlers.
|
///> Optional event handlers.
|
||||||
OPT<CLICK_HANDLER> m_clickHandler;
|
OPT<CLICK_HANDLER> m_clickHandler;
|
||||||
OPT<CANCEL_HANDLER> m_cancelHandler;
|
OPT<CANCEL_HANDLER> m_cancelHandler;
|
||||||
|
|
|
@ -139,7 +139,6 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
|
||||||
bool picking = true;
|
bool picking = true;
|
||||||
|
|
||||||
statusPopup.SetText( _( "Select reference item..." ) );
|
statusPopup.SetText( _( "Select reference item..." ) );
|
||||||
picker->SetSnapping( false );
|
|
||||||
picker->Activate();
|
picker->Activate();
|
||||||
|
|
||||||
picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool
|
picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool
|
||||||
|
|
Loading…
Reference in New Issue