Don't add non-groupable items to groups
This is a re-implementation of 259e41be
Fixes https://gitlab.com/kicad/code/kicad/issues/13026
This commit is contained in:
parent
42bd43407a
commit
c9cc29593a
|
@ -221,6 +221,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 );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_set<BOARD_ITEM*> m_items; // Members of the group
|
std::unordered_set<BOARD_ITEM*> m_items; // Members of the group
|
||||||
wxString m_name; // Optional group name
|
wxString m_name; // Optional group name
|
||||||
|
|
|
@ -165,8 +165,11 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
||||||
{
|
{
|
||||||
case CHT_ADD:
|
case CHT_ADD:
|
||||||
{
|
{
|
||||||
if( 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 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,14 +30,47 @@
|
||||||
#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_TEXT_T:
|
||||||
|
case PCB_FP_TEXT_T:
|
||||||
|
case PCB_FP_SHAPE_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_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->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
|
||||||
|
|
||||||
// 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