Fix broken bool PCB_SHAPE::IsType()

This commit is contained in:
jean-pierre charras 2022-09-12 12:38:24 +02:00
parent 0e0d1a34f5
commit d1af8e7a4b
2 changed files with 33 additions and 25 deletions

View File

@ -53,6 +53,38 @@ PCB_SHAPE::~PCB_SHAPE()
}
bool PCB_SHAPE::IsType( const std::vector<KICAD_T>& aScanTypes ) const
{
if( BOARD_ITEM::IsType( aScanTypes ) )
return true;
bool sametype = false;
for( KICAD_T scanType : aScanTypes )
{
if( scanType == PCB_LOCATE_GRAPHIC_T )
return true;
else if( scanType == PCB_LOCATE_BOARD_EDGE_T )
sametype = m_layer == Edge_Cuts;
else if( scanType == PCB_SHAPE_LOCATE_ARC_T )
sametype = m_shape == SHAPE_T::ARC;
else if( scanType == PCB_SHAPE_LOCATE_CIRCLE_T )
sametype = m_shape == SHAPE_T::CIRCLE;
else if( scanType == PCB_SHAPE_LOCATE_RECT_T )
sametype = m_shape == SHAPE_T::RECT;
else if( scanType == PCB_SHAPE_LOCATE_SEGMENT_T )
sametype = m_shape == SHAPE_T::SEGMENT;
else if( scanType == PCB_SHAPE_LOCATE_POLY_T )
sametype = m_shape == SHAPE_T::POLY;
if( sametype )
return true;
}
return false;
}
const VECTOR2I PCB_SHAPE::GetFocusPosition() const
{
// For some shapes return the visual center, but for not filled polygonal shapes,

View File

@ -57,31 +57,7 @@ public:
return wxT( "PCB_SHAPE" );
}
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
{
if( BOARD_ITEM::IsType( aScanTypes ) )
return true;
for( KICAD_T scanType : aScanTypes )
{
if( scanType == PCB_LOCATE_GRAPHIC_T )
return true;
else if( scanType == PCB_LOCATE_BOARD_EDGE_T )
return m_layer == Edge_Cuts;
else if( scanType == PCB_SHAPE_LOCATE_ARC_T )
return m_shape == SHAPE_T::ARC;
else if( scanType == PCB_SHAPE_LOCATE_CIRCLE_T )
return m_shape == SHAPE_T::CIRCLE;
else if( scanType == PCB_SHAPE_LOCATE_RECT_T )
return m_shape == SHAPE_T::RECT;
else if( scanType == PCB_SHAPE_LOCATE_SEGMENT_T )
return m_shape == SHAPE_T::SEGMENT;
else if( scanType == PCB_SHAPE_LOCATE_POLY_T )
return m_shape == SHAPE_T::POLY;
}
return false;
}
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
VECTOR2I GetPosition() const override { return getPosition(); }