router: use SHAPEs and PNS::ITEMs only in the ROUTER_PREVIEW_ITEM

This commit is contained in:
Tomasz Wlostowski 2022-03-08 00:44:31 +01:00
parent b08280d00c
commit a4ad47cd08
3 changed files with 24 additions and 32 deletions

View File

@ -1391,8 +1391,7 @@ void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aClearance, bool
void PNS_KICAD_IFACE::DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor )
{
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( nullptr, m_view );
pitem->Line( aRatline, 10000, aColor );
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aRatline, m_view );
m_previewItems->Add( pitem );
m_view->Update( m_previewItems );
}

View File

@ -62,6 +62,28 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem, KIGFX::VIEW* a
}
ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const SHAPE& aShape, KIGFX::VIEW* aView ) :
EDA_ITEM( NOT_USED )
{
m_view = aView;
m_shape = aShape.Clone();
m_hole = nullptr;
m_clearance = -1;
m_originLayer = m_layer = LAYER_SELECT_OVERLAY ;
m_showClearance = false;
// initialize variables, overwritten by Update( aItem ), if aItem != NULL
m_router = nullptr;
m_type = PR_SHAPE;
m_style = 0;
m_width = 0;
m_depth = 0;
}
ROUTER_PREVIEW_ITEM::~ROUTER_PREVIEW_ITEM()
{
delete m_shape;
@ -442,32 +464,6 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
}
void ROUTER_PREVIEW_ITEM::Line( const SHAPE_LINE_CHAIN& aLine, int aWidth, int aStyle )
{
m_width = aWidth;
if( aStyle >= 0 )
m_color = assignColor( aStyle );
m_type = PR_SHAPE;
m_depth = -1024; // TODO gal->GetMinDepth()
SHAPE_LINE_CHAIN *lc = static_cast<SHAPE_LINE_CHAIN*>( aLine.Clone() );
lc->SetWidth( aWidth );
m_shape = lc;
}
void ROUTER_PREVIEW_ITEM::Point( const VECTOR2I& aPos, int aStyle )
{
}
void ROUTER_PREVIEW_ITEM::Box( const BOX2I& aBox, int aStyle )
{
}
const COLOR4D ROUTER_PREVIEW_ITEM::getLayerColor( int aLayer ) const
{
auto settings = static_cast<PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );

View File

@ -55,15 +55,12 @@ public:
PR_SHAPE
};
ROUTER_PREVIEW_ITEM( const SHAPE& aShape, KIGFX::VIEW* aView = nullptr);
ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem = nullptr, KIGFX::VIEW* aView = nullptr);
~ROUTER_PREVIEW_ITEM();
void Update( const PNS::ITEM* aItem );
void Line( const SHAPE_LINE_CHAIN& aLine, int aWidth = 0, int aStyle = -1 );
void Box( const BOX2I& aBox, int aStyle = 0 );
void Point ( const VECTOR2I& aPos, int aStyle = 0);
void SetColor( const KIGFX::COLOR4D& aColor )
{
m_color = aColor;