44#include <wx/checklst.h>
45#include <wx/clntdata.h>
49#include <wx/stattext.h>
58 DIALOG_SHIM( aParent, wxID_ANY,
_(
"Match Properties Settings" ), wxDefaultPosition, wxDefaultSize,
59 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
62 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
64 sizer->Add(
new wxStaticText(
this, wxID_ANY,
65 wxString::Format(
_(
"Properties copied from %s:" ),
70 m_properties->SetMinSize( FromDIP( wxSize( 380, 320 ) ) );
72 std::vector<std::pair<wxString, wxString>> rows;
80 std::ranges::sort( rows );
82 for(
const auto& [label, key] : rows )
84 const unsigned int index =
m_properties->Append( label,
new wxStringClientData( key ) );
89 sizer->Add(
m_properties, 1, wxEXPAND | wxLEFT | wxRIGHT, 10 );
90 sizer->Add( CreateStdDialogButtonSizer( wxOK | wxCANCEL ), 0, wxEXPAND | wxALL, 10 );
103 for(
unsigned int ii = 0; ii <
m_properties->GetCount(); ++ii )
105 const wxString key =
keyAt( ii );
117 wxString
keyAt(
unsigned int aIndex )
const
119 auto* data =
static_cast<wxStringClientData*
>(
m_properties->GetClientObject( aIndex ) );
121 return data ? data->GetData() : wxString();
126 for(
unsigned int ii = 0; ii <
m_properties->GetCount(); ++ii )
136 ID_CHECK_ALL = wxID_HIGHEST + 1,
140 menu.Append( ID_CHECK_ALL,
_(
"Check All" ) );
141 menu.Append( ID_UNCHECK_ALL,
_(
"Uncheck All" ) );
143 switch( GetPopupMenuSelectionFromUser( menu ) )
145 case ID_CHECK_ALL:
checkAll(
true );
break;
146 case ID_UNCHECK_ALL:
checkAll(
false );
break;
159 if( aSelection.
Size() != 1 )
195 if( aTargets.empty() )
207 wxCHECK2( target->IsBOARD_ITEM(),
continue );
221 changed +=
result.m_Changed;
224 if( !error.IsEmpty() )
225 frame()->ShowInfoBarError( error );
226 else if( changed == 0 )
227 frame()->ShowInfoBarMsg(
_(
"Nothing to copy. The target already matches the source." ) );
229 if( !error.IsEmpty() || changed == 0 )
235 commit.
Push(
_(
"Match Properties" ) );
248 frame()->ShowInfoBarError(
_(
"Select one item to copy properties from." ) );
256 frame()->ShowInfoBarError(
_(
"The selected source item has no properties to match." ) );
264 frame()->ShowInfoBarMsg(
_(
"No properties are enabled for this kind of item. Press <ctrl>+<,> to "
278 const KIID sourceId = aSourceId;
284 return board->ResolveItem( sourceId,
true );
289 auto enabledCount = [&](
const EDA_ITEM& aItem )
307 statusPopup.
SetText( wxString::Format(
_(
"Click or drag over the items to copy to.\n"
308 "%d properties enabled; <ctrl>+<,> for settings." ),
309 enabledCount( *source ) ) );
324 auto updateHover = [&](
const VECTOR2I& aPointer )
328 hover.ClearBrightening();
336 hover.Brighten( source );
338 if(
BOARD_ITEM* target = hover.Pick( aPointer, accepts( source ) ) )
339 hover.Brighten( target );
346 frame()->PushTool( aEvent );
366 updateHover( aPointer );
369 [&](
const VECTOR2D& aPointer ) ->
bool
375 frame()->ShowInfoBarError(
_(
"The Match Properties source no longer exists." ) );
380 BOARD_ITEM* target = hover.Pick( aPointer, accepts( source ) );
386 hover.ClearBrightening();
388 updateHover( aPointer );
401 std::vector<BOARD_ITEM*> lit{ source };
406 lit.push_back( item );
411 hover.BrightenOnly( lit );
422 std::vector<EDA_ITEM*> candidates( selected.
begin(), selected.
end() );
424 hover.ClearBrightening();
432 hover.ClearBrightening();
437 hover.ClearBrightening();
464 event->SetPassEvent();
468 hover.ClearBrightening();
473 if(
EDA_ITEM* remaining =
board->ResolveItem( sourceId,
true ) )
476 frame()->PopTool( aEvent );
static TOOL_ACTION pickerSubTool
static TOOL_ACTION selectionClear
Clear the current selection.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
DIALOG_SHIM(wxWindow *aParent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, const wxString &name=wxDialogNameStr)
void SetStatusPopup(wxWindow *aPopup)
A base class for most all the KiCad significant classes used in schematics and boards.
The board item under the pointer, and the highlight that follows it.
Represent a selection area (currently a rectangle) in a VIEW, drawn corner-to-corner between two poin...
The properties this kind of source can offer.
bool TransferDataFromWindow() override
std::set< wxString > & m_enabled
void checkAll(bool aChecked)
wxCheckListBox * m_properties
MATCH_PROPERTIES_DIALOG(wxWindow *aParent, std::set< wxString > &aEnabled, const wxString &aFamily)
wxString keyAt(unsigned int aIndex) const
void onContextMenu(wxContextMenuEvent &aEvent)
static TOOL_ACTION matchPropertiesSettings
static TOOL_ACTION matchProperties
std::set< wxString > m_MatchProperties
Keyed as "family/Property Name"; see MATCH_PROPERTIES_CATALOG.
virtual SETTINGS_MANAGER & GetSettingsManager() const
int Size() const
Returns the number of selected parts.
MATCH_PROPERTIES_RESULT Copy(const EDA_ITEM &aSource, EDA_ITEM &aTarget, const std::set< wxString > &aEnabledKeys)
bool Compatible(const EDA_ITEM &aSource, const EDA_ITEM &aTarget)
const std::set< wxString > & AllSafeKeys()
Every property Match Properties may copy, keyed as "family/Property Name".
wxString PropertyLabel(const wxString &aKey)
The translated property name alone, without the family it belongs to.
const std::set< wxString > & DefaultKeys()
The subset enabled until the user says otherwise.
bool AnyEnabledFor(const EDA_ITEM &aItem, const std::set< wxString > &aEnabledKeys)
True if any enabled key names a property of this item's family.
std::vector< EDA_ITEM * > CompatibleTargets(const EDA_ITEM &aSource, const std::vector< EDA_ITEM * > &aCandidates)
wxString FamilyLabel(const wxString &aFamily)
The translated name of a family, for the heading of its group.
std::set< wxString > FamiliesFor(const wxString &aKey)
The families a key reaches. One for a family key, several for a common one.
wxString Family(const EDA_ITEM &aItem)
PGM_BASE & Pgm()
The global program "get" accessor.
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D