45#include <wx/checklst.h>
46#include <wx/clntdata.h>
50#include <wx/stattext.h>
59 DIALOG_SHIM( aParent, wxID_ANY,
_(
"Match Properties Settings" ), wxDefaultPosition, wxDefaultSize,
60 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
63 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
65 sizer->Add(
new wxStaticText(
this, wxID_ANY,
66 wxString::Format(
_(
"Properties copied from %s:" ),
71 m_properties->SetMinSize( FromDIP( wxSize( 380, 320 ) ) );
73 std::vector<std::pair<wxString, wxString>>
rows;
81 std::ranges::sort(
rows );
83 for(
const auto& [label, key] :
rows )
85 const unsigned int index =
m_properties->Append( label,
new wxStringClientData( key ) );
90 sizer->Add(
m_properties, 1, wxEXPAND | wxLEFT | wxRIGHT, 10 );
91 sizer->Add( CreateStdDialogButtonSizer( wxOK | wxCANCEL ), 0, wxEXPAND | wxALL, 10 );
104 for(
unsigned int ii = 0; ii <
m_properties->GetCount(); ++ii )
106 const wxString key =
keyAt( ii );
118 wxString
keyAt(
unsigned int aIndex )
const
120 auto* data =
static_cast<wxStringClientData*
>(
m_properties->GetClientObject( aIndex ) );
122 return data ? data->GetData() : wxString();
127 for(
unsigned int ii = 0; ii <
m_properties->GetCount(); ++ii )
137 ID_CHECK_ALL = wxID_HIGHEST + 1,
141 menu.Append( ID_CHECK_ALL,
_(
"Check All" ) );
142 menu.Append( ID_UNCHECK_ALL,
_(
"Uncheck All" ) );
144 switch( GetPopupMenuSelectionFromUser( menu ) )
146 case ID_CHECK_ALL:
checkAll(
true );
break;
147 case ID_UNCHECK_ALL:
checkAll(
false );
break;
160 if( aSelection.
Size() != 1 )
196 if( aTargets.empty() )
208 wxCHECK2( target->IsBOARD_ITEM(),
continue );
222 changed +=
result.m_Changed;
234 if( !error.IsEmpty() )
235 frame()->ShowInfoBarError( error );
236 else if( changed == 0 )
237 frame()->ShowInfoBarMsg(
_(
"Nothing to copy. The target already matches the source." ) );
239 if( !error.IsEmpty() || changed == 0 )
245 commit.
Push(
_(
"Match Properties" ) );
258 frame()->ShowInfoBarError(
_(
"Select one item to copy properties from." ) );
266 frame()->ShowInfoBarError(
_(
"The selected source item has no properties to match." ) );
274 frame()->ShowInfoBarMsg(
_(
"No properties are enabled for this kind of item. Press <ctrl>+<,> to "
288 const KIID sourceId = aSourceId;
294 return board->ResolveItem( sourceId,
true );
299 auto enabledCount = [&](
const EDA_ITEM& aItem )
317 statusPopup.
SetText( wxString::Format(
_(
"Click or drag over the items to copy to.\n"
318 "%d properties enabled; <ctrl>+<,> for settings." ),
319 enabledCount( *
source ) ) );
334 auto updateHover = [&](
const VECTOR2I& aPointer )
338 hover.ClearBrightening();
349 hover.Brighten( target );
356 frame()->PushTool( aEvent );
376 updateHover( aPointer );
379 [&](
const VECTOR2D& aPointer ) ->
bool
385 frame()->ShowInfoBarError(
_(
"The Match Properties source no longer exists." ) );
396 hover.ClearBrightening();
398 updateHover( aPointer );
411 std::vector<BOARD_ITEM*> lit{
source };
416 lit.push_back( item );
421 hover.BrightenOnly( lit );
434 hover.ClearBrightening();
442 hover.ClearBrightening();
447 hover.ClearBrightening();
474 event->SetPassEvent();
478 hover.ClearBrightening();
483 if(
EDA_ITEM* remaining =
board->ResolveItem( sourceId,
true ) )
486 frame()->PopTool( aEvent );
static TOOL_ACTION pickerSubTool
static TOOL_ACTION selectionClear
Clear the current selection.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
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
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
void RebuildCells(const BOARD &aBoard, GENERATED_TABLE_REFRESH *aRefresh=nullptr)
Regenerate the cells from the board.
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)
bool IsGeneratedTableCell(const EDA_ITEM *aItem)
True for a cell whose text is generated from the board, so only its formatting is the user's.
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< DATABASE_CONNECTION::ROW > rows
static std::vector< int > candidates(const SEGMENT_INDEX &aIndex, const SEG &aQuery, int aPadding)
wxString result
Test unit parsing edge cases and error handling.
constexpr bool IsGeneratedTableType(const KICAD_T aType)
A PCB_TABLE subclass whose cells are generated from the board rather than typed by the user.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D