Fixed alignment to grid when there is a grid offset (GAL).
This commit is contained in:
parent
5ca8e0b9d6
commit
b5ef511063
|
@ -39,6 +39,7 @@
|
|||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/common_actions.h>
|
||||
|
||||
// Max values for grid size
|
||||
#define MAX_GRID_SIZE ( 50.0 * IU_PER_MM )
|
||||
|
@ -282,9 +283,15 @@ bool PCB_BASE_FRAME::InvokeDialogGrid()
|
|||
TOOL_MANAGER* mgr = GetToolManager();
|
||||
|
||||
if( mgr && IsGalCanvasActive() )
|
||||
{
|
||||
mgr->RunAction( "common.Control.gridPreset", true,
|
||||
screen->GetGridCmdId() - ID_POPUP_GRID_LEVEL_1000 );
|
||||
|
||||
TOOL_EVENT gridOriginUpdate = COMMON_ACTIONS::gridSetOrigin.MakeEvent();
|
||||
gridOriginUpdate.SetParameter( new VECTOR2D( grid_origin ) );
|
||||
mgr->ProcessEvent( gridOriginUpdate );
|
||||
}
|
||||
|
||||
m_canvas->Refresh();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -60,10 +60,11 @@ void GRID_HELPER::SetGrid( int aSize )
|
|||
|
||||
void GRID_HELPER::SetOrigin( const VECTOR2I& aOrigin )
|
||||
{
|
||||
assert( false );
|
||||
}
|
||||
|
||||
|
||||
VECTOR2I GRID_HELPER::GetGrid()
|
||||
VECTOR2I GRID_HELPER::GetGrid() const
|
||||
{
|
||||
PCB_SCREEN* screen = m_frame->GetScreen();
|
||||
|
||||
|
@ -73,13 +74,13 @@ VECTOR2I GRID_HELPER::GetGrid()
|
|||
}
|
||||
|
||||
|
||||
VECTOR2I GRID_HELPER::GetOrigin()
|
||||
VECTOR2I GRID_HELPER::GetOrigin() const
|
||||
{
|
||||
return VECTOR2I( 0, 0 );
|
||||
return VECTOR2I( m_frame->GetGridOrigin() );
|
||||
}
|
||||
|
||||
|
||||
void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I aOrigin, bool aEnableDiagonal )
|
||||
void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin, bool aEnableDiagonal )
|
||||
{
|
||||
if( aEnable )
|
||||
m_auxAxis = aOrigin;
|
||||
|
@ -90,7 +91,7 @@ void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I aOrigin, bool aEnable
|
|||
}
|
||||
|
||||
|
||||
VECTOR2I GRID_HELPER::Align( const VECTOR2I& aPoint )
|
||||
VECTOR2I GRID_HELPER::Align( const VECTOR2I& aPoint ) const
|
||||
{
|
||||
const VECTOR2D gridOffset( GetOrigin() );
|
||||
const VECTOR2D gridSize( GetGrid() );
|
||||
|
@ -152,7 +153,7 @@ VECTOR2I GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, BOARD_ITEM* aIt
|
|||
}
|
||||
|
||||
|
||||
std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea )
|
||||
std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea ) const
|
||||
{
|
||||
std::set<BOARD_ITEM*> items;
|
||||
|
||||
|
@ -323,7 +324,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
|||
}
|
||||
|
||||
|
||||
GRID_HELPER::ANCHOR* GRID_HELPER::nearestAnchor( VECTOR2I aPos, int aFlags, LSET aMatchLayers )
|
||||
GRID_HELPER::ANCHOR* GRID_HELPER::nearestAnchor( const VECTOR2I& aPos, int aFlags, LSET aMatchLayers )
|
||||
{
|
||||
double minDist = std::numeric_limits<double>::max();
|
||||
ANCHOR* best = NULL;
|
||||
|
|
|
@ -43,12 +43,12 @@ public:
|
|||
void SetGrid( int aSize );
|
||||
void SetOrigin( const VECTOR2I& aOrigin );
|
||||
|
||||
VECTOR2I GetGrid();
|
||||
VECTOR2I GetOrigin();
|
||||
VECTOR2I GetGrid() const;
|
||||
VECTOR2I GetOrigin() const;
|
||||
|
||||
void SetAuxAxes( bool aEnable, const VECTOR2I aOrigin = VECTOR2I( 0, 0 ), bool aEnableDiagonal = false );
|
||||
void SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin = VECTOR2I( 0, 0 ), bool aEnableDiagonal = false );
|
||||
|
||||
VECTOR2I Align( const VECTOR2I& aPoint );
|
||||
VECTOR2I Align( const VECTOR2I& aPoint ) const;
|
||||
|
||||
VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, BOARD_ITEM* aItem );
|
||||
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem );
|
||||
|
@ -70,24 +70,24 @@ private:
|
|||
int flags;
|
||||
BOARD_ITEM* item;
|
||||
|
||||
double Distance( const VECTOR2I& aP )
|
||||
double Distance( const VECTOR2I& aP ) const
|
||||
{
|
||||
return ( aP - pos ).EuclideanNorm();
|
||||
}
|
||||
|
||||
bool CanSnapItem( const BOARD_ITEM* aItem );
|
||||
//bool CanSnapItem( const BOARD_ITEM* aItem ) const;
|
||||
};
|
||||
|
||||
std::vector<ANCHOR> m_anchors;
|
||||
|
||||
std::set<BOARD_ITEM*> queryVisible( const BOX2I& aArea );
|
||||
std::set<BOARD_ITEM*> queryVisible( const BOX2I& aArea ) const;
|
||||
|
||||
void addAnchor( VECTOR2I aPos, int aFlags = CORNER | SNAPPABLE, BOARD_ITEM* aItem = NULL )
|
||||
void addAnchor( const VECTOR2I& aPos, int aFlags = CORNER | SNAPPABLE, BOARD_ITEM* aItem = NULL )
|
||||
{
|
||||
m_anchors.push_back( ANCHOR( aPos, aFlags, aItem ) );
|
||||
}
|
||||
|
||||
ANCHOR* nearestAnchor( VECTOR2I aPos, int aFlags, LSET aMatchLayers );
|
||||
ANCHOR* nearestAnchor( const VECTOR2I& aPos, int aFlags, LSET aMatchLayers );
|
||||
|
||||
void computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos );
|
||||
|
||||
|
|
|
@ -471,6 +471,15 @@ static bool setOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
|
|||
|
||||
|
||||
int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
|
||||
|
||||
if( origin )
|
||||
{
|
||||
setOrigin( getView(), m_frame, m_gridOrigin, *origin );
|
||||
delete origin;
|
||||
}
|
||||
else
|
||||
{
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
assert( picker );
|
||||
|
@ -479,6 +488,7 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
|||
m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
|
||||
picker->SetClickHandler( boost::bind( setOrigin, getView(), m_frame, m_gridOrigin, _1 ) );
|
||||
picker->Activate();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue