Add comments. Gerbview: in legacy mode, do not display D_Code id text when it is too small to be readable.

This commit is contained in:
jean-pierre charras 2017-11-13 09:11:54 +01:00
parent cabc92bd48
commit e14a1656db
3 changed files with 28 additions and 7 deletions

View File

@ -430,10 +430,18 @@ void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
width /= 2;
}
DrawGraphicText( aPanel->GetClipBox(), aDC, pos, aDrawColor, Line,
orient, wxSize( width, width ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
0, false, false );
// Avoid to draw text, if it is too small (size in pixel < 5 pixels)
// to be readable:
int size_pixel = aDC->LogicalToDeviceXRel( width );
const int threshold = 5;
if( size_pixel >= threshold )
{
DrawGraphicText( aPanel->GetClipBox(), aDC, pos, aDrawColor, Line,
orient, wxSize( width, width ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
0, false, false );
}
}
}
}

View File

@ -281,7 +281,9 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
}
case GBR_SPOT_MACRO:
{
// Update the shape drawings and the bounding box coordiantes:
code->GetMacro()->GetApertureMacroShape( this, m_Start );
// now the bounding box is valid:
bbox = code->GetMacro()->GetBoundingBox();
break;
}
@ -781,7 +783,10 @@ const BOX2I GERBER_DRAW_ITEM::ViewBBox() const
unsigned int GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
// DCodes will be shown only if zoom is appropriate
// DCodes will be shown only if zoom is appropriate:
// Returns the level of detail of the item.
// A level of detail (LOD) is the minimal VIEW scale that
// is sufficient for an item to be shown on a given layer.
if( IsDCodeLayer( aLayer ) )
{
int size = 0;
@ -800,7 +805,10 @@ unsigned int GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) cons
size = m_Size.x;
}
return ( 100000000 / ( size + 1 ) );
// the level of details is chosen experimentally, to show
// only a readable text:
const int level = Millimeter2iu( 1000 );
return ( level / ( size + 1 ) );
}
// Other layers are shown without any conditions

View File

@ -128,8 +128,13 @@ public:
/**
* Function ViewGetLOD()
* Returns the level of detail of the item. A level of detail is the minimal VIEW scale that
* Returns the level of detail (LOD) of the item.
* A level of detail is the minimal VIEW scale that
* is sufficient for an item to be shown on a given layer.
* @param aLayer: current drawing layer
* @param aView: pointer to the VIEW device we are drawing on
* @return the level of detail. 0 always show the item, because the
* actual zoom level (or VIEW scale) is always > 0
*/
virtual unsigned int ViewGetLOD( int aLayer, VIEW* aView ) const
{