Use VIEW_GROUP for candidate highlighting; enable in PcbNew also

This commit is contained in:
Jon Evans 2017-09-20 15:56:22 -04:00 committed by Maciej Suminski
parent 05a120f09f
commit 256f52f27e
5 changed files with 44 additions and 27 deletions

View File

@ -765,17 +765,10 @@ void GERBER_DRAW_ITEM::Show( int nestLevel, std::ostream& os ) const
void GERBER_DRAW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = IsBrightened() ? 1 : 2;
aCount = 2;
if( IsBrightened() )
{
aLayers[0] = LAYER_GP_OVERLAY;
}
else
{
aLayers[0] = GERBER_DRAW_LAYER( GetLayer() );
aLayers[1] = GERBER_DCODE_LAYER( aLayers[0] );
}
aLayers[0] = GERBER_DRAW_LAYER( GetLayer() );
aLayers[1] = GERBER_DCODE_LAYER( aLayers[0] );
}

View File

@ -633,9 +633,12 @@ void GERBVIEW_SELECTION_TOOL::zoomFitSelection( void )
EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollector )
{
EDA_ITEM* current = NULL;
BRIGHT_BOX brightBox;
KIGFX::VIEW_GROUP highlightGroup;
CONTEXT_MENU menu;
highlightGroup.SetLayer( LAYER_GP_OVERLAY );
getView()->Add( &highlightGroup );
int limit = std::min( 10, aCollector->GetCount() );
for( int i = 0; i < limit; ++i )
@ -657,7 +660,8 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
if( current )
{
current->ClearBrightened();
getView()->Update( current, KIGFX::LAYERS );
getView()->Hide( current, false );
highlightGroup.Remove( current );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
@ -668,7 +672,8 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
{
current = ( *aCollector )[id - 1];
current->SetBrightened();
getView()->Update( current, KIGFX::LAYERS );
getView()->Hide( current, true );
highlightGroup.Add( current );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
else
@ -693,10 +698,13 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
if( current && current->IsBrightened() )
{
current->ClearBrightened();
getView()->Update( current, KIGFX::LAYERS );
getView()->Hide( current, false );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
getView()->Remove( &highlightGroup );
return current;
}

View File

@ -53,6 +53,7 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
m_clearance = CL_NONE;
m_sketchBoardGfx = false;
m_sketchFpGfx = false;
m_selectionCandidateColor = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
// By default everything should be displayed as filled
for( unsigned int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
@ -210,6 +211,12 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
if( item )
{
// Selection disambiguation
if( item->IsBrightened() )
{
return m_selectionCandidateColor;
}
if( item->IsSelected() )
{
return m_layerColorsSel[aLayer];

View File

@ -163,6 +163,9 @@ protected:
///> Clearance visibility settings
int m_clearance;
///> Color used for highlighting selection candidates
COLOR4D m_selectionCandidateColor;
};

View File

@ -1268,10 +1268,11 @@ void SELECTION_TOOL::clearSelection()
BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
{
BOARD_ITEM* current = NULL;
PCB_BRIGHT_BOX brightBox;
KIGFX::VIEW_GROUP highlightGroup;
CONTEXT_MENU menu;
getView()->Add( &brightBox );
highlightGroup.SetLayer( LAYER_GP_OVERLAY );
getView()->Add( &highlightGroup );
int limit = std::min( 9, aCollector->GetCount() );
@ -1294,7 +1295,12 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
if( evt->Action() == TA_CONTEXT_MENU_UPDATE )
{
if( current )
{
current->ClearBrightened();
getView()->Hide( current, false );
highlightGroup.Remove( current );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
int id = *evt->GetCommandId();
@ -1303,6 +1309,9 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
{
current = ( *aCollector )[id - 1];
current->SetBrightened();
getView()->Hide( current, true );
highlightGroup.Add( current );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
else
{
@ -1321,19 +1330,16 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
break;
}
// Draw a mark to show which item is available to be selected
if( current && current->IsBrightened() )
{
brightBox.SetItem( current );
getView()->SetVisible( &brightBox, true );
// getView()->Hide( &brightBox, false );
getView()->Update( &brightBox, KIGFX::GEOMETRY );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
}
getView()->Remove( &brightBox );
if( current && current->IsBrightened() )
{
current->ClearBrightened();
getView()->Hide( current, false );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
getView()->Remove( &highlightGroup );
return current;