Don't add non-groupable items to the group
Things like markers and netinfo should never get added to the group, even if we are inside the group while adding the items Fixes https://gitlab.com/kicad/code/kicad/issues/13026
This commit is contained in:
parent
d232ade752
commit
259e41be2d
|
@ -222,6 +222,13 @@ public:
|
||||||
*/
|
*/
|
||||||
void RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction ) const;
|
void RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the proposed type can be added to a group
|
||||||
|
* @param aType KICAD_T type to check
|
||||||
|
* @return true if the type can belong to a group, false otherwise
|
||||||
|
*/
|
||||||
|
static bool IsGroupableType( KICAD_T aType );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///< @copydoc BOARD_ITEM::swapData
|
///< @copydoc BOARD_ITEM::swapData
|
||||||
void swapData( BOARD_ITEM* aImage ) override;
|
void swapData( BOARD_ITEM* aImage ) override;
|
||||||
|
|
|
@ -246,8 +246,11 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
||||||
{
|
{
|
||||||
case CHT_ADD:
|
case CHT_ADD:
|
||||||
{
|
{
|
||||||
if( selTool && selTool->GetEnteredGroup() && !boardItem->GetParentGroup() )
|
if( selTool && selTool->GetEnteredGroup() && !boardItem->GetParentGroup()
|
||||||
|
&& PCB_GROUP::IsGroupableType( boardItem->Type() ) )
|
||||||
|
{
|
||||||
selTool->GetEnteredGroup()->AddItem( boardItem );
|
selTool->GetEnteredGroup()->AddItem( boardItem );
|
||||||
|
}
|
||||||
|
|
||||||
if( m_isFootprintEditor )
|
if( m_isFootprintEditor )
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,14 +32,55 @@
|
||||||
#include <widgets/msgpanel.h>
|
#include <widgets/msgpanel.h>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
|
|
||||||
|
#include <wx/debug.h>
|
||||||
|
|
||||||
PCB_GROUP::PCB_GROUP( BOARD_ITEM* aParent ) :
|
PCB_GROUP::PCB_GROUP( BOARD_ITEM* aParent ) :
|
||||||
BOARD_ITEM( aParent, PCB_GROUP_T )
|
BOARD_ITEM( aParent, PCB_GROUP_T )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PCB_GROUP::IsGroupableType( KICAD_T aType )
|
||||||
|
{
|
||||||
|
switch ( aType )
|
||||||
|
{
|
||||||
|
case PCB_FOOTPRINT_T:
|
||||||
|
case PCB_PAD_T:
|
||||||
|
case PCB_SHAPE_T:
|
||||||
|
case PCB_BITMAP_T:
|
||||||
|
case PCB_TEXT_T:
|
||||||
|
case PCB_TEXTBOX_T:
|
||||||
|
case PCB_FP_TEXT_T:
|
||||||
|
case PCB_FP_TEXTBOX_T:
|
||||||
|
case PCB_FP_SHAPE_T:
|
||||||
|
case PCB_FP_DIM_ALIGNED_T:
|
||||||
|
case PCB_FP_DIM_LEADER_T:
|
||||||
|
case PCB_FP_DIM_CENTER_T:
|
||||||
|
case PCB_FP_DIM_RADIAL_T:
|
||||||
|
case PCB_FP_DIM_ORTHOGONAL_T:
|
||||||
|
case PCB_FP_ZONE_T:
|
||||||
|
case PCB_TRACE_T:
|
||||||
|
case PCB_VIA_T:
|
||||||
|
case PCB_ARC_T:
|
||||||
|
case PCB_DIMENSION_T:
|
||||||
|
case PCB_DIM_ALIGNED_T:
|
||||||
|
case PCB_DIM_LEADER_T:
|
||||||
|
case PCB_DIM_CENTER_T:
|
||||||
|
case PCB_DIM_RADIAL_T:
|
||||||
|
case PCB_DIM_ORTHOGONAL_T:
|
||||||
|
case PCB_ZONE_T:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PCB_GROUP::AddItem( BOARD_ITEM* aItem )
|
bool PCB_GROUP::AddItem( BOARD_ITEM* aItem )
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( IsGroupableType( aItem->Type() ), false,
|
||||||
|
wxT( "Invalid item type added to group: " ) + aItem->GetTypeDesc() );
|
||||||
|
|
||||||
// Items can only be in one group at a time
|
// Items can only be in one group at a time
|
||||||
if( aItem->GetParentGroup() )
|
if( aItem->GetParentGroup() )
|
||||||
aItem->GetParentGroup()->RemoveItem( aItem );
|
aItem->GetParentGroup()->RemoveItem( aItem );
|
||||||
|
|
Loading…
Reference in New Issue