router: When dragging tracks, don't snap to parts of the original line.
Fixes https://gitlab.com/kicad/code/kicad/issues/10113
This commit is contained in:
parent
52edbf91dc
commit
0ff6cb49d6
|
@ -104,6 +104,11 @@ public:
|
|||
*/
|
||||
const ITEM_SET Traces() override;
|
||||
|
||||
virtual PNS::DRAG_MODE Mode() const override
|
||||
{
|
||||
return PNS::DM_COMPONENT;
|
||||
}
|
||||
|
||||
private:
|
||||
struct DRAGGED_CONNECTION
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <memory>
|
||||
#include <math/vector2d.h>
|
||||
|
||||
#include "pns_router.h"
|
||||
#include "pns_algo_base.h"
|
||||
#include "pns_itemset.h"
|
||||
#include "pns_layerset.h"
|
||||
|
@ -115,7 +116,9 @@ public:
|
|||
*/
|
||||
virtual const ITEM_SET Traces() = 0;
|
||||
|
||||
virtual void SetMode( int aDragMode ) {};
|
||||
virtual void SetMode( PNS::DRAG_MODE aDragMode ){};
|
||||
|
||||
virtual PNS::DRAG_MODE Mode() const = 0;
|
||||
|
||||
protected:
|
||||
NODE* m_world;
|
||||
|
|
|
@ -258,9 +258,15 @@ bool DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
|
|||
}
|
||||
|
||||
|
||||
void DRAGGER::SetMode( int aMode )
|
||||
void DRAGGER::SetMode( PNS::DRAG_MODE aMode )
|
||||
{
|
||||
m_mode = aMode;
|
||||
m_mode = static_cast<int>( aMode );
|
||||
}
|
||||
|
||||
|
||||
PNS::DRAG_MODE DRAGGER::Mode() const
|
||||
{
|
||||
return static_cast<PNS::DRAG_MODE>( m_mode );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -100,6 +100,16 @@ public:
|
|||
return m_draggedLine.Layer();
|
||||
}
|
||||
|
||||
const LINE& GetOriginalLine()
|
||||
{
|
||||
return m_draggedLine;
|
||||
}
|
||||
|
||||
const LINE& GetLastDragSolution()
|
||||
{
|
||||
return m_lastDragSolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Traces()
|
||||
*
|
||||
|
@ -107,7 +117,9 @@ public:
|
|||
*/
|
||||
const ITEM_SET Traces() override;
|
||||
|
||||
void SetMode( int aDragMode ) override;
|
||||
void SetMode( PNS::DRAG_MODE aDragMode ) override;
|
||||
|
||||
PNS::DRAG_MODE DRAGGER::Mode() const override;
|
||||
|
||||
private:
|
||||
const ITEM_SET findViaFanoutByHandle ( NODE *aNode, const VIA_HANDLE& handle );
|
||||
|
|
|
@ -185,7 +185,7 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM
|
|||
m_state = DRAG_SEGMENT;
|
||||
}
|
||||
|
||||
m_dragger->SetMode( aDragMode );
|
||||
m_dragger->SetMode( static_cast<PNS::DRAG_MODE>( aDragMode ) );
|
||||
m_dragger->SetWorld( m_world.get() );
|
||||
m_dragger->SetLogger( m_logger );
|
||||
m_dragger->SetDebugDecorator( m_iface->GetDebugDecorator() );
|
||||
|
|
|
@ -33,6 +33,7 @@ using namespace std::placeholders;
|
|||
#include "pns_tool_base.h"
|
||||
#include "pns_arc.h"
|
||||
#include "pns_solid.h"
|
||||
#include "pns_dragger.h"
|
||||
|
||||
|
||||
using namespace KIGFX;
|
||||
|
@ -264,14 +265,18 @@ bool TOOL_BASE::checkSnap( ITEM *aItem )
|
|||
// Sync PNS engine settings with the general PCB editor options.
|
||||
auto& pnss = m_router->Settings();
|
||||
|
||||
// If we're dragging a track segment, don't try to snap to items on the same copper layer with same nets. This is not a perfect heuristic, but seems to work reasonably well :-)
|
||||
// This way we avoid 'flickery' behaviour for short segments when the snap algo is trying to
|
||||
// snap to the corners of the segments next to the one being dragged.
|
||||
// If we're dragging a track segment, don't try to snap to items that are part of the original line.
|
||||
if( m_startItem && aItem && m_router->GetState() == ROUTER::DRAG_SEGMENT
|
||||
&& aItem->Layer() == m_startItem->Layer() && aItem->OfKind( ITEM::SEGMENT_T )
|
||||
&& m_startItem->OfKind( ITEM::SEGMENT_T )
|
||||
&& aItem->Net() == m_startItem->Net() )
|
||||
return false;
|
||||
&& m_router->GetDragger() )
|
||||
{
|
||||
DRAGGER* dragger = dynamic_cast<DRAGGER*>( m_router->GetDragger() );
|
||||
LINKED_ITEM* liItem = dynamic_cast<LINKED_ITEM*>( aItem );
|
||||
|
||||
if( dragger && liItem && dragger->GetOriginalLine().ContainsLink( liItem ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
pnss.SetSnapToPads(
|
||||
frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ||
|
||||
|
|
Loading…
Reference in New Issue