KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_create_array.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
26#include <set>
27
28#include <wx/msgdlg.h>
29
30#include <base_units.h>
31#include <footprint.h>
32#include <pcb_edit_frame.h>
33#include <tools/pcb_actions.h>
35#include <tool/tool_manager.h>
37
38
43{
49
50 bool m_OptionsSet = true;
51
52 long m_GridNx = 5;
53 long m_GridNy = 5;
54 long m_GridDx = pcbIUScale.mmToIU( 2.54 );
55 long m_GridDy = pcbIUScale.mmToIU( 2.54 );
56 long m_GridOffsetX = 0;
57 long m_GridOffsetY = 0;
58 long m_GridStagger = 1;
59 bool m_GridStaggerRows = true;
62
63 bool m_GridRenumberPads = true;
64 long m_GridNumberingAxis = 0; // h then v
65 bool m_GridNumReverseAlt = false;
66 long m_GridNumStartSet = 1; // use specified start
67 long m_Grid2dArrayNumbering = 0; // linear numbering
68 long m_GridPrimaryAxisScheme = 0; // numeric
69 long m_GridSecondaryAxisScheme = 0; // numeric
70 wxString m_GridPrimaryNumOffset = wxT( "1" ); // numeric
71 wxString m_GridSecondaryNumOffset = wxT( "1" ); // numeric
74
75 long m_CircCentreX = 0;
76 long m_CircCentreY = 0;
78 long m_CircleDirection = 0; // clockwise
80 long m_CircCount = 4;
82 long m_CircNumStartSet = 1; // use specified start
84 wxString m_CircNumberingOffset = wxT("1");
87 long m_ArrayTypeTab = 0; // start on grid view
88 bool m_SelectionArrange = false;
89 bool m_SelectionDuplicate = true; // Duplicate by default
91 bool m_FootprintReannotate = true; // Assign unique by default
92};
93
94// Persistent options settings
96
105
110static const std::vector<NUMBERING_LIST_DATA> numberingTypeData {
111 {
113 _( "Numerals (0,1,2,...,9,10)" ),
114 },
115 {
117 _( "Hexadecimal (0,1,...,F,10,...)" ),
118 },
119 {
121 _( "Alphabet, minus IOSQXZ" ),
122 },
123 {
125 _( "Alphabet, full 26 characters" ),
126 },
127};
128
130 std::unique_ptr<ARRAY_OPTIONS>& aSettings,
131 bool aIsFootprintEditor, const VECTOR2I& aOrigPos ) :
132 DIALOG_CREATE_ARRAY_BASE( aParent ),
133 m_frame( aParent ),
134 m_settings( aSettings ),
135 m_originalItemPosition( aOrigPos ), m_isFootprintEditor( aIsFootprintEditor ),
145{
146 // Configure display origin transforms
153
154 // Set up numbering scheme drop downs character set strings
155 for( const auto& numData : numberingTypeData )
156 {
157 const wxString label = wxGetTranslation( numData.m_label );
158 void* clientData = (void*) &numData;
159
160 m_choicePriAxisNumbering->Append( label, clientData );
161 m_choiceSecAxisNumbering->Append( label, clientData );
162 m_choiceCircNumbering->Append( label, clientData );
163 }
164
165 m_choicePriAxisNumbering->SetSelection( 0 );
166 m_choiceSecAxisNumbering->SetSelection( 0 );
167 m_choiceCircNumbering->SetSelection( 0 );
168
171
172 // bind grid options to persister
173 m_cfg_persister.Add( *m_entryNx, s_arrayOptions.m_GridNx );
174 m_cfg_persister.Add( *m_entryNy, s_arrayOptions.m_GridNy );
177
178 m_cfg_persister.Add( m_hOffset, s_arrayOptions.m_GridOffsetX );
179 m_cfg_persister.Add( m_vOffset, s_arrayOptions.m_GridOffsetY );
180 m_cfg_persister.Add( *m_entryStagger, s_arrayOptions.m_GridStagger );
181
182 m_cfg_persister.Add( *m_staggerRows, s_arrayOptions.m_GridStaggerRows );
183
184 m_cfg_persister.Add( *m_rbItemsRemainInPlace, s_arrayOptions.m_GridPositionItemsInPlace );
185 m_cfg_persister.Add( *m_rbCentreOnSource, s_arrayOptions.m_GridPositionCentreOnItems );
186
187 m_cfg_persister.Add( *m_cbRenumberPads, s_arrayOptions.m_GridRenumberPads );
190
192 m_cfg_persister.Add( *m_radioBoxGridNumberingScheme, s_arrayOptions.m_Grid2dArrayNumbering );
193 m_cfg_persister.Add( *m_choicePriAxisNumbering, s_arrayOptions.m_GridPrimaryAxisScheme );
194 m_cfg_persister.Add( *m_choiceSecAxisNumbering, s_arrayOptions.m_GridSecondaryAxisScheme );
195
196 m_cfg_persister.Add( *m_entryGridPriNumberingOffset, s_arrayOptions.m_GridPrimaryNumOffset );
197 m_cfg_persister.Add( *m_entryGridSecNumberingOffset, s_arrayOptions.m_GridSecondaryNumOffset );
198 m_cfg_persister.Add( *m_entryGridPriNumberingStep, s_arrayOptions.m_GridPrimaryAxisStep );
199 m_cfg_persister.Add( *m_entryGridSecNumberingStep, s_arrayOptions.m_GridSecondaryAxisStep );
200
201 // bind circular options to persister
202 m_cfg_persister.Add( m_hCentre, s_arrayOptions.m_CircCentreX );
203 m_cfg_persister.Add( m_vCentre, s_arrayOptions.m_CircCentreY );
204
205 m_cfg_persister.Add( *m_checkBoxFullCircle, s_arrayOptions.m_CircFullCircle );
206 m_cfg_persister.Add( m_circAngle, s_arrayOptions.m_CircAngle );
207 m_cfg_persister.Add( m_circOffset, s_arrayOptions.m_CircOffsetAngle );
208 m_cfg_persister.Add( *m_rbCircDirection, s_arrayOptions.m_CircleDirection );
210 m_cfg_persister.Add( *m_entryRotateItemsCb, s_arrayOptions.m_CircRotatationStep );
211
213 m_cfg_persister.Add( *m_choiceCircNumbering, s_arrayOptions.m_GridCircNumScheme );
214 m_cfg_persister.Add( *m_entryCircNumberingStart, s_arrayOptions.m_CircNumberingOffset );
215 m_cfg_persister.Add( *m_entryCircNumberingStep, s_arrayOptions.m_CircNumberingStep );
216
217 m_cfg_persister.Add( *m_gridTypeNotebook, s_arrayOptions.m_ArrayTypeTab );
218
220 m_cfg_persister.Add( *m_radioBtnDuplicateSelection, s_arrayOptions.m_SelectionDuplicate );
221
222 m_cfg_persister.Add( *m_radioBtnKeepRefs, s_arrayOptions.m_FootprintKeepAnnotations );
223 m_cfg_persister.Add( *m_radioBtnUniqueRefs, s_arrayOptions.m_FootprintReannotate );
224
225 m_cfg_persister.RestoreConfigToControls();
226
227 // Run the callbacks once to process the dialog contents
230
232 Fit();
233 SetMinSize( GetSize() );
234}
235
236
240
241
242void DIALOG_CREATE_ARRAY::OnParameterChanged( wxCommandEvent& event )
243{
244 if( m_checkBoxFullCircle->GetValue() && m_entryCircAngle == event.GetEventObject() )
245 {
246 return;
247 }
248
251}
252
253
254void DIALOG_CREATE_ARRAY::OnSelectCenterButton( wxCommandEvent& event )
255{
256 event.Skip();
257
258 TOOL_MANAGER* toolMgr = m_frame->GetToolManager();
259 PCB_PICKER_TOOL* pickerTool = toolMgr->GetTool<PCB_PICKER_TOOL>();
260 wxCHECK( pickerTool, /* void */ );
261
262 // Keep the dialog visible, but disable while picking.
263 // Hiding the dialog on GTK causes the controls to not accept their new values
264 Disable();
265
266 if( event.GetEventObject() == m_btnSelectCenterItem )
267 {
269 PCB_PICKER_TOOL::INTERACTIVE_PARAMS { this, _( "Select center item..." ) } );
270 }
271 else if( event.GetEventObject() == m_btnSelectCenterPoint )
272 {
274 PCB_PICKER_TOOL::INTERACTIVE_PARAMS { this, _( "Select center point..." ) } );
275 }
276 else
277 {
278 wxFAIL_MSG( "Unknown event source" );
279 }
280}
281
282
283void DIALOG_CREATE_ARRAY::OnAxisNumberingChange( wxCommandEvent& aEvent )
284{
285 // On an alphabet change, make sure the offset control is valid by default.
286
287 const int newAlphabet = aEvent.GetSelection();
288
289 wxCHECK( newAlphabet >= 0 && newAlphabet < static_cast<int>( numberingTypeData.size() ),
290 /* void */ );
291
292 const ARRAY_AXIS::NUMBERING_TYPE numberingType =
293 numberingTypeData[newAlphabet].m_numbering_type;
294
295 wxTextCtrl* matchingTextCtrl = nullptr;
296
297 if( aEvent.GetEventObject() == m_choicePriAxisNumbering )
298 matchingTextCtrl = m_entryGridPriNumberingOffset;
299 else if( aEvent.GetEventObject() == m_choiceSecAxisNumbering )
300 matchingTextCtrl = m_entryGridSecNumberingOffset;
301 else if( aEvent.GetEventObject() == m_choiceCircNumbering )
302 matchingTextCtrl = m_entryCircNumberingStart;
303
304 wxCHECK( matchingTextCtrl, /* void */ );
305
306 ARRAY_AXIS dummyAxis;
307 dummyAxis.SetAxisType( numberingType );
308
309 // If the text control has a valid value for the new alphabet, keep it
310 // else reset to the first value in the new alphabet.
311
312 const bool isAlreadyOK = dummyAxis.SetOffset( matchingTextCtrl->GetValue() );
313
314 if( !isAlreadyOK )
315 {
316 dummyAxis.SetOffset( ARRAY_AXIS::TypeIsNumeric( numberingType ) ? 1 : 0 );
317 matchingTextCtrl->SetValue( dummyAxis.GetItemNumber( 0 ) );
318 }
319}
320
321
322// Implement the RECEIVER interface for the callback from the TOOL
324{
325 if( aItem )
326 {
327 m_hCentre.SetValue( aItem->GetPosition().x );
328 m_vCentre.SetValue( aItem->GetPosition().y );
329 }
330
331 Enable( true );
332}
333
334
335void DIALOG_CREATE_ARRAY::UpdatePickedPoint( const std::optional<VECTOR2I>& aPoint )
336{
337 if( aPoint )
338 {
339 m_hCentre.SetValue( aPoint->x );
340 m_vCentre.SetValue( aPoint->y );
341 }
342
343 Enable( true );
344}
345
346
356static bool validateLongEntry( const wxTextEntry& entry, long& dest, const wxString& description,
357 wxArrayString& errors )
358{
359 bool ok = true;
360
361 if( !entry.GetValue().ToLong( &dest ) )
362 {
363 wxString err;
364 err.Printf( _( "Bad numeric value for %s: %s" ), description, entry.GetValue() );
365 errors.Add( err );
366 ok = false;
367 }
368
369 return ok;
370}
371
372
383static bool validateAxisOptions( const wxTextCtrl& offsetEntry, const wxChoice& typeEntry,
384 const wxTextCtrl& aStepEntry, ARRAY_AXIS& aAxis,
385 wxArrayString& errors )
386{
387 void* clientData = typeEntry.GetClientData( typeEntry.GetSelection() );
388 const NUMBERING_LIST_DATA* numberingData = static_cast<NUMBERING_LIST_DATA*>( clientData );
389
390 wxCHECK_MSG( numberingData, false, wxT( "Failed to get client data from list control." ) );
391
392 aAxis.SetAxisType( numberingData->m_numbering_type );
393
394 const wxString text = offsetEntry.GetValue();
395
396 bool ok = aAxis.SetOffset( text );
397
398 if( !ok )
399 {
400 errors.Add( wxString::Format( _( "Could not determine numbering start from '%s': "
401 "expected value consistent with alphabet '%s'." ),
402 text,
403 aAxis.GetAlphabet() ) );
404 return false;
405 }
406
407 long step;
408 ok = validateLongEntry( aStepEntry, step, _( "step value" ), errors );
409
410 if( ok )
411 aAxis.SetStep( step );
412
413 return ok;
414}
415
416
423static bool arrayHasStackedPositions( const ARRAY_OPTIONS& aOptions, const VECTOR2I& aPos )
424{
425 std::set<std::pair<VECTOR2I, EDA_ANGLE>> placements;
426
427 for( int ii = 0; ii < aOptions.GetArraySize(); ++ii )
428 {
429 const ARRAY_OPTIONS::TRANSFORM xf = aOptions.GetTransform( ii, aPos );
430
431 if( !placements.emplace( xf.m_offset, xf.m_rotation ).second )
432 return true;
433 }
434
435 return false;
436}
437
438
440{
441 std::unique_ptr<ARRAY_OPTIONS> newSettings;
442
443 wxArrayString errors;
444 const wxWindow* page = m_gridTypeNotebook->GetCurrentPage();
445
446 if( page == m_gridPanel )
447 {
448 auto newGrid = std::make_unique<ARRAY_GRID_OPTIONS>();
449 bool ok = true;
450
451 // ints
452 ok &= validateLongEntry(*m_entryNx, newGrid->m_nx, _("horizontal count"), errors);
453 ok &= validateLongEntry(*m_entryNy, newGrid->m_ny, _("vertical count"), errors);
454
455 newGrid->m_delta.x = m_hSpacing.GetIntValue();
456 newGrid->m_delta.y = m_vSpacing.GetIntValue();
457
458 newGrid->m_offset.x = m_hOffset.GetIntValue();
459 newGrid->m_offset.y = m_vOffset.GetIntValue();
460
461 newGrid->m_centred = m_rbCentreOnSource->GetValue();
462
463 ok &= validateLongEntry(*m_entryStagger, newGrid->m_stagger, _("stagger"), errors);
464
465 newGrid->m_stagger_rows = m_staggerRows->GetValue();
466
467 newGrid->m_horizontalThenVertical = m_radioBoxGridNumberingAxis->GetSelection() == 0;
468 newGrid->m_reverseNumberingAlternate = m_checkBoxGridReverseNumbering->GetValue();
469
470 newGrid->SetShouldNumber( m_isFootprintEditor && m_cbRenumberPads->GetValue() );
471
473 {
474 newGrid->SetNumberingStartIsSpecified( m_rbGridStartNumberingOpt->GetSelection() == 1 );
475
476 if( newGrid->GetNumberingStartIsSpecified() )
477 {
478 newGrid->m_2dArrayNumbering = m_radioBoxGridNumberingScheme->GetSelection() != 0;
479
480 // validate from the input fields
484 newGrid->m_pri_axis, errors );
485
486 if( newGrid->m_2dArrayNumbering )
487 {
491 newGrid->m_sec_axis, errors );
492 }
493
494 ok &= numOk;
495 }
496 else
497 {
498 // artificial linear numeric scheme from 1
499 newGrid->m_2dArrayNumbering = false;
500 newGrid->m_pri_axis.SetAxisType( ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_NUMERIC );
501 newGrid->m_pri_axis.SetOffset( 1 );
502 }
503 }
504
505 // Only use settings if all values are good
506 if( ok )
507 newSettings = std::move( newGrid );
508 }
509 else if( page == m_circularPanel )
510 {
511 auto newCirc = std::make_unique<ARRAY_CIRCULAR_OPTIONS>();
512 bool ok = true;
515
516 newCirc->m_centre.x = m_hCentre.GetIntValue();
517 newCirc->m_centre.y = m_vCentre.GetIntValue();
518 newCirc->m_angle = EDA_ANGLE( angle, DEGREES_T );
519 newCirc->m_angleOffset = EDA_ANGLE( offset, DEGREES_T );
520 newCirc->m_clockwise = m_rbCircDirection->GetSelection() == 0;
521
522 ok = validateLongEntry(*m_entryCircCount, newCirc->m_nPts, _("point count"), errors);
523
524 newCirc->m_rotateItems = m_entryRotateItemsCb->GetValue();
525 newCirc->SetShouldNumber( m_isFootprintEditor );
526
528 {
529 newCirc->SetNumberingStartIsSpecified( m_rbCircStartNumberingOpt->GetSelection() == 1 );
530
531 if( newCirc->GetNumberingStartIsSpecified() )
532 {
534 *m_entryCircNumberingStep, newCirc->m_axis, errors );
535 }
536 else
537 {
538 // artificial linear numeric scheme from 1
539 newCirc->m_axis.SetAxisType( ARRAY_AXIS::NUMBERING_TYPE::NUMBERING_NUMERIC );
540 newCirc->m_axis.SetOffset( 1 ); // Start at "1"
541 }
542 }
543
544 // Only use settings if all values are good
545 if( ok )
546 newSettings = std::move( newCirc );
547 }
548
549 bool ret = false;
550
551 // Warn (but don't block) when the array would stack items on top of one another.
552 // Zero-spacing arrays are legitimate when intentionally duplicating in place, but
553 // accidental zero spacing on a large count can stamp out thousands of overlapping
554 // objects (see issue 22669). Confirm the user wants to do this.
555 if( newSettings
556 && newSettings->GetArraySize() > 1
558 {
559 wxString msg = wxString::Format( _( "The array configuration would place %d "
560 "items at the same position and rotation, "
561 "stacking them on top of one another.\n\n"
562 "Proceed anyway?" ),
563 newSettings->GetArraySize() );
564
565 if( wxMessageBox( msg, _( "Confirm Array" ), wxYES_NO | wxICON_QUESTION, this ) != wxYES )
566 return false;
567 }
568
569 // If we got good settings, send them out and finish
570 if( newSettings )
571 {
572 // assign pointer and ownership here
573 m_settings = std::move( newSettings );
574
575 m_settings->SetShouldArrangeSelection( m_radioBtnArrangeSelection->GetValue() );
576 m_settings->SetSShouldReannotateFootprints( m_radioBtnUniqueRefs->GetValue() );
577
578 // persist the control state for next time
579 m_cfg_persister.ReadConfigFromControls();
580
581 ret = true;
582 }
583 else
584 {
585 wxString errorStr;
586
587 if( errors.IsEmpty() )
588 errorStr = _("Bad parameters");
589 else
590 errorStr = wxJoin( errors, '\n' );
591
592 wxMessageBox( errorStr );
593 ret = false;
594 }
595
596 // This dialog is not modal, so close it now if successful
597 if( ret )
598 Close();
599
600 return ret;
601}
602
603
605{
606 if( m_checkBoxFullCircle->GetValue() )
607 {
608 m_entryCircAngle->Disable();
609 }
610 else
611 {
612 m_entryCircAngle->Enable();
613 }
614
616 {
617 m_footprintReannotatePanel->Show( false );
618
619 m_gridPadNumberingPanel->Show( true );
620 m_circularPadNumberingPanel->Show( true );
621
622 // In no pad re-numbering, everything is disabled
623 bool renumber_pads = m_cbRenumberPads->GetValue();
624
625 m_radioBoxGridNumberingAxis->Enable( renumber_pads );
626 m_checkBoxGridReverseNumbering->Enable( renumber_pads );
627 m_rbGridStartNumberingOpt->Enable( renumber_pads );
628
629 // If we set the start number, we can set the other options,
630 // otherwise it's a hardcoded linear array
631 const bool use_set_start_grid = renumber_pads && m_rbGridStartNumberingOpt->GetSelection() == 1;
632
633 m_radioBoxGridNumberingScheme->Enable( use_set_start_grid );
634 m_labelPriAxisNumbering->Enable( use_set_start_grid );
635 m_choicePriAxisNumbering->Enable( use_set_start_grid );
636
637 // Disable the secondary axis numbering option if the
638 // numbering scheme doesn't have two axes
639 const bool num2d = m_radioBoxGridNumberingScheme->GetSelection() != 0;
640
641 m_labelSecAxisNumbering->Enable( use_set_start_grid && num2d );
642 m_choiceSecAxisNumbering->Enable( use_set_start_grid && num2d );
643
644 // We can only set an offset if we're setting the start number
645 m_labelGridNumberingOffset->Enable( use_set_start_grid );
646 m_labelGridNumberingStep->Enable( use_set_start_grid );
647 m_entryGridPriNumberingOffset->Enable( use_set_start_grid );
648 m_entryGridPriNumberingStep->Enable( use_set_start_grid );
649 m_entryGridSecNumberingOffset->Enable( use_set_start_grid && num2d );
650 m_entryGridSecNumberingStep->Enable( use_set_start_grid && num2d );
651
652 // disable the circular number offset in the same way
653 const bool use_set_start_circ = renumber_pads && m_rbCircStartNumberingOpt->GetSelection() == 1;
654 m_entryCircNumberingStart->Enable( use_set_start_circ );
655 }
656 else
657 {
658 // grid
659 m_rbGridStartNumberingOpt->Enable( false );
660 m_radioBoxGridNumberingScheme->Enable( false );
661
662 m_labelPriAxisNumbering->Enable( false );
663 m_labelSecAxisNumbering->Enable( false );
664
665 m_choiceSecAxisNumbering->Enable( false );
666 m_choicePriAxisNumbering->Enable( false );
667
668 m_labelGridNumberingOffset->Enable( false );
669 m_entryGridPriNumberingOffset->Enable( false );
670 m_entryGridSecNumberingOffset->Enable( false );
671
672 m_gridPadNumberingPanel->Show( false );
673
674 // circular
675 m_rbCircStartNumberingOpt->Enable( false );
676 m_entryCircNumberingStart->Enable( false );
677
678 m_circularPadNumberingPanel->Show( false );
679
680 m_footprintReannotatePanel->Show( true );
681 }
682
683 if( m_radioBtnArrangeSelection->GetValue() )
684 {
685 m_footprintReannotatePanel->Show( false );
686 }
687}
688
689
691{
692 // In full circle mode, the division angle is computed from the number of points
693 if( m_checkBoxFullCircle->GetValue() )
694 {
695 long nPts;
696 if( m_entryCircCount->GetValue().ToLong( &nPts ) )
697 {
698 EDA_ANGLE division = EDA_ANGLE( 360, DEGREES_T ) / nPts;
699 m_circAngle.SetAngleValue( division );
700 }
701 }
702}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:125
Class that contains information about a single array axis and the numbering of items along that axis.
Definition array_axis.h:40
bool SetOffset(const wxString &aOffsetName)
Set the axis start (as a string, which should decode to a valid index in the alphabet),...
wxString GetItemNumber(int n) const
Get the position number (name) for the n'th axis point.
static bool TypeIsNumeric(NUMBERING_TYPE type)
Check if a numbering type is a numeric type.
Definition array_axis.h:60
const wxString & GetAlphabet() const
Get the alphabet for the current numbering scheme.
void SetAxisType(NUMBERING_TYPE aType)
Set the axis numbering type.
@ NUMBERING_NUMERIC
Arabic numerals: 0,1,2,3,4,5,6,7,8,9,10,11...
Definition array_axis.h:44
@ NUMBERING_ALPHA_NO_IOSQXZ
Alphabet, excluding IOSQXZ.
Definition array_axis.h:53
@ NUMBERING_ALPHA_FULL
Full 26-character alphabet.
Definition array_axis.h:54
void SetStep(int aStep)
Set the skip between consecutive numbers (useful when doing a partial array, e.g.
Options that govern the setup of an "array" of multiple item.
virtual int GetArraySize() const =0
The number of points in this array.
virtual TRANSFORM GetTransform(int aN, const VECTOR2I &aPos) const =0
Get the transform of the n-th point in the array.
DIALOG_CREATE_ARRAY_BASE(wxWindow *parent, wxWindowID id=wxID_DIALOG_CREATE_ARRAY, const wxString &title=_("Create Array"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
WIDGET_SAVE_RESTORE m_cfg_persister
DIALOG_CREATE_ARRAY(PCB_BASE_FRAME *aParent, std::unique_ptr< ARRAY_OPTIONS > &aOptions, bool enableNumbering, const VECTOR2I &aOrigPos)
Construct a new dialog.
bool TransferDataFromWindow() override
PCB_BASE_FRAME * m_frame
void OnSelectCenterButton(wxCommandEvent &aEvent) override
const VECTOR2I m_originalItemPosition
std::unique_ptr< ARRAY_OPTIONS > & m_settings
The settings to re-seat on dialog OK.
void OnParameterChanged(wxCommandEvent &aEvent) override
void UpdatePickedItem(const EDA_ITEM *aItem) override
void UpdatePickedPoint(const std::optional< VECTOR2I > &aPoint) override
void OnAxisNumberingChange(wxCommandEvent &aEvent) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
bool Enable(bool enable) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:100
virtual VECTOR2I GetPosition() const
Definition eda_item.h:286
static TOOL_ACTION selectPointInteractively
static TOOL_ACTION selectItemInteractively
Selection of reference points/items.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Generic tool for picking an item.
Master controller class:
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
static const std::vector< NUMBERING_LIST_DATA > numberingTypeData
List of type <--> name mappings (in order) for the numbering type list boxes.
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.
static bool arrayHasStackedPositions(const ARRAY_OPTIONS &aOptions, const VECTOR2I &aPos)
Detect whether the array configuration would produce two or more items at the same position and rotat...
static bool validateLongEntry(const wxTextEntry &entry, long &dest, const wxString &description, wxArrayString &errors)
Validate and save a long integer entry.
static CREATE_ARRAY_DIALOG_ENTRIES s_arrayOptions
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
@ DEGREES_T
Definition eda_angle.h:31
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
Transform applied to an object by this array.
Struct containing the last-entered values for the dialog.
CREATE_ARRAY_DIALOG_ENTRIES()
Construct with some sensible defaults.
Local mapping for list-box <-> numbering type.
ARRAY_AXIS::NUMBERING_TYPE m_numbering_type
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687