ADDED Properties Dialog for groups.

ADDED memberOf() function for DRC rule expressions.

Also fixes a bug in several of the pickers where the event wasn't
being correctly passed.

Fixes https://gitlab.com/kicad/code/kicad/issues/5647
This commit is contained in:
Jeff Young 2020-09-24 02:05:46 +01:00
parent 446a9ca866
commit dba42ebed0
23 changed files with 1277 additions and 66 deletions

View File

@ -43,6 +43,7 @@ class BOARD_ITEM_CONTAINER;
class SHAPE_POLY_SET;
class PCB_BASE_FRAME;
class SHAPE;
class PCB_GROUP;
/**
* Enum STROKE_T
@ -99,26 +100,15 @@ public:
{
}
/**
* Set the group that this item belongs to.
*
* @param aGroup is the group this belongs to
*/
void SetGroup( const KIID& aGroup ) { m_groupUuid = aGroup; }
/**
* Get the group this item belongs to.
*
* @return the group this item is in
*/
const KIID& GetGroup() const { return m_groupUuid; }
void SetGroup( PCB_GROUP* aGroup );
PCB_GROUP* GetGroup() const;
/**
* Test if this item is inside a group.
*
* @return true if inside a group
*/
bool IsInGroup() { return m_groupUuid != niluuid; }
bool IsInGroup() const { return m_groupUuid != niluuid; }
// Do not create a copy constructor & operator=.
// The ones generated by the compiler are adequate.

View File

@ -60,21 +60,19 @@ public:
return aItem && PCB_GROUP_T == aItem->Type();
}
wxString GetName() const
wxString GetClass() const override
{
return m_name;
return wxT( "PCB_GROUP" );
}
wxString GetName() const { return m_name; }
void SetName( wxString aName ) { m_name = aName; }
const BOARD_ITEM_SET& GetItems() const
{
return m_items;
}
void SetName( wxString aName )
{
m_name = aName;
}
/**
* Adds item to group. Does not take ownership of item.
*
@ -89,10 +87,7 @@ public:
*/
bool RemoveItem( BOARD_ITEM* aItem );
wxString GetClass() const override
{
return wxT( "PCB_GROUP" );
}
void RemoveAll();
#if defined( DEBUG )
void Show( int nestLevel, std::ostream& os ) const override
@ -201,11 +196,8 @@ public:
void RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction );
private:
// Members of the group
BOARD_ITEM_SET m_items;
// Optional group name
wxString m_name;
BOARD_ITEM_SET m_items; // Members of the group
wxString m_name; // Optional group name
};
#endif // CLASS_PCB_GROUP_H_

View File

@ -105,6 +105,7 @@ set( PCBNEW_DIALOGS
dialogs/dialog_global_edit_text_and_graphics.cpp
dialogs/dialog_global_edit_text_and_graphics_base.cpp
dialogs/dialog_global_fp_lib_table_config.cpp
dialogs/dialog_group_properties_base.cpp
dialogs/dialog_push_pad_properties.cpp
dialogs/dialog_push_pad_properties_base.cpp
dialogs/dialog_graphic_item_properties.cpp
@ -331,6 +332,7 @@ set( PCBNEW_CLASS_SRCS
tools/drc_tool.cpp
tools/edit_tool.cpp
tools/global_edit_tool.cpp
tools/group_tool.cpp
tools/footprint_editor_tools.cpp
tools/pad_tool.cpp
tools/pcb_bright_box.cpp

View File

@ -59,6 +59,21 @@ BOARD* BOARD_ITEM::GetBoard() const
}
PCB_GROUP* BOARD_ITEM::GetGroup() const
{
if( IsInGroup() && GetBoard() )
return dynamic_cast<PCB_GROUP*>( GetBoard()->GetItem( m_groupUuid ) );
return nullptr;
}
void BOARD_ITEM::SetGroup( PCB_GROUP* aGroup )
{
m_groupUuid = aGroup ? aGroup->m_Uuid : niluuid;
}
wxString BOARD_ITEM::GetLayerName() const
{
BOARD* board = GetBoard();

View File

@ -41,20 +41,17 @@ bool PCB_GROUP::AddItem( BOARD_ITEM* aItem )
return false;
m_items.insert( aItem );
aItem->SetGroup( m_Uuid );
aItem->SetGroup( this );
return true;
}
bool PCB_GROUP::RemoveItem( BOARD_ITEM* aItem )
{
if( !aItem->IsInGroup() )
return false;
// Only clear the item's group field if it was inside this group
if( m_items.erase( aItem ) == 1 )
{
aItem->SetGroup( niluuid );
aItem->SetGroup( nullptr );
return true;
}
@ -62,6 +59,15 @@ bool PCB_GROUP::RemoveItem( BOARD_ITEM* aItem )
}
void PCB_GROUP::RemoveAll()
{
for( BOARD_ITEM* item : m_items )
item->SetGroup( nullptr );
m_items.clear();
}
wxPoint PCB_GROUP::GetPosition() const
{
return GetBoundingBox().Centre();

View File

@ -0,0 +1,96 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_group_properties_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_GROUP_PROPERTIES_BASE::DIALOG_GROUP_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer1->AddGrowableCol( 1 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_nameLabel = new wxStaticText( this, wxID_ANY, _("Group name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_nameLabel->Wrap( -1 );
fgSizer1->Add( m_nameLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_nameCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_nameCtrl, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
bSizerUpper->Add( fgSizer1, 1, wxEXPAND|wxBOTTOM, 5 );
m_membersLabel = new wxStaticText( this, wxID_ANY, _("Group members:"), wxDefaultPosition, wxDefaultSize, 0 );
m_membersLabel->Wrap( -1 );
bSizerUpper->Add( m_membersLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_membersList = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_membersList->SetMinSize( wxSize( 360,200 ) );
bSizerUpper->Add( m_membersList, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bMembershipButtons;
bMembershipButtons = new wxBoxSizer( wxHORIZONTAL );
m_bpAddMember = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bMembershipButtons->Add( m_bpAddMember, 0, wxALL, 5 );
m_bpRemoveMember = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bMembershipButtons->Add( m_bpRemoveMember, 0, wxALL, 5 );
bSizerUpper->Add( bMembershipButtons, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GROUP_PROPERTIES_BASE::onClose ) );
m_membersList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GROUP_PROPERTIES_BASE::OnMemberSelected ), NULL, this );
m_bpAddMember->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GROUP_PROPERTIES_BASE::OnAddMember ), NULL, this );
m_bpRemoveMember->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GROUP_PROPERTIES_BASE::OnRemoveMember ), NULL, this );
}
DIALOG_GROUP_PROPERTIES_BASE::~DIALOG_GROUP_PROPERTIES_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GROUP_PROPERTIES_BASE::onClose ) );
m_membersList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GROUP_PROPERTIES_BASE::OnMemberSelected ), NULL, this );
m_bpAddMember->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GROUP_PROPERTIES_BASE::OnAddMember ), NULL, this );
m_bpRemoveMember->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GROUP_PROPERTIES_BASE::OnRemoveMember ), NULL, this );
}

View File

@ -0,0 +1,577 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_group_properties_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_group_properties</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_GROUP_PROPERTIES_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Group Properties</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnClose">onClose</event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerMain</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerUpper</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer1</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Group name:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_nameLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_nameCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Group members:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_membersLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxListBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">360,200</property>
<property name="moveable">1</property>
<property name="name">m_membersList</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnListBox">OnMemberSelected</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bMembershipButtons</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">MyButton</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_bpAddMember</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnAddMember</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">MyButton</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_bpRemoveMember</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnRemoveMember</event>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticline1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/listbox.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_GROUP_PROPERTIES_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_GROUP_PROPERTIES_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_nameLabel;
wxTextCtrl* m_nameCtrl;
wxStaticText* m_membersLabel;
wxListBox* m_membersList;
wxBitmapButton* m_bpAddMember;
wxBitmapButton* m_bpRemoveMember;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void onClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnMemberSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAddMember( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveMember( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_GROUP_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Group Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_GROUP_PROPERTIES_BASE();
};

View File

@ -79,6 +79,12 @@ A.insideArea('<zone_name>')
A.isPlated()
# True if A is a member of the given group. Includes nested
# membership.
A.memberOf('<group_name>')
# True if A exists on the given layer. The layer name can be
# either the name assigned in Board Setup > Board Editor Layers or
# the canonical name (ie: F.Cu).

View File

@ -161,6 +161,10 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
Edit_Zone_Params( static_cast<ZONE_CONTAINER*>( aItem ) );
break;
case PCB_GROUP_T:
m_toolManager->RunAction( PCB_ACTIONS::groupProperties, true, aItem );
break;
default:
break;
}

View File

@ -63,6 +63,7 @@
#include <tools/pcbnew_picker_tool.h>
#include <tools/point_editor.h>
#include <tools/edit_tool.h>
#include <tools/group_tool.h>
#include <tools/drc_tool.h>
#include <tools/global_edit_tool.h>
#include <tools/convert_tool.h>
@ -512,6 +513,7 @@ void PCB_EDIT_FRAME::setupTools()
m_toolManager->RegisterTool( new DRC_TOOL );
m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
m_toolManager->RegisterTool( new CONVERT_TOOL );
m_toolManager->RegisterTool( new GROUP_TOOL );
m_toolManager->InitTools();
// Run the selection tool, it is supposed to be always active

View File

@ -43,6 +43,7 @@ class VIA;
class D_PAD;
class TEXTE_MODULE;
class PCB_TARGET;
class PCB_GROUP;
class DIMENSION;
class EDGE_MODULE;
class DRC;
@ -816,6 +817,7 @@ public:
// Properties dialogs
void ShowTargetOptionsDialog( PCB_TARGET* aTarget );
void ShowDimensionPropertyDialog( DIMENSION* aDimension );
void ShowGroupPropertiesDialog( PCB_GROUP* aGroup );
void InstallNetlistFrame();
/**

View File

@ -211,6 +211,46 @@ static void insideArea( LIBEVAL::CONTEXT* aCtx, void* self )
}
static void memberOf( LIBEVAL::CONTEXT* aCtx, void* self )
{
LIBEVAL::VALUE* arg = aCtx->Pop();
LIBEVAL::VALUE* result = aCtx->AllocValue();
result->Set( 0.0 );
aCtx->Push( result );
if( !arg )
{
aCtx->ReportError( wxString::Format( _( "Missing argument to '%s'" ),
wxT( "memberOf()" ) ) );
return;
}
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
if( !item )
return;
BOARD* board = item->GetBoard();
PCB_GROUP* group = board->ParentGroup( item );
if( !group && item->GetParent() && item->GetParent()->Type() == PCB_MODULE_T )
group = board->ParentGroup( item->GetParent() );
while( group )
{
if( group->GetName().Matches( arg->AsString() ) )
{
result->Set( 1.0 );
return;
}
group = board->ParentGroup( group );
}
}
static void isMicroVia( LIBEVAL::CONTEXT* aCtx, void* self )
{
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
@ -261,6 +301,7 @@ PCB_EXPR_BUILTIN_FUNCTIONS::PCB_EXPR_BUILTIN_FUNCTIONS()
registerFunc( "isPlated()", isPlated );
registerFunc( "insideCourtyard('x')", insideCourtyard );
registerFunc( "insideArea('x')", insideArea );
registerFunc( "memberOf('x')", memberOf );
registerFunc( "isMicroVia()", isMicroVia );
registerFunc( "isBlindBuriedVia()", isBlindBuriedVia );
}

View File

@ -1197,6 +1197,28 @@ void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
m_gal->DrawLine( pos + wxPoint( bbox.GetWidth(), bbox.GetHeight() ),
pos + wxPoint( 0, bbox.GetHeight() ) );
m_gal->DrawLine( pos + wxPoint( 0, bbox.GetHeight() ), pos );
wxString name = aGroup->GetName();
int ptSize = 12;
int scaledSize = abs( KiROUND( m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
int unscaledSize = Mils2iu( ptSize );
// Scale by zoom a bit, but not too much
int textSize = ( scaledSize + unscaledSize ) / 2;
int penWidth = textSize / 12;
int textOffset = textSize / 2;
if( !name.IsEmpty() && (int) aGroup->GetName().Length() * textSize < bbox.GetWidth() )
{
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM );
m_gal->SetIsFill( false );
m_gal->SetGlyphSize( VECTOR2D( textSize, textSize ) );
m_gal->SetLineWidth( penWidth );
m_gal->StrokeText( aGroup->GetName(), wxPoint( pos.x, pos.y - textOffset ), 0 );
}
}
}

View File

@ -1618,7 +1618,7 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
while( !done )
Wait();
Wait()->SetPassEvent();
// Ensure statusPopup is hidden after use and before deleting it:
m_statusPopup->Hide();

284
pcbnew/tools/group_tool.cpp Normal file
View File

@ -0,0 +1,284 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/selection_tool.h>
#include <tools/group_tool.h>
#include <tools/pcbnew_picker_tool.h>
#include <status_popup.h>
#include <board_commit.h>
#include <bitmaps.h>
#include <dialogs/dialog_group_properties_base.h>
#include "edit_tool.h"
class DIALOG_GROUP_PROPERTIES : public DIALOG_GROUP_PROPERTIES_BASE
{
private:
PCB_EDIT_FRAME* m_brdEditor;
TOOL_MANAGER* m_toolMgr;
PCB_GROUP* m_group;
public:
DIALOG_GROUP_PROPERTIES( PCB_EDIT_FRAME* aParent, PCB_GROUP* aTarget );
~DIALOG_GROUP_PROPERTIES() { }
void OnMemberSelected( wxCommandEvent& event ) override;
void OnAddMember( wxCommandEvent& event ) override;
void OnRemoveMember( wxCommandEvent& event ) override;
void DoAddMember( EDA_ITEM* aItem );
private:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
};
DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES( PCB_EDIT_FRAME* aParent, PCB_GROUP* aGroup ) :
DIALOG_GROUP_PROPERTIES_BASE( aParent ),
m_brdEditor( aParent ),
m_toolMgr( aParent->GetToolManager() ),
m_group( aGroup )
{
m_bpAddMember->SetBitmap( KiBitmap( small_plus_xpm ) );
m_bpRemoveMember->SetBitmap( KiBitmap( trash_xpm ) );
m_nameCtrl->SetValue( m_group->GetName() );
for( BOARD_ITEM* item : m_group->GetItems() )
m_membersList->Append( item->GetSelectMenuText( m_brdEditor->GetUserUnits() ), item );
m_sdbSizerOK->SetDefault();
SetInitialFocus( m_nameCtrl );
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
bool DIALOG_GROUP_PROPERTIES::TransferDataToWindow()
{
// Don't do anything here; it gets called every time we re-show the dialog after
// picking a new member.
return true;
}
bool DIALOG_GROUP_PROPERTIES::TransferDataFromWindow()
{
BOARD_COMMIT commit( m_brdEditor );
commit.Modify( m_group );
m_group->SetName( m_nameCtrl->GetValue() );
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_group->RemoveAll();
for( size_t ii = 0; ii < m_membersList->GetCount(); ++ii )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_membersList->GetClientData( ii ) );
PCB_GROUP* existingGroup = item->GetGroup();
if( existingGroup )
{
commit.Modify( existingGroup );
existingGroup->RemoveItem( item );
}
m_group->AddItem( item );
}
commit.Push( _( "Modified group" ) );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, m_group );
return true;
}
void DIALOG_GROUP_PROPERTIES::OnMemberSelected( wxCommandEvent& aEvent )
{
int selected = m_membersList->GetSelection();
if( selected >= 0 )
{
WINDOW_THAWER thawer( m_brdEditor );
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( m_membersList->GetClientData( selected ) );
m_brdEditor->FocusOnItem( item );
m_brdEditor->GetCanvas()->Refresh();
}
aEvent.Skip();
}
void DIALOG_GROUP_PROPERTIES::OnAddMember( wxCommandEvent& event )
{
m_toolMgr->RunAction( PCB_ACTIONS::pickNewGroupMember, true );
}
void DIALOG_GROUP_PROPERTIES::DoAddMember( EDA_ITEM* aItem )
{
for( size_t ii = 0; ii < m_membersList->GetCount(); ++ii )
{
if( aItem == static_cast<BOARD_ITEM*>( m_membersList->GetClientData( ii ) ) )
return;
}
if( aItem == m_group )
return;
m_membersList->Append( aItem->GetSelectMenuText( m_brdEditor->GetUserUnits() ), aItem );
}
void DIALOG_GROUP_PROPERTIES::OnRemoveMember( wxCommandEvent& event )
{
int selected = m_membersList->GetSelection();
if( selected >= 0 )
m_membersList->Delete( selected );
}
GROUP_TOOL::GROUP_TOOL() :
PCB_TOOL_BASE( "pcbnew.Groups" ),
m_propertiesDialog( nullptr ),
m_selectionTool( nullptr )
{
}
void GROUP_TOOL::Reset( RESET_REASON aReason )
{
if( aReason != RUN )
m_commit = std::make_unique<BOARD_COMMIT>( this );
}
bool GROUP_TOOL::Init()
{
// Find the selection tool, so they can cooperate
m_selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
return m_selectionTool != nullptr;
}
int GROUP_TOOL::GroupProperties( const TOOL_EVENT& aEvent )
{
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
PCB_GROUP* group = aEvent.Parameter<PCB_GROUP*>();
if( m_propertiesDialog )
m_propertiesDialog->Destroy();
m_propertiesDialog = new DIALOG_GROUP_PROPERTIES( editFrame, group );
m_propertiesDialog->Show( true );
return 0;
}
int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent )
{
std::string tool = "pcbnew.EditGroups.selectNewMember";
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
STATUS_TEXT_POPUP statusPopup( frame() );
bool done = false;
if( m_propertiesDialog )
m_propertiesDialog->Show( false );
Activate();
statusPopup.SetText( _( "Click on new member..." ) );
picker->SetClickHandler(
[&]( const VECTOR2D& aPoint ) -> bool
{
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
const PCBNEW_SELECTION& sel = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
} );
if( sel.Empty() )
return true; // still looking for an item
statusPopup.Hide();
if( m_propertiesDialog )
{
m_propertiesDialog->DoAddMember( sel.Front() );
m_propertiesDialog->Show( true );
}
return false; // got our item; don't need any more
} );
picker->SetMotionHandler(
[&] ( const VECTOR2D& aPos )
{
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
} );
picker->SetCancelHandler(
[&]()
{
if( m_propertiesDialog )
m_propertiesDialog->Show( true );
statusPopup.Hide();
} );
picker->SetFinalizeHandler(
[&]( const int& aFinalState )
{
done = true;
} );
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
statusPopup.Popup();
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
while( !done )
Wait()->SetPassEvent();
return 0;
}
void GROUP_TOOL::setTransitions()
{
Go( &GROUP_TOOL::GroupProperties, PCB_ACTIONS::groupProperties.MakeEvent() );
Go( &GROUP_TOOL::PickNewMember, PCB_ACTIONS::pickNewGroupMember.MakeEvent() );
}

68
pcbnew/tools/group_tool.h Normal file
View File

@ -0,0 +1,68 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef GROUP_TOOL_H
#define GROUP_TOOL_H
#include <math/vector2d.h>
#include <tools/pcb_tool_base.h>
#include "selection_tool.h"
#include "dialogs/dialog_group_properties_base.h"
class BOARD_COMMIT;
class BOARD_ITEM;
class SELECTION_TOOL;
class DIALOG_GROUP_PROPERTIES;
class GROUP_TOOL : public PCB_TOOL_BASE
{
public:
GROUP_TOOL();
void Reset( RESET_REASON aReason ) override;
/// @copydoc TOOL_BASE::Init()
bool Init() override;
int GroupProperties( const TOOL_EVENT& aEvent );
/**
* Function SelectNewMember()
*
* Invokes the picker tool to select a new member of the group.
*/
int PickNewMember( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions() override;
private:
DIALOG_GROUP_PROPERTIES* m_propertiesDialog;
///> Selection tool used for obtaining selected items
SELECTION_TOOL* m_selectionTool;
std::unique_ptr<BOARD_COMMIT> m_commit;
};
#endif

View File

@ -1120,6 +1120,16 @@ TOOL_ACTION PCB_ACTIONS::pointEditorRemoveCorner( "pcbnew.PointEditor.removeCorn
_( "Remove Corner" ), _( "Remove corner" ), delete_xpm );
// GROUP_TOOL
//
TOOL_ACTION PCB_ACTIONS::groupProperties( "pcbnew.Groups.groupProperties",
AS_GLOBAL );
TOOL_ACTION PCB_ACTIONS::pickNewGroupMember( "pcbnew.Groups.selectNewGroupMember",
AS_GLOBAL );
// POSITION_RELATIVE_TOOL
//
TOOL_ACTION PCB_ACTIONS::positionRelative( "pcbnew.PositionRelative.positionRelative",

View File

@ -205,7 +205,13 @@ public:
/// Removes a corner
static TOOL_ACTION pointEditorRemoveCorner;
// Placement tool
// Group Tool
static TOOL_ACTION groupProperties;
static TOOL_ACTION pickNewGroupMember;
// Placement Tool
static TOOL_ACTION alignTop;
static TOOL_ACTION alignBottom;
static TOOL_ACTION alignLeft;

View File

@ -851,10 +851,11 @@ int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsN
}
else if( item->Type() == PCB_GROUP_T )
{
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
// If pasting a group, its immediate children must be updated to have its new KIID
static_cast<PCB_GROUP*>( item )->RunOnChildren( [item] ( BOARD_ITEM* aBrdItem )
group->RunOnChildren( [group]( BOARD_ITEM* aBrdItem )
{
aBrdItem->SetGroup( item->m_Uuid );
aBrdItem->SetGroup( group );
} );
}
}

View File

@ -133,7 +133,7 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
Activate();
statusPopup.SetText( _( "Select reference item..." ) );
statusPopup.SetText( _( "Click on reference item..." ) );
picker->SetClickHandler(
[&]( const VECTOR2D& aPoint ) -> bool
@ -184,7 +184,7 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
while( !done )
Wait();
Wait()->SetPassEvent();
return 0;
}

View File

@ -351,7 +351,10 @@ void SELECTION_TOOL::EnterGroup()
ClearSelection();
m_enteredGroup = aGroup;
m_enteredGroup->RunOnChildren( [&]( BOARD_ITEM* titem ) { select( titem ); } );
m_enteredGroup->RunOnChildren( [&]( BOARD_ITEM* titem )
{
select( titem );
} );
}
@ -2004,6 +2007,7 @@ void SELECTION_TOOL::unselect( BOARD_ITEM* aItem )
m_locked = true;
}
void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION* aGroup )
{
highlightInternal( aItem, aMode, aGroup, false );
@ -2016,35 +2020,44 @@ void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION*
getView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
}
void SELECTION_TOOL::highlightInternal( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION* aGroup, bool isChild )
void SELECTION_TOOL::highlightInternal( BOARD_ITEM* aItem, int aMode,
PCBNEW_SELECTION* aSelectionViewGroup, bool isChild )
{
wxLogTrace( "GRP", wxString::Format( "highlight() of %s %p",
aItem->GetSelectMenuText( m_frame->GetUserUnits() ) ), aItem );
wxLogTrace( "GRP", wxString::Format( "highlight() %s",
aItem->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) ) );
if( aMode == SELECTED )
aItem->SetSelected();
else if( aMode == BRIGHTENED )
aItem->SetBrightened();
if( aGroup )
if( aSelectionViewGroup )
{
// Hide the original item, so it is shown only on overlay
view()->Hide( aItem, true );
if( !isChild || aMode == BRIGHTENED )
aGroup->Add( aItem );
aSelectionViewGroup->Add( aItem );
}
// Modules are treated in a special way - when they are highlighted, we have to
// highlight all the parts that make the module, not the module itself
// Modules are treated in a special way - when they are highlighted, we have to highlight
// all the parts that make the module, not the module itself
if( aItem->Type() == PCB_MODULE_T )
{
static_cast<MODULE*>( aItem )->RunOnChildren( [&]( BOARD_ITEM* titem ) {
highlightInternal( titem, aMode, aGroup, true ); } );
static_cast<MODULE*>( aItem )->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
highlightInternal( aChild, aMode, aSelectionViewGroup, true );
} );
}
else if( aItem->Type() == PCB_GROUP_T )
{
static_cast<PCB_GROUP*>( aItem )->RunOnChildren( [&]( BOARD_ITEM* titem ) {
highlightInternal( titem, aMode, aGroup, true ); } );
static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
highlightInternal( aChild, aMode, aSelectionViewGroup, true );
} );
}
}
@ -2062,18 +2075,20 @@ void SELECTION_TOOL::unhighlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION
}
void SELECTION_TOOL::unhighlightInternal( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION* aGroup, bool isChild )
void SELECTION_TOOL::unhighlightInternal( BOARD_ITEM* aItem, int aMode,
PCBNEW_SELECTION* aSelectionViewGroup, bool isChild )
{
wxLogTrace( "GRP", wxString::Format( "unhighlight() of %s %p",
aItem->GetSelectMenuText( m_frame->GetUserUnits() ) ), aItem );
wxLogTrace( "GRP", wxString::Format( "unhighlight() %s",
aItem->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) ) );
if( aMode == SELECTED )
aItem->ClearSelected();
else if( aMode == BRIGHTENED )
aItem->ClearBrightened();
if( aGroup )
if( aSelectionViewGroup )
{
aGroup->Remove( aItem );
aSelectionViewGroup->Remove( aItem );
// Restore original item visibility
view()->Hide( aItem, false );
@ -2088,13 +2103,19 @@ void SELECTION_TOOL::unhighlightInternal( BOARD_ITEM* aItem, int aMode, PCBNEW_S
// highlight all the parts that make the module, not the module itself
if( aItem->Type() == PCB_MODULE_T )
{
static_cast<MODULE*>( aItem )->RunOnChildren( [&]( BOARD_ITEM* titem ) {
unhighlightInternal( titem, aMode, aGroup, true ); } );
static_cast<MODULE*>( aItem )->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
unhighlightInternal( aChild, aMode, aSelectionViewGroup, true );
} );
}
else if( aItem->Type() == PCB_GROUP_T )
{
static_cast<PCB_GROUP*>( aItem )->RunOnChildren( [&]( BOARD_ITEM* titem ) {
unhighlightInternal( titem, aMode, aGroup, true ); } );
static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
unhighlightInternal( aChild, aMode, aSelectionViewGroup, true );
} );
}
}

View File

@ -366,10 +366,10 @@ private:
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const;
private:
void highlightInternal( BOARD_ITEM* aItem, int aHighlightMode, PCBNEW_SELECTION* aGroup,
void highlightInternal( BOARD_ITEM* aItem, int aHighlightMode, PCBNEW_SELECTION* aSelectionViewGroup,
bool isChild);
void unhighlightInternal( BOARD_ITEM* aItem, int aHighlightMode, PCBNEW_SELECTION* aGroup,
void unhighlightInternal( BOARD_ITEM* aItem, int aHighlightMode, PCBNEW_SELECTION* aSelectionViewGroup,
bool isChild);
PCB_BASE_FRAME* m_frame; // Pointer to the parent frame