Read/write group locked state. Show locked state in dialog & statusbar.

Fixes https://gitlab.com/kicad/code/kicad/issues/8796
This commit is contained in:
Jeff Young 2021-07-22 12:45:33 +01:00
parent 49e1b5785f
commit a16b85db67
11 changed files with 104 additions and 20 deletions

View File

@ -244,10 +244,7 @@ public:
/**
* @return true if the object is locked, else false.
*/
virtual bool IsLocked() const
{
return GetState( LOCKED );
}
virtual bool IsLocked() const;
/**
* Modify the 'lock' status for of the item.

View File

@ -28,6 +28,7 @@
#include <wx/debug.h>
#include <i18n_utility.h>
#include <board.h>
#include <pcb_group.h>
#include <string>
#include <wx/msgdlg.h>
@ -61,6 +62,15 @@ BOARD* BOARD_ITEM::GetBoard() const
}
bool BOARD_ITEM::IsLocked() const
{
if( GetParentGroup() )
return GetParentGroup()->IsLocked();
return GetState( LOCKED );
}
wxString BOARD_ITEM::GetLayerName() const
{
BOARD* board = GetBoard();

View File

@ -43,6 +43,7 @@ DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
m_bpRemoveMember->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
m_nameCtrl->SetValue( m_group->GetName() );
m_locked->SetValue( m_group->IsLocked() );
for( BOARD_ITEM* item : m_group->GetItems() )
m_membersList->Append( item->GetSelectMenuText( m_brdEditor->GetUserUnits() ), item );
@ -100,6 +101,7 @@ bool DIALOG_GROUP_PROPERTIES::TransferDataFromWindow()
}
m_group->SetName( m_nameCtrl->GetValue() );
m_group->SetLocked( m_locked->GetValue() );
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_group->RemoveAll();

View File

@ -33,7 +33,12 @@ DIALOG_GROUP_PROPERTIES_BASE::DIALOG_GROUP_PROPERTIES_BASE( wxWindow* parent, wx
fgSizer1->Add( m_nameCtrl, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
bSizerUpper->Add( fgSizer1, 0, wxEXPAND|wxBOTTOM, 5 );
bSizerUpper->Add( fgSizer1, 0, wxEXPAND, 5 );
m_locked = new wxCheckBox( this, wxID_ANY, _("Locked"), wxDefaultPosition, wxDefaultSize, 0 );
m_locked->SetToolTip( _("Prevents group from being moved on canvas") );
bSizerUpper->Add( m_locked, 0, wxALL, 5 );
m_membersLabel = new wxStaticText( this, wxID_ANY, _("Group members:"), wxDefaultPosition, wxDefaultSize, 0 );
m_membersLabel->Wrap( -1 );

View File

@ -70,7 +70,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
@ -211,6 +211,70 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" 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="checked">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">Locked</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_locked</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">Prevents group from being moved on canvas</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>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>

View File

@ -19,6 +19,7 @@
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/listbox.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
@ -41,6 +42,7 @@ class DIALOG_GROUP_PROPERTIES_BASE : public DIALOG_SHIM
protected:
wxStaticText* m_nameLabel;
wxTextCtrl* m_nameCtrl;
wxCheckBox* m_locked;
wxStaticText* m_membersLabel;
wxListBox* m_membersList;
wxBitmapButton* m_bpAddMember;

View File

@ -321,6 +321,9 @@ void PCB_GROUP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
{
aList.emplace_back( _( "Group" ), m_name.empty() ? _( "<unnamed>" ) : m_name );
aList.emplace_back( _( "Members" ), wxString::Format( "%zu", m_items.size() ) );
if( IsLocked() )
aList.emplace_back( _( "Status" ), _( "Locked" ) );
}

View File

@ -1728,8 +1728,9 @@ void PCB_IO::format( const PCB_GROUP* aGroup, int aNestLevel ) const
if( aGroup->GetItems().empty() )
return;
m_out->Print( aNestLevel, "(group %s (id %s)\n",
m_out->Print( aNestLevel, "(group %s%s (id %s)\n",
m_out->Quotew( aGroup->GetName() ).c_str(),
aGroup->IsLocked() ? " locked" : "",
TO_UTF8( aGroup->m_Uuid.AsString() ) );
m_out->Print( aNestLevel + 1, "(members\n" );

View File

@ -98,7 +98,8 @@ class PCB_TEXT;
//#define SEXPR_BOARD_FILE_VERSION 20210228 // Move global margins back to board file
//#define SEXPR_BOARD_FILE_VERSION 20210424 // Correct locked flag syntax (remove parens).
//#define SEXPR_BOARD_FILE_VERSION 20210606 // Change overbar syntax from `~...~` to `~{...}`.
#define SEXPR_BOARD_FILE_VERSION 20210623 // Add support for reading/writing arcs in polygons
//#define SEXPR_BOARD_FILE_VERSION 20210623 // Add support for reading/writing arcs in polygons
#define SEXPR_BOARD_FILE_VERSION 20210722 // Reading/writing group locked flags
#define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag

View File

@ -964,6 +964,9 @@ void PCB_PARSER::resolveGroups( BOARD_ITEM* aParent )
group->SetName( aGrp.name );
const_cast<KIID&>( group->m_Uuid ) = aGrp.uuid;
if( aGrp.locked )
group->SetLocked( true );
if( aGrp.parent->Type() == PCB_FOOTPRINT_T )
static_cast<FOOTPRINT*>( aGrp.parent )->Add( group );
else
@ -4472,23 +4475,20 @@ void PCB_PARSER::parseGROUP( BOARD_ITEM* aParent )
token = NextTok();
if( token != T_LEFT )
while( ( token = NextTok() ) != T_LEFT )
{
// Optional group name present.
if( !IsSymbol( token ) )
Expecting( DSN_SYMBOL );
if( token == T_STRING )
groupInfo.name = FromUTF8();
else if( token == T_locked )
groupInfo.locked = true;
else
Expecting( "group name or locked" );
}
NeedLEFT();
token = NextTok();
if( token != T_id )
{
Expecting( T_id );
}
NextTok();
groupInfo.uuid = CurStrToKIID();
@ -4498,9 +4498,7 @@ void PCB_PARSER::parseGROUP( BOARD_ITEM* aParent )
token = NextTok();
if( token != T_members )
{
Expecting( T_members );
}
while( ( token = NextTok() ) != T_RIGHT )
{

View File

@ -381,6 +381,7 @@ private:
{
BOARD_ITEM* parent;
wxString name;
bool locked;
KIID uuid;
std::vector<KIID> memberUuids;
};