28#include <wx/tokenzr.h>
79 bool CanGetValueAs(
int aRow,
int aCol,
const wxString& aTypeName )
override;
80 bool CanSetValueAs(
int aRow,
int aCol,
const wxString& aTypeName )
override;
81 wxGridCellAttr*
GetAttr(
int aRow,
int aCol, wxGridCellAttr::wxAttrKind aKind )
override;
83 wxString
GetValue(
int aRow,
int aCol )
override;
86 void SetValue(
int aRow,
int aCol,
const wxString& aValue )
override;
113 return aTypeName == wxGRID_VALUE_NUMBER;
119 return aTypeName == wxGRID_VALUE_NUMBER;
132 return m_frame->GetBoard()->GetLayerName( this->at( (
size_t) aRow ) );
138 return this->at( (
size_t) aRow );
144 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a string value" ), aCol ) );
150 this->at( (
size_t) aRow ) =
ToLAYER_ID( (
int) aValue );
170 SetEvtHandlerEnabled(
false );
214 [
this]( wxCommandEvent& aEvent )
219 [
this]( wxCommandEvent& aEvent )
224 [
this]( wxCommandEvent& aEvent )
229 [
this]( wxCommandEvent& aEvent )
240 m_itemsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
255 if(
static_cast<int>(
m_page ) >= 0 )
273 "Enter an absolute value (e.g., -0.1mm), a percentage "
274 "(e.g., -5%), or both (e.g., -0.1mm - 5%).\n"
275 "If blank, the global value is used." ) );
297 SetEvtHandlerEnabled(
true );
326 if( !wxDialog::TransferDataToWindow() )
346 (void)
m_3dPanel->TransferDataToWindow();
353 wxCHECK2( field,
continue );
359 wxGridTableMessage tmsg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_fields->GetNumberRows() );
374 wxGridTableMessage gridTableMessagesg(
m_privateLayers, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
415 wxGridTableMessage gridTableMessagesCustom(
m_customUserLayers, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
433 if(
m_footprint->GetLocalSolderMaskMargin().has_value() )
455 if( !
group.IsEmpty() )
468 for(
const wxString& pinNumber :
group.GetNames() )
470 if( !groupTxt.IsEmpty() )
473 groupTxt << pinNumber;
481 for(
int col = 0; col <
m_itemsGrid->GetNumberCols(); col++ )
486 int col_size =
m_itemsGrid->GetVisibleWidth( col );
493 col_size = std::max( col_size, GetTextExtent( board->
GetLayerName( layer ) ).x );
496 col_size +=
KiROUND( 14 * GetDPIScaleFactor() ) + 12;
516 if( aFootprintName.IsEmpty() )
534 if( aFootprintName != originalFPName && adapter->
FootprintExists( libraryName, aFootprintName ) )
536 wxString msg = wxString::Format(
_(
"Footprint '%s' already exists in library '%s'." ),
537 aFootprintName, libraryName );
539 KIDIALOG errorDlg(
m_frame, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
540 errorDlg.SetOKLabel(
_(
"Overwrite" ) );
563 userLayers.
set( layer );
583 if( !DIALOG_SHIM::Validate() )
602 for(
int i = 0; i < (int)
m_fields->size(); ++i )
607 if( field.
GetName(
false ).IsEmpty() )
625 m_frame->StringFromValue( maxSize,
true ) );
637 m_frame->StringFromValue( maxSize,
true ) );
653 "It will be clamped." );
666 if(
m_frame->DeleteFootprintFromLibrary( overwrite,
false ) )
667 m_frame->SyncLibraryTree(
true );
678 if( orphanLayers.any() )
681 wxString::Format(
_(
"You are trying to remove layers that are used by the footprint: %s.\n"
682 "Please remove the objects that use these layers first." ),
714 std::optional<BOARD_COMMIT> commit;
719 bool editingCurrentFootprint = (
m_footprint ==
m_frame->GetBoard()->GetFirstFootprint() );
721 if( editingCurrentFootprint )
723 view =
m_frame->GetCanvas()->GetView();
731 if( !DIALOG_SHIM::TransferDataFromWindow() )
735 std::set<wxString> files;
736 std::set<wxString> files_to_delete;
742 files.insert( field.GetText() );
748 wxCHECK2( field,
continue );
752 if( files.find( field->GetText() ) == files.end() )
753 files_to_delete.insert( field->GetText() );
757 for(
const wxString& file : files_to_delete )
772 if( editingCurrentFootprint )
775 std::vector<PCB_FIELD*> addedFields;
776 std::vector<PCB_FIELD*> detachedFields;
799 if( selectionTool && field->IsSelected() )
803 field->ClearSelected();
811 privateLayers.
set( layer );
820 m_footprint->SetStackupLayers( std::move( customLayers ) );
833 case 1: attributes |=
FP_SMD;
break;
886 if( !
group.IsEmpty() )
892 std::set<wxString> availablePads;
895 availablePads.insert(
pad->GetNumber() );
901 wxStringTokenizer tokenizer(
m_jumperGroupsGrid->GetCellValue( ii, 0 ),
", \t\r\n", wxTOKEN_STRTOK );
902 std::set<wxString> names;
904 while( tokenizer.HasMoreTokens() )
906 wxString token = tokenizer.GetNextToken();
908 if( token.IsEmpty() )
911 if( !availablePads.count( token ) )
914 msg.Printf(
_(
"Pad '%s' in jumper pad group %d does not exist in this footprint." ),
920 names.insert( token );
924 newJumpers.
Add( std::move( *
group ) );
927 m_footprint->JumperPadGroups() = std::move( newJumpers );
930 std::vector<FP_3DMODEL>& panelList =
m_3dPanel->GetModelList();
931 std::vector<FP_3DMODEL>* fpList = &
m_footprint->Models();
933 fpList->insert( fpList->end(), panelList.begin(), panelList.end() );
936 commit->Push(
_(
"Edit Footprint Properties" ) );
945 [&]() -> std::pair<int, int>
964 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
978 if( row < m_fields->GetMandatoryRowCount() )
980 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory." ),
981 m_fields->GetMandatoryRowCount() ) );
999 aLayerTable.erase( aLayerTable.begin() + aRow );
1002 wxGridTableMessage msg( &aLayerTable, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow, 1 );
1003 aGrid.ProcessTableMessage( msg );
1017 aGridTable.push_back( nextLayer );
1020 wxGridTableMessage msg( &aGridTable, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
1021 aGrid.ProcessTableMessage( msg );
1024 return { aGridTable.size() - 1, -1 };
1101 [&]() -> std::pair<int, int>
1103 aGrid->AppendRows( 1 );
1106 return { aGrid->GetNumberRows() - 1, 0 };
1116 aGrid->DeleteRows( row, 1 );
1125 wxGridCellEditor*
editor =
m_itemsGrid->GetCellEditor( aEvent.GetRow(), aEvent.GetCol() );
1126 wxControl* control =
editor->GetControl();
1128 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
1136 else if( aEvent.GetCol() ==
PFC_NAME )
1138 wxString newName = aEvent.GetString();
1140 for(
int row = 0; row <
m_itemsGrid->GetNumberRows(); ++row )
1142 if( row == aEvent.GetRow() )
1174 const int oldPage =
m_NoteBook->ChangeSelection( newPage );
1177 wxBookCtrlEvent changed( wxEVT_NOTEBOOK_PAGE_CHANGED,
m_NoteBook->GetId(), newPage, oldPage );
1179 m_NoteBook->GetEventHandler()->ProcessEvent( changed );
1201 textEntry->SelectAll();
constexpr EDA_IU_SCALE pcbIUScale
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION selectionClear
Clear the current selection.
BASE_SET & set(size_t pos)
Container for design settings for a BOARD object.
int GetTextThickness(PCB_LAYER_ID aLayer) const
Return the default text thickness from the layer class for the given layer.
bool GetTextItalic(PCB_LAYER_ID aLayer) const
VECTOR2I GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
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...
virtual int GetTextHeight() const
virtual int GetTextWidth() const
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Represents an (ordered) list of JUMPER_GROUP objects.
void Add(JUMPER_GROUP aGroup)
Add a JUMPER_GROUP to the set.
Represents a group of jumper pins or pads, keyed by name.
static std::optional< JUMPER_GROUP > Make(std::set< wxString > aNames)
Factory method to create a JUMPER_GROUP from a set of names.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
int GetNumberCols() override
LAYERS_GRID_TABLE(PCB_BASE_FRAME *aFrame, const LSET &aForbiddenLayers)
wxString GetValue(int aRow, int aCol) override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
void SetValueAsLong(int aRow, int aCol, long aValue) override
long GetValueAsLong(int aRow, int aCol) override
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
void SetValue(int aRow, int aCol, const wxString &aValue) override
int GetNumberRows() override
wxGridCellAttr * m_layerColAttr
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
A logical library item identifier and consists of various portions much like a URI.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
bool IsValid() const
Check if this LID_ID is valid.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
static const LSET & AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const LSET & AllLayersMask()
static LSET UserDefinedLayersMask(int aUserDefinedLayerCount=MAX_USER_DEFINED_LAYERS)
Return a mask with the requested number of user defined layers.
static const LSET & InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetTextThickness(int aWidth) override
The TextThickness is that set by the user.
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
int GetTextThickness() const override
VECTOR2I GetTextSize() const override
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
void OnDeleteRows(const std::function< void(int row)> &aDeleter)
Handles a row deletion event.
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
const int minSize
Push and Shove router track width and via size dialog.
Declaration of the eda_3d_viewer class.
#define TEXT_MIN_SIZE_MM
Minimum text size (1 micron).
#define TEXT_MAX_SIZE_MM
Maximum text size in mm (~10 inches)
int ClampTextPenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
static const std::string KiCadUriPrefix
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
wxString AccumulateNames(const LSEQ &aLayers, const BOARD *aBoard)
Accumulate layer names from a layer set into a comma separated string.
LSET GetUsedFootprintLayers(const FOOTPRINT &aFootprint)
Return the layers the footprint's items actually occupy.
int MinimalCopperLayerCount(const LSET &aLayers)
Return the smallest even copper layer count whose stackup contains every copper layer in aLayers.
LSET GetOrphanedFootprintLayers(const FOOTPRINT &aFootprint, const LSET &aCustomUserLayers)
Compute the set of footprint-used layers that would be orphaned if the footprint's allowed layer set ...
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
bool FieldNamesAreDuplicates(const wxString &aLhs, const wxString &aRhs, std::initializer_list< FIELD_T > aMandatoryFields)
Test whether two field names should be treated as duplicates for the purposes of field name uniquenes...
wxString GetUserFieldName(int aFieldNdx, TRANSLATION aTranslation)
@ USER
The field ID hasn't been set yet; field is invalid.
Custom text control validator definitions.
@ THERMAL
Use thermal relief for pads.
@ NONE
Pads are not covered.
@ FULL
pads are covered by copper