refactoring: remove PNS router dependency on PCB_EDIT_FRAME

This commit is contained in:
Tomasz Włostowski 2017-10-31 12:03:58 +01:00
parent d0ef881a53
commit 26f862a9d0
3 changed files with 17 additions and 13 deletions

View File

@ -46,6 +46,7 @@
#include <geometry/shape_convex.h>
#include <geometry/convex_hull.h>
#include "tools/pcb_tool.h"
#include "pns_kicad_iface.h"
#include "pns_routing_settings.h"
@ -470,7 +471,7 @@ PNS_KICAD_IFACE::PNS_KICAD_IFACE()
{
m_ruleResolver = nullptr;
m_board = nullptr;
m_frame = nullptr;
m_tool = nullptr;
m_view = nullptr;
m_previewItems = nullptr;
m_world = nullptr;
@ -989,7 +990,7 @@ void PNS_KICAD_IFACE::Commit()
{
EraseView();
m_commit->Push( wxT( "Added a track" ) );
m_commit.reset( new BOARD_COMMIT( m_frame ) );
m_commit.reset( new BOARD_COMMIT( m_tool ) );
}
@ -1032,10 +1033,13 @@ void PNS_KICAD_IFACE::SetRouter( PNS::ROUTER* aRouter )
}
void PNS_KICAD_IFACE::SetHostFrame( PCB_EDIT_FRAME* aFrame )
void PNS_KICAD_IFACE::SetHostTool( PCB_TOOL* aTool )
{
m_frame = aFrame;
m_commit.reset( new BOARD_COMMIT( m_frame ) );
m_dispOptions = (PCB_DISPLAY_OPTIONS*) m_frame->GetDisplayOptions();
m_tool = aTool;
m_commit.reset( new BOARD_COMMIT( m_tool ) );
}
void PNS_KICAD_IFACE::SetDisplayOptions( PCB_DISPLAY_OPTIONS *aDispOptions )
{
m_dispOptions = aDispOptions;
}

View File

@ -32,6 +32,7 @@ class PNS_PCBNEW_DEBUG_DECORATOR;
class BOARD;
class BOARD_COMMIT;
class PCB_DISPLAY_OPTIONS;
class PCB_TOOL;
namespace KIGFX
{
@ -44,7 +45,8 @@ public:
~PNS_KICAD_IFACE();
void SetRouter( PNS::ROUTER* aRouter ) override;
void SetHostFrame( PCB_EDIT_FRAME* aFrame );
void SetHostTool( PCB_TOOL* aTool );
void SetDisplayOptions( PCB_DISPLAY_OPTIONS* aDispOptions );
void SetBoard( BOARD* aBoard );
void SetView( KIGFX::VIEW* aView );
@ -76,7 +78,7 @@ private:
PNS::NODE* m_world;
PNS::ROUTER* m_router;
BOARD* m_board;
PCB_EDIT_FRAME* m_frame;
PCB_TOOL* m_tool;
std::unique_ptr<BOARD_COMMIT> m_commit;
PCB_DISPLAY_OPTIONS* m_dispOptions;
};

View File

@ -100,7 +100,7 @@ void TOOL_BASE::Reset( RESET_REASON aReason )
m_iface = new PNS_KICAD_IFACE;
m_iface->SetBoard( board() );
m_iface->SetView( getView() );
m_iface->SetHostFrame( frame() );
m_iface->SetHostTool( this );
m_router = new ROUTER;
m_router->SetInterface( m_iface );
@ -156,14 +156,12 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer )
}
ITEM* rv = NULL;
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)frame->GetDisplayOptions();
for( int i = 0; i < 4; i++ )
{
ITEM* item = prioritized[i];
if( displ_opts->m_ContrastModeDisplay )
if( displayOptions()->m_ContrastModeDisplay )
if( item && !item->Layers().Overlaps( tl ) )
item = NULL;