GRID_HELPER: Fill out remaining anchor calculations
The computeAnchors function is used to find best drag locations for items being moved. All movable PCB items should be handled. Fixes: lp:1794304 * https://bugs.launchpad.net/kicad/+bug/1794304
This commit is contained in:
parent
853b9d06ad
commit
f8f2af774c
|
@ -28,10 +28,11 @@ using namespace std::placeholders;
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
|
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_module.h>
|
#include <class_dimension.h>
|
||||||
#include <class_edge_mod.h>
|
|
||||||
#include <class_zone.h>
|
|
||||||
#include <class_draw_panel_gal.h>
|
#include <class_draw_panel_gal.h>
|
||||||
|
#include <class_edge_mod.h>
|
||||||
|
#include <class_module.h>
|
||||||
|
#include <class_zone.h>
|
||||||
|
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
|
@ -319,7 +320,6 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
{
|
{
|
||||||
D_PAD* pad = static_cast<D_PAD*>( aItem );
|
D_PAD* pad = static_cast<D_PAD*>( aItem );
|
||||||
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,6 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
DRAWSEGMENT* dseg = static_cast<DRAWSEGMENT*>( aItem );
|
DRAWSEGMENT* dseg = static_cast<DRAWSEGMENT*>( aItem );
|
||||||
VECTOR2I start = dseg->GetStart();
|
VECTOR2I start = dseg->GetStart();
|
||||||
VECTOR2I end = dseg->GetEnd();
|
VECTOR2I end = dseg->GetEnd();
|
||||||
//PCB_LAYER_ID layer = dseg->GetLayer();
|
|
||||||
|
|
||||||
switch( dseg->GetShape() )
|
switch( dseg->GetShape() )
|
||||||
{
|
{
|
||||||
|
@ -346,40 +345,42 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
}
|
}
|
||||||
|
|
||||||
case S_ARC:
|
case S_ARC:
|
||||||
{
|
|
||||||
origin = dseg->GetCenter();
|
origin = dseg->GetCenter();
|
||||||
addAnchor( dseg->GetArcStart(), CORNER | SNAPPABLE, dseg );
|
addAnchor( dseg->GetArcStart(), CORNER | SNAPPABLE, dseg );
|
||||||
addAnchor( dseg->GetArcEnd(), CORNER | SNAPPABLE, dseg );
|
addAnchor( dseg->GetArcEnd(), CORNER | SNAPPABLE, dseg );
|
||||||
addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
|
addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case S_RECT:
|
||||||
|
addAnchor( start, CORNER | SNAPPABLE, dseg );
|
||||||
|
addAnchor( VECTOR2I( end.x, start.y ), CORNER | SNAPPABLE, dseg );
|
||||||
|
addAnchor( VECTOR2I( start.x, end.y ), CORNER | SNAPPABLE, dseg );
|
||||||
|
addAnchor( end, CORNER | SNAPPABLE, dseg );
|
||||||
|
break;
|
||||||
|
|
||||||
case S_SEGMENT:
|
case S_SEGMENT:
|
||||||
{
|
|
||||||
origin.x = start.x + ( start.x - end.x ) / 2;
|
origin.x = start.x + ( start.x - end.x ) / 2;
|
||||||
origin.y = start.y + ( start.y - end.y ) / 2;
|
origin.y = start.y + ( start.y - end.y ) / 2;
|
||||||
addAnchor( start, CORNER | SNAPPABLE, dseg );
|
addAnchor( start, CORNER | SNAPPABLE, dseg );
|
||||||
addAnchor( end, CORNER | SNAPPABLE, dseg );
|
addAnchor( end, CORNER | SNAPPABLE, dseg );
|
||||||
addAnchor( origin, ORIGIN, dseg );
|
addAnchor( origin, ORIGIN, dseg );
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
{
|
|
||||||
for( const auto& p : dseg->BuildPolyPointsList() )
|
for( const auto& p : dseg->BuildPolyPointsList() )
|
||||||
{
|
|
||||||
addAnchor( p, CORNER | SNAPPABLE, dseg );
|
addAnchor( p, CORNER | SNAPPABLE, dseg );
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_CURVE:
|
||||||
|
addAnchor( start, CORNER | SNAPPABLE, dseg );
|
||||||
|
addAnchor( end, CORNER | SNAPPABLE, dseg );
|
||||||
|
//Fallthrough
|
||||||
default:
|
default:
|
||||||
{
|
|
||||||
origin = dseg->GetStart();
|
origin = dseg->GetStart();
|
||||||
addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
|
addAnchor( origin, ORIGIN | SNAPPABLE, dseg );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,8 +397,10 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case PCB_MARKER_T:
|
||||||
|
case PCB_TARGET_T:
|
||||||
case PCB_VIA_T:
|
case PCB_VIA_T:
|
||||||
addAnchor( aItem->GetPosition(), CORNER | SNAPPABLE, aItem );
|
addAnchor( aItem->GetPosition(), ORIGIN | CORNER | SNAPPABLE, aItem );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_ZONE_AREA_T:
|
case PCB_ZONE_AREA_T:
|
||||||
|
@ -418,11 +421,22 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case PCB_DIMENSION_T:
|
||||||
|
{
|
||||||
|
const DIMENSION* dim = static_cast<const DIMENSION*>( aItem );
|
||||||
|
addAnchor( dim->m_featureLineGF, CORNER | SNAPPABLE, aItem );
|
||||||
|
addAnchor( dim->m_featureLineDF, CORNER | SNAPPABLE, aItem );
|
||||||
|
addAnchor( dim->m_featureLineGO, CORNER | SNAPPABLE, aItem );
|
||||||
|
addAnchor( dim->m_featureLineDO, CORNER | SNAPPABLE, aItem );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case PCB_MODULE_TEXT_T:
|
case PCB_MODULE_TEXT_T:
|
||||||
case PCB_TEXT_T:
|
case PCB_TEXT_T:
|
||||||
addAnchor( aItem->GetPosition(), ORIGIN, aItem );
|
addAnchor( aItem->GetPosition(), ORIGIN, aItem );
|
||||||
default:
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,6 +307,8 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||||
KIGFX::VIEW* view = getView();
|
KIGFX::VIEW* view = getView();
|
||||||
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||||
|
|
||||||
|
controls->SetSnapping( false );
|
||||||
|
|
||||||
GRID_HELPER grid( editFrame );
|
GRID_HELPER grid( editFrame );
|
||||||
auto item = selection.Front();
|
auto item = selection.Front();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue