29#include <wx/choicdlg.h>
42std::vector<SECTION_ROW> sectionRows()
47 { SECTION::BOM_AVL,
_(
"BOM" ), wxS(
"components PRP, boms/" ), wxS(
"Bom, Avl" ) },
48 { SECTION::PACKAGES,
_(
"packages" ), wxS(
"eda/data PKG" ), wxS(
"Package" ) },
49 { SECTION::COMPONENTS,
_(
"components" ), wxS(
"comp_+_top, comp_+_bot" ), wxS(
"Component" ) },
50 { SECTION::PADSTACKS,
_(
"padstacks" ), wxS(
"features .geometry" ), wxS(
"PadStackDef" ) },
51 { SECTION::STACKUP,
_(
"stackup" ), wxS(
"matrix/stackup.xml" ), wxS(
"Stackup, Spec" ) },
52 { SECTION::PROFILE,
_(
"board profile" ), wxS(
"steps/pcb/profile" ), wxS(
"Profile" ) },
53 { SECTION::SOLDERMASK,
_(
"solder mask" ), wxS(
"SOLDER_MASK" ), wxS(
"SOLDERMASK" ) },
54 { SECTION::SOLDERPASTE,
_(
"solder paste" ), wxS(
"SOLDER_PASTE" ), wxS(
"SOLDERPASTE" ) },
55 { SECTION::SILKSCREEN,
_(
"silkscreen" ), wxS(
"SILK_SCREEN" ), wxS(
"SILKSCREEN" ) },
56 { SECTION::DRILL_ROUT,
_(
"drill and router" ), wxS(
"DRILL, ROUT" ), wxS(
"DRILL, ROUT" ) },
57 { SECTION::DOCUMENTATION,
_(
"documentation" ), wxS(
"DOCUMENT" ), wxS(
"DOCUMENT" ) },
58 { SECTION::OUTER_COPPER,
_(
"outer copper" ), wxS(
"SIGNAL" ), wxS(
"CONDUCTOR, SIGNAL" ) },
59 { SECTION::INNER_COPPER,
_(
"inner copper" ), wxS(
"SIGNAL, POWER_GROUND, MIXED" ),
60 wxS(
"SIGNAL, PLANE, MIXED" ) },
61 { SECTION::DIELECTRIC,
_(
"dielectric" ), wxS(
"DIELECTRIC rows" ), wxS(
"DIELCORE, DIELPREG" ) },
62 { SECTION::MISC_FAB,
_(
"misc fab layers" ), wxS(
"DOCUMENT (MISC)" ), wxS(
"Layer (other functions)" ) },
63 { SECTION::LOGICAL_NET,
_(
"logical netlist" ), wxS(
"eda/data NET" ), wxS(
"LogicalNet" ) },
64 { SECTION::PHYSICAL_NET,
_(
"physical netlist" ), wxS(
"netlists/cadnet" ), wxS(
"PhyNetGroup" ) },
73 const FAB::SECTION_SET& aCurrent,
bool aBoardMetadata ) :
74 DIALOG_FAB_CUSTOMIZE_BASE( aParent ),
75 m_original( aCurrent )
78 m_sections->AppendToggleColumn( wxEmptyString, wxDATAVIEW_CELL_ACTIVATABLE, 36 );
79 m_sections->AppendTextColumn(
_(
"Section" ), wxDATAVIEW_CELL_INERT, 170 );
80 m_sections->AppendTextColumn( odb ?
_(
"ODB++" ) :
_(
"IPC-2581" ), wxDATAVIEW_CELL_INERT, 260 );
83 for(
const SECTION_ROW& row : sectionRows() )
85 m_rows.push_back( row.m_section );
87 m_editable.push_back( ( odb && aMode == FAB::MODE::USERDEF ) || optional.
Contains( row.m_section ) );
88 wxVector<wxVariant> values;
89 values.push_back( wxVariant( aCurrent.
Contains( row.m_section ) ) );
90 values.push_back( wxVariant( row.m_label ) );
91 values.push_back( wxVariant( odb ? row.m_odb : row.m_ipc ) );
92 m_sections->AppendItem( values );
98 _(
"Choose sections to include. Intentional shorts are written when the board has net ties." ) );
99 wxVector<wxVariant> values;
100 values.push_back( wxVariant( aBoardMetadata ) );
101 values.push_back( wxVariant(
_(
"board metadata" ) ) );
102 values.push_back( wxVariant( wxS(
"misc/metadata.xml" ) ) );
103 m_metadataRow = m_sections->GetItemCount();
104 m_sections->AppendItem( values );
105 m_editable.push_back(
true );
108 values.push_back( wxVariant(
true ) );
109 values.push_back( wxVariant(
_(
"intentional shorts" ) ) );
110 values.push_back( wxVariant( wxS(
"eda/shortf" ) ) );
111 m_sections->AppendItem( values );
112 m_editable.push_back(
false );
115 m_sections->Bind( wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &DIALOG_FAB_CUSTOMIZE::onValueChanged,
this );
116 SetupStandardButtons();
117 finishDialogSettings();
120 FAB::SECTION_SET Selected()
const
122 FAB::SECTION_SET selected;
127 m_sections->GetValue( value,
static_cast<unsigned int>(
index ), 0 );
129 if( value.GetBool() )
136 bool BoardMetadata()
const
139 m_sections->GetValue( value, m_metadataRow, 0 );
140 return value.GetBool();
144 void onValueChanged( wxDataViewEvent& aEvent )
149 unsigned int row = m_sections->ItemToRow( aEvent.GetItem() );
151 if( row >= m_editable.size() || m_editable[row] )
155 bool included = row < m_rows.size() && m_original.
Contains( m_rows[row] );
157 if( row >= m_rows.size() )
160 m_sections->SetValue( wxVariant( included ), row, 0 );
164 std::vector<FAB::SECTION> m_rows;
165 std::vector<bool> m_editable;
166 unsigned int m_metadataRow = 0;
167 FAB::SECTION_SET m_original;
168 bool m_restoring =
false;
174 const wxSize& aSize,
long aStyle,
const wxString& aName ) :
190 auto addMode = [&](
FAB::MODE aMode,
const wxString& aLabel )
196 addMode( FAB::MODE::USERDEF,
_(
"All data (user-defined)" ) );
199 addMode( FAB::MODE::BOM,
_(
"Bill of materials" ) );
201 addMode( FAB::MODE::STACKUP,
_(
"Stackup" ) );
202 addMode( FAB::MODE::FABRICATION,
_(
"Fabrication" ) );
203 addMode( FAB::MODE::ASSEMBLY,
_(
"Assembly" ) );
204 addMode( FAB::MODE::TEST,
_(
"Test" ) );
207 addMode( FAB::MODE::STENCIL,
_(
"Stencil" ) );
213 if( current.IsEmpty() )
216 m_choiceVariant->Append( wxString::Format(
_(
"Current (%s)" ), current ) );
246 return selection >= 0 &&
static_cast<size_t>( selection ) <
m_modes.size() ?
m_modes[selection]
247 : FAB::MODE::USERDEF;
303 if( !
m_board || selection <= 0 )
306 const std::vector<wxString>& names =
m_board->GetVariantNames();
308 if(
static_cast<size_t>( selection ) <= names.size() )
309 return { names[selection - 1] };
314 if(
static_cast<size_t>( selection ) == names.size() + 1 )
318 all.insert( all.end(), names.begin(), names.end() );
328 if(
m_board && !aNames.empty() )
330 const std::vector<wxString>& names =
m_board->GetVariantNames();
332 if( aNames.size() == 1 )
334 auto it = std::find( names.begin(), names.end(), aNames.front() );
336 if( it != names.end() )
337 selection =
static_cast<int>( it - names.begin() ) + 1;
341 selection =
static_cast<int>( names.size() ) + 1;
385 wxString summary =
_(
"Includes: " );
386 wxString line = summary;
388 std::vector<wxString> labels;
390 for(
const SECTION_ROW& row : sectionRows() )
392 if( sections.
Contains( row.m_section ) )
393 labels.push_back( row.m_label );
397 labels.push_back(
_(
"board metadata" ) );
399 for(
const wxString& label : labels )
401 wxString item = label;
402 bool first = line ==
_(
"Includes: " );
403 item = first ? item : wxS(
", " ) + item;
405 if( line.length() + item.length() > 70 && !first )
407 summary << wxS(
"\n" );
418 m_lblIncludes->SetMinSize( wxSize( -1, lines * GetCharHeight() + 5 ) );
425 GetParent()->Layout();
437 GetParent()->Layout();
461 const std::vector<wxString>& names =
m_board->GetVariantNames();
462 int selectedIndex =
static_cast<int>( names.size() ) + 1;
466 wxArrayString choices;
469 for(
const wxString&
name : names )
472 wxMultiChoiceDialog dialog(
this,
_(
"Choose the variants to export" ),
_(
"Selected variants" ), choices );
479 if(
index != wxNOT_FOUND )
480 checked.Add(
index );
483 dialog.SetSelections( checked );
485 if( dialog.ShowModal() != wxID_OK )
493 for(
int index : dialog.GetSelections() )
521 if( dialog.ShowModal() != wxID_OK )
Information pertinent to a Pcbnew printed circuit board.
const std::vector< wxString > & GetVariantNames() const
wxString GetCurrentVariant() const
const IPC2581_BOM_FIELDS & GetFields() const
Class DIALOG_FAB_CUSTOMIZE_BASE.
SECTION_SET & Set(SECTION aSection, bool aOn=true)
bool Contains(SECTION aSection) const
NET_NAMES
An anonymous name keeps the connections.
wxStaticText * m_variantHint
wxButton * m_btnBomFields
wxChoice * m_choiceDataSet
PANEL_FAB_EXPORT_CONTENT_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxChoice * m_choiceRefDes
wxChoice * m_choiceVariant
wxStaticText * m_lblIncludes
wxStaticText * m_lblVariant
wxStaticText * m_lblRefDes
wxChoice * m_choiceNetNames
wxRadioBox * m_variantOutput
void onBomFieldsClick(wxCommandEvent &aEvent) override
std::function< void()> m_contentChanged
void onVariantOutputChange(wxCommandEvent &aEvent) override
void SetSectionKey(const std::optional< wxString > &aKey)
void SetRefDes(JOB_EXPORT_PCB_IPC2581::REF_DES aRefDes)
FAB_CONTENT_FORMAT m_format
void onVariantChange(wxCommandEvent &aEvent) override
PANEL_FAB_EXPORT_CONTENT(wxWindow *aParent, wxWindowID aId=wxID_ANY, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxTAB_TRAVERSAL, const wxString &aName=wxEmptyString)
void onDataSetChange(wxCommandEvent &aEvent) override
void SetVariantNames(const std::vector< wxString > &aNames)
void onCustomizeClick(wxCommandEvent &aEvent) override
std::vector< wxString > GetVariantNames() const
void updateSummary()
Set the Includes line and BOM Fields button from the function mode.
std::optional< wxString > m_sectionKey
Set after Customize An empty IPC-2581 key is a true empty selection.
IPC2581_BOM_FIELDS m_bomFields
void SetNetNames(JOB_EXPORT_PCB_FAB::NET_NAMES aNetNames)
JOB_EXPORT_PCB_FAB::NET_NAMES GetNetNames() const
JOB_EXPORT_PCB_IPC2581::REF_DES GetRefDes() const
FAB::MODE GetDataSet() const
void SetDataSet(FAB::MODE aMode)
FAB::SECTION_SET ResolvedSections() const
void SetCombinedVariantOutput(bool aCombined)
void Configure(FAB_CONTENT_FORMAT aFormat, BOARD *aBoard)
void SetBoardMetadata(bool aValue)
std::vector< FAB::MODE > m_modes
void updateVariantOutput()
bool IsCombinedVariantOutput() const
std::vector< wxString > m_selectedVariants
JOB_EXPORT_PCB_FAB::DATA_SET MODE
Columns of Table 4 The job owns the enum so that every layer shares one type.
wxString SectionKeyString(const SECTION_SET &aSet)
Give aSet as a sectionKey attribute value.
SECTION
Schema sections of the IPC-2581C function mode table, Table 4 p 80.
bool SectionSetFromKeyString(const wxString &aKey, SECTION_SET &aResult)
Read a sectionKey attribute value Return false for an unknown character.
SECTION_SET OptionalSections(MODE aMode)
Schema sections that Table 4 marks O for aMode.
SECTION_SET RecommendedOptionalSections(MODE aMode)
Optional schema sections that aMode selects by default.
RESOLVE_RESULT ResolveSections(REVISION aRevision, MODE aMode, const SECTION_SET &aRequested)
Compare aRequested with Table 4 and give the attributes to remove and the conflicts.
wxString OdbSectionKeyForSelection(FAB::MODE aMode, const FAB::SECTION_SET &aSelection)
Use an empty section key when Customize matches the data set default.
FAB::SECTION_SET OdbDefaultSections(FAB::MODE aMode)
Sections a data set exports when no section key is given.
wxString GetDefaultVariantName()