Gerbview: fix an issue in legacy mode (locate items was not working)

This commit is contained in:
jean-pierre charras 2017-10-23 11:32:05 +02:00
parent 9bd5522419
commit cdb577bbbc
4 changed files with 24 additions and 26 deletions

View File

@ -61,13 +61,13 @@ public:
m_DisplayLinesFill = true;
m_DisplayPolygonsFill = true;
m_DisplayPolarCood = false;
m_DisplayDCodes = true;
m_DisplayDCodes = false;
m_IsPrinting = false;
m_DisplayNegativeObjects = false;
m_ForceBlackAndWhite = false;
m_NegativeDrawColor = COLOR4D( DARKGRAY );
m_BgDrawColor = COLOR4D::BLACK;
m_DiffMode = true;
m_DiffMode = false;
m_HighContrastMode = false;
}
};

View File

@ -685,9 +685,6 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) const
// calculate aRefPos in XY gerber axis:
wxPoint ref_pos = GetXYPosition( aRefPos );
// TODO: a better analyze of the shape (perhaps create a D_CODE::HitTest for flashed items)
int radius = std::min( m_Size.x, m_Size.y ) >> 1;
SHAPE_POLY_SET poly;
switch( m_Shape )
@ -695,17 +692,14 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) const
case GBR_POLYGON:
poly = m_Polygon;
return poly.Contains( VECTOR2I( ref_pos ), 0 );
break;
case GBR_SPOT_POLY:
poly = GetDcodeDescr()->m_Polygon;
poly.Move( m_Start );
return poly.Contains( VECTOR2I( ref_pos ), 0 );
break;
case GBR_SPOT_RECT:
return GetBoundingBox().Contains( aRefPos );
break;
case GBR_SPOT_MACRO:
// Aperture macro polygons are already in absolute coordinates
@ -716,9 +710,11 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) const
return true;
}
return false;
break;
}
// TODO: a better analyze of the shape (perhaps create a D_CODE::HitTest for flashed items)
int radius = std::min( m_Size.x, m_Size.y ) >> 1;
if( m_Flashed )
return HitTestPoints( m_Start, ref_pos, radius );
else

View File

@ -47,7 +47,8 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
if( frame )
{
auto displ_opts = (GBR_DISPLAY_OPTIONS*) frame->GetDisplayOptions();
static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( displ_opts );
static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() )
->LoadDisplayOptions( displ_opts );
UseColorScheme( frame->m_colorsSettings );
}
}

View File

@ -44,7 +44,6 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
{
m_messagePanel->EraseMsgBox();
wxPoint ref = aPosition;
bool found = false;
if( aTypeloc == CURSEUR_ON_GRILLE )
ref = GetNearestGridPosition( ref );
@ -52,55 +51,57 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
int layer = GetActiveLayer();
GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
GERBER_DRAW_ITEM* gerb_item = NULL;
GERBER_DRAW_ITEM* gerb_item = nullptr;
// Search first on active layer
// A not used graphic layer can be selected. So gerber can be NULL
if( gerber && IsLayerVisible( layer ) )
if( gerber && gerber->m_IsVisible )
{
for( gerb_item = gerber->GetItemsList(); gerb_item; gerb_item = gerb_item->Next() )
for( auto item = gerber->GetItemsList(); item; item = item->Next() )
{
if( gerb_item->HitTest( ref ) )
if( item->HitTest( ref ) )
{
found = true;
gerb_item = item;
break;
}
}
}
if( !found ) // Search on all layers
if( gerb_item == nullptr ) // Search on all layers
{
for( layer = 0; layer < (int)ImagesMaxCount(); ++layer )
{
gerber = GetGbrImage( layer );
if( gerber == NULL ) // Graphic layer not yet used
if( gerber == nullptr ) // Graphic layer not yet used
continue;
if( !IsLayerVisible( layer ) )
if( !gerber->m_IsVisible )
continue;
for( gerb_item = gerber->GetItemsList(); gerb_item; gerb_item = gerb_item->Next() )
if( layer == GetActiveLayer() )
continue;
for( auto item = gerber->GetItemsList(); item; item = item->Next() )
{
if( gerb_item->HitTest( ref ) )
if( item->HitTest( ref ) )
{
found = true;
gerb_item = item;
break;
}
}
if( found )
if( gerb_item )
break;
}
}
if( found && gerb_item )
if( gerb_item )
{
MSG_PANEL_ITEMS items;
gerb_item->GetMsgPanelInfo( items );
SetMsgPanel( items );
return gerb_item;
}
return NULL;
return gerb_item;
}