Highlight selection candidates instead of using BRIGHT_BOX

This commit is contained in:
Jon Evans 2017-09-17 21:54:02 -04:00 committed by Maciej Suminski
parent b90d86aa2d
commit d87c9f7ed7
3 changed files with 28 additions and 17 deletions

View File

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

View File

@ -232,6 +232,10 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
color = m_gerbviewSettings.GetColor( aItem, aLayer ); color = m_gerbviewSettings.GetColor( aItem, aLayer );
// TODO: Should brightened color be a preference?
if( aItem->IsBrightened() )
color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
if( isNegative ) if( isNegative )
{ {
if( m_gerbviewSettings.m_showNegativeItems ) if( m_gerbviewSettings.m_showNegativeItems )

View File

@ -636,8 +636,6 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
BRIGHT_BOX brightBox; BRIGHT_BOX brightBox;
CONTEXT_MENU menu; CONTEXT_MENU menu;
getView()->Add( &brightBox );
int limit = std::min( 10, aCollector->GetCount() ); int limit = std::min( 10, aCollector->GetCount() );
for( int i = 0; i < limit; ++i ) for( int i = 0; i < limit; ++i )
@ -657,7 +655,11 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
if( evt->Action() == TA_CONTEXT_MENU_UPDATE ) if( evt->Action() == TA_CONTEXT_MENU_UPDATE )
{ {
if( current ) if( current )
{
current->ClearBrightened(); current->ClearBrightened();
getView()->Update( current, KIGFX::LAYERS );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
int id = *evt->GetCommandId(); int id = *evt->GetCommandId();
@ -666,6 +668,8 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
{ {
current = ( *aCollector )[id - 1]; current = ( *aCollector )[id - 1];
current->SetBrightened(); current->SetBrightened();
getView()->Update( current, KIGFX::LAYERS );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
} }
else else
{ {
@ -684,19 +688,14 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
break; 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()->Update( current, KIGFX::LAYERS );
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
return current; return current;
} }
@ -762,7 +761,7 @@ void GERBVIEW_SELECTION_TOOL::selectVisually( EDA_ITEM* aItem ) const
{ {
// Move the item's layer to the front // Move the item's layer to the front
int layer = static_cast<GERBER_DRAW_ITEM*>( aItem )->GetLayer(); int layer = static_cast<GERBER_DRAW_ITEM*>( aItem )->GetLayer();
m_frame->GetGalCanvas()->SetTopLayer( GERBER_DRAW_LAYER( layer ) ); m_frame->SetActiveLayer( layer, true );
// Hide the original item, so it is shown only on overlay // Hide the original item, so it is shown only on overlay
aItem->SetSelected(); aItem->SetSelected();