32 #include <boost/algorithm/string/join.hpp> 128 ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_NUMERIC,
129 _(
"Numerals (0,1,2,...,9,10)" ),
132 ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_HEX,
133 _(
"Hexadecimal (0,1,...,F,10,...)" ),
136 ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_ALPHA_NO_IOSQXZ,
137 _(
"Alphabet, minus IOSQXZ" ),
140 ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_ALPHA_FULL,
141 _(
"Alphabet, full 26 characters" ),
146 std::unique_ptr<ARRAY_OPTIONS>& aSettings,
147 bool enableNumbering, wxPoint aOrigPos ) :
149 m_settings( aSettings ),
150 m_originalItemPosition( aOrigPos ),
151 m_numberingEnabled( enableNumbering ),
152 m_hSpacing( aParent, m_labelDx, m_entryDx, m_unitLabelDx ),
153 m_vSpacing( aParent, m_labelDy, m_entryDy, m_unitLabelDy ),
154 m_hOffset( aParent, m_labelOffsetX, m_entryOffsetX, m_unitLabelOffsetX ),
155 m_vOffset( aParent, m_labelOffsetY, m_entryOffsetY, m_unitLabelOffsetY ),
156 m_hCentre( aParent, m_labelCentreX, m_entryCentreX, m_unitLabelCentreX ),
157 m_vCentre( aParent, m_labelCentreY, m_entryCentreY, m_unitLabelCentreY ),
158 m_circRadius( aParent, m_labelCircRadius, m_valueCircRadius, m_unitLabelCircRadius ),
159 m_circAngle( aParent, m_labelCircAngle, m_entryCircAngle, m_unitLabelCircAngle ),
173 const wxString label = wxGetTranslation( numData.m_label );
174 void* clientData = (
void*) &numData;
234 SetMinSize( GetSize() );
254 static bool validateLongEntry(
const wxTextEntry& entry,
long& dest,
const wxString& description,
255 wxArrayString& errors )
259 if( !entry.GetValue().ToLong( &dest ) )
262 err.Printf(
_(
"Bad numeric value for %s: %s" ), description, entry.GetValue() );
282 const wxTextCtrl& aStepEntry,
ARRAY_AXIS& aAxis,
283 wxArrayString& errors )
285 void* clientData = typeEntry.GetClientData( typeEntry.GetSelection() );
286 const NUMBERING_LIST_DATA* numberingData = static_cast<NUMBERING_LIST_DATA*>( clientData );
288 wxCHECK_MSG( numberingData,
false,
"Failed to get client data from list control." );
292 const wxString text = offsetEntry.GetValue();
298 errors.Add(
wxString::Format(
_(
"Could not determine numbering start from \"%s\": " 299 "expected value consistent with alphabet \"%s\"" ),
317 std::unique_ptr<ARRAY_OPTIONS> newSettings;
319 wxArrayString errors;
324 auto newGrid = std::make_unique<ARRAY_GRID_OPTIONS>();
350 if( newGrid->GetNumberingStartIsSpecified() )
357 newGrid->m_pri_axis, errors );
359 if( newGrid->m_2dArrayNumbering )
363 newGrid->m_sec_axis, errors )
372 newGrid->m_2dArrayNumbering =
false;
373 newGrid->m_pri_axis.SetAxisType( ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_NUMERIC );
374 newGrid->m_pri_axis.SetOffset( 1 );
380 newSettings = std::move( newGrid );
384 auto newCirc = std::make_unique<ARRAY_CIRCULAR_OPTIONS>();
401 if( newCirc->GetNumberingStartIsSpecified() )
410 newCirc->m_axis.SetAxisType( ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_NUMERIC );
411 newCirc->m_axis.SetOffset( 1 );
417 newSettings = std::move( newCirc );
435 if( errors.IsEmpty() )
436 errorStr =
_(
"Bad parameters");
438 errorStr = boost::algorithm::join( errors,
"\n" );
440 wxMessageBox( errorStr );
wxTextCtrl * m_entryGridPriNumberingOffset
wxString m_CircNumberingOffset
void OnParameterChanged(wxCommandEvent &event) override
Implementation of conversion functions that require both schematic and board internal units.
std::unique_ptr< ARRAY_OPTIONS > & m_settings
The settings to re-seat on dialog OK.
wxRadioBox * m_radioBoxGridStaggerType
wxCheckBox * m_entryRotateItemsCb
wxStaticText * m_labelGridNumberingOffset
wxPanel * m_circularPanel
static bool validateLongEntry(const wxTextEntry &entry, long &dest, const wxString &description, wxArrayString &errors)
Validate and save a long integer entry.
void SetAxisType(NUMBERING_TYPE aType)
Set the axis numbering type.
bool SetOffset(const wxString &aOffsetName)
Set the axis start (as a string, which should decode to a valid index in the alphabet)
long m_GridSecondaryAxisScheme
wxRadioBox * m_rbGridStartNumberingOpt
TEXT_CTRL_EVAL * m_entryStagger
wxTextCtrl * m_entryCircNumberingStep
wxStaticText * m_labelPriAxisNumbering
WIDGET_SAVE_RESTORE m_cfg_persister
wxCheckBox * m_checkBoxGridReverseNumbering
long m_GridPrimaryAxisScheme
bool m_CircRotatationStep
CREATE_ARRAY_DIALOG_ENTRIES()
Construct with some sensible defaults.
long m_GridPrimaryAxisStep
DIALOG_CREATE_ARRAY(PCB_BASE_FRAME *aParent, std::unique_ptr< ARRAY_OPTIONS > &aOptions, bool enableNumbering, wxPoint aOrigPos)
Construct a new dialog.
void SetStep(int aStep)
Set the skip between consecutive numbers (useful when doing a partial array, e.g.
wxChoice * m_choiceCircNumbering
TEXT_CTRL_EVAL * m_entryNy
wxString m_GridSecondaryNumOffset
wxRadioBox * m_rbCircStartNumberingOpt
Class that contains information about a single array axis and the numbering of items along that axis.
void calculateCircularArrayProperties()
wxTextCtrl * m_entryCircNumberingStart
wxRadioBox * m_radioBoxGridNumberingScheme
wxStaticText * m_labelSecAxisNumbering
bool TransferDataFromWindow() override
wxButton * m_stdButtonsOK
TEXT_CTRL_EVAL * m_entryNx
wxChoice * m_choiceSecAxisNumbering
wxTextCtrl * m_entryGridSecNumberingStep
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Struct containing the last-entered values for the dialog.
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
wxString m_GridPrimaryNumOffset
wxNotebook * m_gridTypeNotebook
TEXT_CTRL_EVAL * m_entryCircCount
static const std::vector< NUMBERING_LIST_DATA > numberingTypeData
List of type <--> name mappings (in order) for the numbering type list boxes.
Local mapping for list-box <-> numbering type.
wxRadioBox * m_radioBoxGridNumberingAxis
void setControlEnablement()
long m_GridSecondaryAxisStep
static bool validateAxisOptions(const wxTextCtrl &offsetEntry, const wxChoice &typeEntry, const wxTextCtrl &aStepEntry, ARRAY_AXIS &aAxis, wxArrayString &errors)
Validates and saves (if valid) the type and offset of an array axis numbering.
wxTextCtrl * m_entryGridSecNumberingOffset
wxTextCtrl * m_entryGridPriNumberingStep
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
virtual long long int GetValue()
Return the current value in Internal Units.
long m_Grid2dArrayNumbering
void SetCoordType(ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
Set the current origin transform mode.
ARRAY_AXIS::NUMBERING_TYPE m_numbering_type
Class DIALOG_CREATE_ARRAY_BASE.
double DoubleValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function DoubleValueFromString converts aTextValue to a double.
static constexpr int Millimeter2iu(double mm)
const wxString & GetAlphabet() const
Get the alphabet for the current numbering scheme.
static CREATE_ARRAY_DIALOG_ENTRIES s_arrayOptions
wxChoice * m_choicePriAxisNumbering
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
wxTextCtrl * m_entryCircAngle
const wxPoint m_originalItemPosition