35#include <wx/filedlg.h>
36#include <wx/filename.h>
65 default:
return false;
103wxArrayString alignChoices()
105 wxArrayString choices;
106 choices.Add(
_(
"Left" ) );
107 choices.Add(
_(
"Center" ) );
108 choices.Add(
_(
"Right" ) );
134 m_columnGrid->SetColLabelValue( COL_HEADING,
_(
"Heading" ) );
136 m_columnGrid->SetColLabelValue( COL_GROUP_BY,
_(
"Group By" ) );
138 m_columnGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
159 const wxArrayString aligns = alignChoices();
161 for(
size_t row = 0; row <
m_columns.size(); ++row )
163 const int r =
static_cast<int>( row );
165 m_columnGrid->SetCellRenderer( r, COL_SHOW,
new wxGridCellBoolRenderer );
166 m_columnGrid->SetCellEditor( r, COL_SHOW,
new wxGridCellBoolEditor );
174 m_columnGrid->SetCellEditor( r, COL_ALIGN,
new wxGridCellChoiceEditor( aligns ) );
176 aligns[
static_cast<int>(
m_columns[row].m_Align )] );
180 if( columnGroupKey(
m_columns[row].m_Id, key ) )
182 m_columnGrid->SetCellRenderer( r, COL_GROUP_BY,
new wxGridCellBoolRenderer );
183 m_columnGrid->SetCellEditor( r, COL_GROUP_BY,
new wxGridCellBoolEditor );
185 m_profile.IsGroupedBy( key ) ? wxT(
"1" )
205 const wxArrayString aligns = alignChoices();
207 for(
size_t row = 0; row <
m_columns.size(); ++row )
209 const int r =
static_cast<int>( row );
214 const int align = aligns.Index(
m_columnGrid->GetCellValue( r, COL_ALIGN ) );
216 if( align != wxNOT_FOUND )
221 if( columnGroupKey(
m_columns[row].m_Id, key ) )
224 !
m_columnGrid->GetCellValue( r, COL_GROUP_BY ).IsEmpty() );
234 if( !wxDialog::TransferDataToWindow() )
241 m_profile =
m_frame->GetBoard()->GetDesignSettings().GetDrillSymbolProfile();
271 return aCol.m_Id == id;
279 col.
m_Heading = columnLabel(
id ).Upper();
301 if(
m_chart->GetBorderStroke().GetWidth() >= 0 )
304 if(
m_chart->GetSeparatorsStroke().GetWidth() >= 0 )
319 if( !wxDialog::TransferDataFromWindow() )
322 std::vector<DRILL_CHART_COLUMN> columns;
324 for(
size_t row = 0; row <
m_columns.size(); ++row )
330 if( columns.empty() )
332 DisplayError(
this,
_(
"A drill chart needs at least one column." ) );
367 m_chart->SetBorderStroke( stroke );
375 m_chart->SetSeparatorsStroke( stroke );
379 const std::set<DRILL_GROUP_KEY> wasGroupedBy = boardProfile.
GroupKeys();
385 if( columnGroupKey(
id, key ) )
389 if( boardProfile.
GroupKeys() != wasGroupedBy )
398 m_chart->RebuildCells( *board );
411 if( cols < 1 || width < 1 )
418 for(
int col = 0; col < cols; ++col )
420 if( col !=
COL_NAME && col != COL_HEADING )
424 const int spare = width - fixed;
430 m_columnGrid->SetColSize( COL_HEADING, spare - spare / 2 );
443 const int defaultWidth =
m_frame->GetDesignSettings().GetLineThickness(
466 const int target = row + aDelta;
468 if( row < 0 || target < 0 || target >=
static_cast<int>(
m_columns.size() ) )
474 const bool shown =
m_shown[row];
508 return aCol.m_Id == id;
516 col.
m_Heading = columnLabel(
id ).Upper();
533 wxFileDialog dlg(
this,
_(
"Import Drill Chart Template" ), wxEmptyString, wxEmptyString,
534 _(
"Drill chart templates" ) + wxT(
" (*.json)|*.json" ),
535 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
537 if( dlg.ShowModal() != wxID_OK )
562 wxFileDialog dlg(
this,
_(
"Export Drill Chart Template" ), wxEmptyString, wxT(
"drill_chart" ),
563 _(
"Drill chart templates" ) + wxT(
" (*.json)|*.json" ),
564 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
566 if( dlg.ShowModal() != wxID_OK )
572 tmpl.
SetName( wxFileName( dlg.GetPath() ).GetName() );
577 for(
size_t row = 0; row <
m_columns.size(); ++row )
585 if( !tmpl.
SaveToFile( dlg.GetPath(), &error ) )
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
DRILL_SYMBOL_PROFILE & GetDrillSymbolProfile()
Information pertinent to a Pcbnew printed circuit board.
void BumpDrillModelGeneration()
Bumped whenever anything a drill chart or map reports on has moved.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
wxCheckBox * m_filterPlated
wxCheckBox * m_filterVias
DIALOG_DRILL_CHART_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Drill Chart Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxCheckBox * m_filterNonPlated
wxCheckBox * m_rowSeparators
wxCheckBox * m_filterCastellated
wxStaticText * m_separatorsWidthUnits
wxCheckBox * m_borderCheckbox
wxStaticText * m_borderWidthLabel
wxTextCtrl * m_borderWidthCtrl
wxCheckBox * m_colSeparators
wxCheckBox * m_headerBorder
wxStaticText * m_separatorsWidthLabel
wxCheckBox * m_filterSlots
wxSpinCtrl * m_precisionCtrl
wxCheckBox * m_showTotals
PCB_LAYER_BOX_SELECTOR * m_LayerSelectionCtrl
wxCheckBox * m_filterBackdrills
wxTextCtrl * m_separatorsWidthCtrl
wxStaticText * m_borderWidthUnits
void moveColumn(int aDelta)
void onExportTemplate(wxCommandEvent &aEvent) override
bool TransferDataFromWindow() override
UNIT_BINDER m_borderWidth
UNIT_BINDER m_separatorsWidth
void onMoveUp(wxCommandEvent &aEvent) override
bool TransferDataToWindow() override
std::vector< DRILL_CHART_COLUMN > m_columns
Every known column, checked ones first in chart order.
void fitColumnGrid()
Share the grid's width out across its columns so none of it goes unused.
DIALOG_DRILL_CHART_PROPERTIES(PCB_BASE_EDIT_FRAME *aFrame, PCB_DRILL_CHART *aChart)
void onBorderChecked(wxCommandEvent &aEvent) override
~DIALOG_DRILL_CHART_PROPERTIES() override
DRILL_SYMBOL_PROFILE m_profile
The board's grouping, edited through the Group By column.
void onMoveDown(wxCommandEvent &aEvent) override
void fillColumnGrid()
Fill the column grid from m_columns, preserving the selected row.
PCB_DRILL_CHART * m_chart
void applyTemplate(const DRILL_CHART_TEMPLATE &aTemplate)
Rebuild m_columns/m_shown from a template, keeping unused columns available.
void onImportTemplate(wxCommandEvent &aEvent) override
std::vector< bool > m_shown
bool harvestColumnGrid()
Read the grid back into m_columns.
PCB_BASE_EDIT_FRAME * m_frame
void onResetColumns(wxCommandEvent &aEvent) override
void onColumnGridSize(wxSizeEvent &aEvent)
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...
The column set and formatting a new chart starts from.
DRILL_CHART_UNITS GetUnits() const
bool SaveToFile(const wxString &aPath, wxString *aError) const
Read and write a template as JSON.
void SetName(const wxString &aName)
void SetPrecision(int aPrecision)
void SetUnits(DRILL_CHART_UNITS aUnits)
void SetShowTotals(bool aShow)
bool LoadFromFile(const wxString &aPath, wxString *aError)
std::vector< DRILL_CHART_COLUMN > & Columns()
static DRILL_CHART_TEMPLATE MakeDefault()
bool GetShowTotals() const
Grouping rules and symbol assignments, shared by reference so a chart and its map can never disagree ...
void SetGroupedBy(DRILL_GROUP_KEY aKey, bool aOn)
const std::set< DRILL_GROUP_KEY > & GroupKeys() const
Common, abstract interface for edit frames.
A drill chart placed on the board, kept in step with the holes.
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
LSET DrillDocumentationLayers()
Layers a chart or map may live on.
DRILL_GROUP_KEY
Which properties split holes into separate chart rows and symbols.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
#define SKIP_CONNECTIVITY
DRILL_CHART_COLUMN_ID m_Id
Which holes a chart reports on.