VIEW::ViewGetLOD() returns double now instead of int.

ViewGetLOD() returns the minimal value of a zoom to show an item.
However a zoom is a double, and using int as minimal value does not
allows setting a correct value in some cases.
This commit is contained in:
jean-pierre charras 2020-09-21 17:03:08 +02:00
parent 3eb7dc6eef
commit 456735f803
18 changed files with 50 additions and 49 deletions

View File

@ -951,7 +951,7 @@ const BOX2I GERBER_DRAW_ITEM::ViewBBox() const
}
unsigned int GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
// DCodes will be shown only if zoom is appropriate:
// Returns the level of detail of the item.
@ -977,12 +977,12 @@ unsigned int GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) cons
// the level of details is chosen experimentally, to show
// only a readable text:
const int level = Millimeter2iu( 4 );
return ( level / ( size + 1 ) );
double level = (double)Millimeter2iu( 3 );
return level / ( size + 1 );
}
// Other layers are shown without any conditions
return 0;
return 0.0;
}

View File

@ -292,7 +292,7 @@ public:
virtual const BOX2I ViewBBox() const override;
/// @copydoc VIEW_ITEM::ViewGetLOD()
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
///> @copydoc EDA_ITEM::Visit()
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;

View File

@ -151,7 +151,7 @@ public:
void ViewGetLayers( int aLayers[], int& aCount ) const override;
///> @copydoc VIEW_ITEM::ViewGetLOD
unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
///> @copydoc BOARD_ITEM::Move
void Move( const wxPoint& aMoveVector ) override;

View File

@ -138,10 +138,10 @@ public:
* @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
virtual double ViewGetLOD( int aLayer, VIEW* aView ) const
{
// By default always show the item
return 0;
return 0.0;
}
public:

View File

@ -313,9 +313,9 @@ void EDGE_MODULE::Move( const wxPoint& aMoveVector )
}
unsigned int EDGE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double EDGE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
const int HIDE = std::numeric_limits<unsigned int>::max();
constexpr double HIDE = std::numeric_limits<double>::max();
if( !aView )
return 0;
@ -328,7 +328,7 @@ unsigned int EDGE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
return HIDE;
// Other layers are shown without any conditions
return 0;
return 0.0;
}

View File

@ -148,7 +148,7 @@ public:
EDA_ITEM* Clone() const override;
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }

View File

@ -1088,19 +1088,20 @@ void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
}
unsigned int MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
int layer = ( m_Layer == F_Cu ) ? LAYER_MOD_FR :
( m_Layer == B_Cu ) ? LAYER_MOD_BK : LAYER_ANCHOR;
// Currently this is only pertinent for the anchor layer; everything else is drawn from the
// children.
#define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 0.6
// The "good" value is experimentally chosen.
#define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
if( aView->IsLayerVisible( layer ) )
return MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY;
return std::numeric_limits<unsigned int>::max();
return std::numeric_limits<double>::max();
}

View File

@ -623,7 +623,7 @@ public:
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
virtual const BOX2I ViewBBox() const override;

View File

@ -1171,12 +1171,12 @@ void D_PAD::ViewGetLayers( int aLayers[], int& aCount ) const
}
unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
if( aView->GetPrintMode() > 0 ) // In printing mode the pad is always drawable
return 0;
return 0.0;
const int HIDE = std::numeric_limits<unsigned int>::max();
constexpr double HIDE = std::numeric_limits<double>::max();
BOARD* board = GetBoard();
// Meta control for hiding all pads
@ -1214,7 +1214,7 @@ unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
if( divisor == 0 )
return HIDE;
return ( Millimeter2iu( 5 ) / divisor );
return ( double ) Millimeter2iu( 5 ) / divisor;
}
// Other layers are shown without any conditions

View File

@ -615,7 +615,7 @@ public:
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
virtual const BOX2I ViewBBox() const override;

View File

@ -238,12 +238,12 @@ void PCB_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const
}
unsigned int PCB_GROUP::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double PCB_GROUP::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
if( aView->IsLayerVisible( LAYER_ANCHOR ) )
return 0;
return 0.0;
return std::numeric_limits<unsigned int>::max();
return std::numeric_limits<double>::max();
}

View File

@ -381,12 +381,12 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
}
unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double TEXTE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
const int HIDE = std::numeric_limits<unsigned int>::max();
constexpr double HIDE = (double)std::numeric_limits<double>::max();
if( !aView )
return 0;
return 0.0;
// Hidden text gets put on the LAYER_MOD_TEXT_INVISIBLE for rendering, but
// should only render if its native layer is visible.
@ -415,7 +415,7 @@ unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
return HIDE;
// Other layers are shown without any conditions
return 0;
return 0.0;
}

View File

@ -228,7 +228,7 @@ public:
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
#if defined(DEBUG)
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }

View File

@ -508,9 +508,9 @@ void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
}
unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
const int HIDE = std::numeric_limits<unsigned int>::max();
constexpr double HIDE = std::numeric_limits<double>::max();
if( !aView->IsLayerVisible( LAYER_TRACKS ) )
return HIDE;
@ -518,11 +518,11 @@ unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
// Netnames will be shown only if zoom is appropriate
if( IsNetnameLayer( aLayer ) )
{
return ( Millimeter2iu( 4 ) / ( m_Width + 1 ) );
return ( double ) Millimeter2iu( 4 ) / ( m_Width + 1 );
}
// Other layers are shown without any conditions
return 0;
return 0.0;
}
@ -569,13 +569,13 @@ void VIA::ViewGetLayers( int aLayers[], int& aCount ) const
}
unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
constexpr unsigned int HIDE = std::numeric_limits<unsigned int>::max();
constexpr double HIDE = (double)std::numeric_limits<double>::max();
// Netnames will be shown only if zoom is appropriate
if( IsNetnameLayer( aLayer ) )
return m_Width == 0 ? HIDE : ( Millimeter2iu( 10 ) / m_Width );
return m_Width == 0 ? HIDE : ( (double)Millimeter2iu( 10 ) / m_Width );
bool onVisibleLayer = false;
@ -599,7 +599,7 @@ unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
if( !onVisibleLayer && m_ViaType != VIATYPE::THROUGH )
return HIDE;
return aView->IsLayerVisible( LAYER_VIAS ) ? 0 : HIDE;
return aView->IsLayerVisible( LAYER_VIAS ) ? 0.0 : HIDE;
}
return HIDE;

View File

@ -226,7 +226,7 @@ public:
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
const BOX2I ViewBBox() const override;
@ -438,7 +438,7 @@ public:
void ViewGetLayers( int aLayers[], int& aCount ) const override;
unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;

View File

@ -301,11 +301,11 @@ void ZONE_CONTAINER::ViewGetLayers( int aLayers[], int& aCount ) const
}
unsigned int ZONE_CONTAINER::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double ZONE_CONTAINER::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
constexpr unsigned int HIDE = std::numeric_limits<unsigned int>::max();
constexpr double HIDE = std::numeric_limits<double>::max();
return aView->IsLayerVisible( LAYER_ZONES ) ? 0 : HIDE;
return aView->IsLayerVisible( LAYER_ZONES ) ? 0.0 : HIDE;
}
@ -1298,9 +1298,9 @@ EDA_ITEM* MODULE_ZONE_CONTAINER::Clone() const
}
unsigned int MODULE_ZONE_CONTAINER::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
double MODULE_ZONE_CONTAINER::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
const int HIDE = std::numeric_limits<unsigned int>::max();
constexpr double HIDE = (double)std::numeric_limits<double>::max();
if( !aView )
return 0;
@ -1315,7 +1315,7 @@ unsigned int MODULE_ZONE_CONTAINER::ViewGetLOD( int aLayer, KIGFX::VIEW* aView )
return HIDE;
// Other layers are shown without any conditions
return 0;
return 0.0;
}

View File

@ -150,7 +150,7 @@ public:
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; }
ZONE_FILL_MODE GetFillMode() const { return m_fillMode; }
@ -951,7 +951,7 @@ public:
EDA_ITEM* Clone() const override;
unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
};
#endif // CLASS_ZONE_H_

View File

@ -1152,7 +1152,7 @@ void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
// Keep the size and width constant, not related to the scale because the anchor
// is just a marker on screen
double anchorSize = 5.0 / m_gal->GetWorldScale(); // 5 pixels size
double anchorThickness = 2.0 / m_gal->GetWorldScale(); // 2 pixels width
double anchorThickness = 1.0 / m_gal->GetWorldScale(); // 1 pixels width
// Draw anchor
m_gal->SetIsFill( false );
@ -1164,7 +1164,7 @@ void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
#if 0 // For debug purpose only: draw the bounding box
#if 0 // For debug purpose only: draw the footing bounding box
double bboxThickness = 1.0 / m_gal->GetWorldScale();
m_gal->SetLineWidth( bboxThickness );
EDA_RECT rect = aModule->GetBoundingBoxBase();