refactoring: implemented SELECTION_TOOL's own GetCollectorsGuide() to avoid dependency on PCB_BASE_FRAME

This commit is contained in:
Tomasz Włostowski 2017-10-31 16:13:41 +01:00
parent c9817df9db
commit 3170eba801
2 changed files with 28 additions and 4 deletions

View File

@ -410,11 +410,29 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
} }
} }
const GENERAL_COLLECTORS_GUIDE SELECTION_TOOL::getCollectorsGuide() const
{
GENERAL_COLLECTORS_GUIDE guide( board()->GetVisibleLayers(),
(PCB_LAYER_ID) view()->GetTopLayer() );
// account for the globals
guide.SetIgnoreMTextsMarkedNoShow( ! board()->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) );
guide.SetIgnoreMTextsOnBack( ! board()->IsElementVisible( LAYER_MOD_TEXT_BK ) );
guide.SetIgnoreMTextsOnFront( ! board()->IsElementVisible( LAYER_MOD_TEXT_FR ) );
guide.SetIgnoreModulesOnBack( ! board()->IsElementVisible( LAYER_MOD_BK ) );
guide.SetIgnoreModulesOnFront( ! board()->IsElementVisible( LAYER_MOD_FR ) );
guide.SetIgnorePadsOnBack( ! board()->IsElementVisible( LAYER_PAD_BK ) );
guide.SetIgnorePadsOnFront( ! board()->IsElementVisible( LAYER_PAD_FR ) );
guide.SetIgnoreModulesVals( ! board()->IsElementVisible( LAYER_MOD_VALUES ) );
guide.SetIgnoreModulesRefs( ! board()->IsElementVisible( LAYER_MOD_REFERENCES ) );
return guide;
}
bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag ) bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag )
{ {
BOARD_ITEM* item; BOARD_ITEM* item;
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide(); auto guide = getCollectorsGuide();
GENERAL_COLLECTOR collector; GENERAL_COLLECTOR collector;
collector.Collect( board(), collector.Collect( board(),
@ -1276,7 +1294,11 @@ void SELECTION_TOOL::clearSelection()
m_selection.SetIsHover( false ); m_selection.SetIsHover( false );
m_selection.ClearReferencePoint(); m_selection.ClearReferencePoint();
if( m_frame )
{
m_frame->SetCurItem( NULL ); m_frame->SetCurItem( NULL );
}
m_locked = true; m_locked = true;
// Inform other potentially interested tools // Inform other potentially interested tools
@ -1742,7 +1764,7 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
// its unique area). // its unique area).
const double commonAreaRatio = 0.6; const double commonAreaRatio = 0.6;
PCB_LAYER_ID actLayer = m_frame->GetActiveLayer(); PCB_LAYER_ID actLayer = (PCB_LAYER_ID) view()->GetTopLayer();
LSET silkLayers( 2, B_SilkS, F_SilkS ); LSET silkLayers( 2, B_SilkS, F_SilkS );

View File

@ -320,6 +320,8 @@ private:
*/ */
int updateSelection( const TOOL_EVENT& aEvent ); int updateSelection( const TOOL_EVENT& aEvent );
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const;
/// Pointer to the parent frame. /// Pointer to the parent frame.
PCB_BASE_FRAME* m_frame; PCB_BASE_FRAME* m_frame;