KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_zone_manager.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 (C) 2023 Ethan Chien <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <algorithm>
22#include <memory>
23#include <optional>
24#include <wx/dataview.h>
25#include <wx/debug.h>
26#include <wx/event.h>
27#include <wx/gdicmn.h>
28#include <wx/wupdlock.h>
29#include <pcb_edit_frame.h>
30#include <wx/string.h>
31#include <pcb_draw_panel_gal.h>
32#include <tool/tool_manager.h>
34#include <view/view.h>
38#include <zone.h>
39#include <zone_settings_bag.h>
40#include <board.h>
41#include <bitmaps.h>
42#include <string_utils.h>
43#include <zone_filler.h>
44#include <zone_utils.h>
45
49#include "dialog_zone_manager.h"
50
51
53 DIALOG_ZONE_MANAGER_BASE( aParent ),
54 m_pcbFrame( aParent ),
55 m_zoneSettingsBag( aParent->GetBoard() ),
57 m_isFillingZones( false ),
58 m_zoneFillComplete( false ),
59 m_zonesToDelete(),
60 m_canvasSelectReady( false )
61{
62#ifdef __APPLE__
63 m_sizerZoneOP->InsertSpacer( m_sizerZoneOP->GetItemCount(), 5 );
64#endif
65
66 m_btnMoveTop->SetBitmap( KiBitmapBundle( BITMAPS::small_top ) );
67 m_btnMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
68 m_btnMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
69 m_btnMoveBottom->SetBitmap( KiBitmapBundle( BITMAPS::small_bottom ) );
70 m_btnDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
71 m_btnAutoAssign->SetBitmap( KiBitmapBundle( BITMAPS::small_sort_desc ) );
72
73 m_panelZoneProperties = new PANEL_ZONE_PROPERTIES( m_zonePanel, aParent, m_zoneSettingsBag );
74 m_sizerProperties->Add( m_panelZoneProperties, 1, wxEXPAND, 5 );
75
76 m_zonePreviewNotebook = new ZONE_PREVIEW_NOTEBOOK( m_zonePanel, aParent );
77 m_sizerPreview->Add( m_zonePreviewNotebook, 1, wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, 5 );
78 m_sizerPreview->Layout();
79
80 for( const auto& [k, v] : MODEL_ZONES_OVERVIEW::GetColumnNames() )
81 {
83 m_viewZonesOverview->AppendIconTextColumn( v, k, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_DEFAULT );
84 else
85 m_viewZonesOverview->AppendTextColumn( v, k, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_DEFAULT );
86 }
87
88 m_modelZonesOverview = new MODEL_ZONES_OVERVIEW( this, m_pcbFrame, m_zoneSettingsBag );
89 m_viewZonesOverview->AssociateModel( m_modelZonesOverview.get() );
90 m_viewZonesOverview->SetLayoutDirection( wxLayout_LeftToRight );
91
92 m_layerFilter->Clear();
93 m_layerFilter->Append( _( "All Layers" ) );
94
95 LSET usedLayers;
96 BOARD* board = m_pcbFrame->GetBoard();
97
98 for( ZONE* zone : m_zoneSettingsBag.GetClonedZoneList() )
99 usedLayers |= zone->GetLayerSet();
100
101 for( PCB_LAYER_ID layer : usedLayers.Seq() )
102 {
103 m_layerFilter->Append( board->GetLayerName( layer ),
104 reinterpret_cast<void*>( static_cast<intptr_t>( layer ) ) );
105 }
106
107 m_modelZonesOverview->SetLayerFilter( UNDEFINED_LAYER );
108 m_layerFilter->SetSelection( 0 );
109
110 m_modelZonesOverview->ApplyFilter( m_filterCtrl->GetValue(), m_viewZonesOverview->GetSelection() );
111
112 if( m_modelZonesOverview->GetCount() )
113 SelectZoneTableItem( m_modelZonesOverview->GetItem( 0 ) );
114 else
115 m_panelZoneProperties->SetZone( nullptr );
116
117 // Control values set before the dialog is shown may not render, so re-apply them once
118 // it is on screen (issue 24797).
119 CallAfter(
120 [this]()
121 {
122 if( m_panelZoneProperties->GetZone() )
123 m_panelZoneProperties->TransferZoneSettingsToWindow();
124 } );
125
126 Layout();
127 m_MainBoxSizer->Fit( this );
128 finishDialogSettings();
129
130#if wxUSE_DRAG_AND_DROP
131 m_viewZonesOverview->EnableDragSource( wxDF_UNICODETEXT );
132 m_viewZonesOverview->EnableDropTarget( wxDF_UNICODETEXT );
133
134 int id = m_viewZonesOverview->GetId();
135 Bind( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &DIALOG_ZONE_MANAGER::OnBeginDrag, this, id );
136 Bind( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, &DIALOG_ZONE_MANAGER::OnDropPossible, this, id );
137 Bind( wxEVT_DATAVIEW_ITEM_DROP, &DIALOG_ZONE_MANAGER::OnDrop, this, id );
138#endif // wxUSE_DRAG_AND_DROP
139
140 Bind( EVT_ZONE_NAME_UPDATE, &DIALOG_ZONE_MANAGER::OnZoneNameUpdate, this );
141 Bind( EVT_ZONE_NET_UPDATE, &DIALOG_ZONE_MANAGER::OnZoneNetUpdate, this );
142 Bind( EVT_ZONES_OVERVIEW_COUNT_CHANGE, &DIALOG_ZONE_MANAGER::OnZonesTableRowCountChange, this );
143 Bind( wxEVT_CHECKBOX, &DIALOG_ZONE_MANAGER::OnCheckBoxClicked, this );
144 Bind( wxEVT_IDLE, &DIALOG_ZONE_MANAGER::OnIdle, this );
145 Bind( wxEVT_CHAR_HOOK, &DIALOG_ZONE_MANAGER::OnDialogCharHook, this );
146 Bind(
147 wxEVT_BOOKCTRL_PAGE_CHANGED,
148 [this]( wxNotebookEvent& aEvent )
149 {
150 Layout();
151 SelectZoneOnCanvas( m_panelZoneProperties->GetZone(), m_zonePreviewNotebook->GetCurrentLayer() );
152 },
153 m_zonePreviewNotebook->GetId() );
154
155 m_canvasSelectReady = true;
156}
157
158
160
161
163{
164 return true;
165}
166
167
168void DIALOG_ZONE_MANAGER::PostProcessZoneViewSelChange( wxDataViewItem const& aItem )
169{
170 bool textCtrlHasFocus = m_filterCtrl->HasFocus();
171 long filterInsertPos = m_filterCtrl->GetInsertionPoint();
172
173 if( aItem.IsOk() )
174 {
175 m_viewZonesOverview->Select( aItem );
176 m_viewZonesOverview->EnsureVisible( aItem );
177 SelectZoneTableItem( aItem );
178 }
179 else
180 {
181 if( m_modelZonesOverview->GetCount() )
182 {
183 wxDataViewItem first_item = m_modelZonesOverview->GetItem( 0 );
184 m_viewZonesOverview->Select( first_item );
185 m_viewZonesOverview->EnsureVisible( first_item );
186 m_zonePreviewNotebook->OnZoneSelectionChanged( m_modelZonesOverview->GetZone( first_item ) );
187 }
188 else
189 {
190 m_zonePreviewNotebook->OnZoneSelectionChanged( nullptr );
191 }
192 }
193
194 if( textCtrlHasFocus )
195 {
196 m_filterCtrl->SetFocus();
197 m_filterCtrl->SetInsertionPoint( filterInsertPos );
198 }
199}
200
201
203{
204 aEvent.Skip();
205}
206
207
209{
210 if( aEvent.GetKeyCode() == WXK_UP )
212 else if( aEvent.GetKeyCode() == WXK_DOWN )
214 else
215 aEvent.Skip();
216}
217
218
220{
221 unsigned count = m_modelZonesOverview->GetCount();
222
223 if( count == 0 )
224 return;
225
226 wxDataViewItem current = m_viewZonesOverview->GetSelection();
227 unsigned currentRow = 0;
228
229 if( current.IsOk() )
230 currentRow = m_modelZonesOverview->GetRow( current );
231
232 int newRow = (int) currentRow + aDirection;
233 newRow = std::max( 0, std::min( newRow, (int) count - 1 ) );
234
235 if( !current.IsOk() || (unsigned) newRow != currentRow )
236 PostProcessZoneViewSelChange( m_modelZonesOverview->GetItem( (unsigned) newRow ) );
237}
238
239
240void DIALOG_ZONE_MANAGER::OnTableChar( wxKeyEvent& aEvent )
241{
242 GenericProcessChar( aEvent );
243}
244
245
246void DIALOG_ZONE_MANAGER::OnTableCharHook( wxKeyEvent& aEvent )
247{
248 GenericProcessChar( aEvent );
249}
250
251
252void DIALOG_ZONE_MANAGER::OnIdle( wxIdleEvent& aEvent )
253{
254 WXUNUSED( aEvent )
255 m_viewZonesOverview->SetFocus();
256 Unbind( wxEVT_IDLE, &DIALOG_ZONE_MANAGER::OnIdle, this );
257}
258
259
260void DIALOG_ZONE_MANAGER::onDialogResize( wxSizeEvent& event )
261{
262 event.Skip();
263}
264
265
267{
268 wxWindowUpdateLocker updateLock( this );
269
270 m_panelZoneProperties->SetZone( zone );
271 m_zonePreviewNotebook->OnZoneSelectionChanged( zone );
272
273 Layout();
274
275 SelectZoneOnCanvas( zone );
276}
277
278
280{
281 for( const auto& [orig, clone] : m_zoneSettingsBag.GetZonesCloneMap() )
282 {
283 if( clone.get() == aClone )
284 return orig;
285 }
286
287 return nullptr;
288}
289
290
292{
293 if( !m_canvasSelectReady || !m_checkAutoSelect->IsChecked() || !aClone )
294 return;
295
296 ZONE* originalZone = GetOriginalZone( aClone );
297
298 if( !originalZone )
299 return;
300
301 PCB_LAYER_ID layer = aLayer;
302
303 if( layer == UNDEFINED_LAYER || !originalZone->GetLayerSet().Contains( layer ) )
304 {
305 layer = m_pcbFrame->GetActiveLayer();
306
307 if( !originalZone->GetLayerSet().Contains( layer ) )
308 layer = originalZone->GetFirstLayer();
309 }
310
311 m_pcbFrame->SetActiveLayer( layer );
312
313 if( PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_pcbFrame ) )
314 {
315 if( APPEARANCE_CONTROLS* appearance = editFrame->GetAppearancePanel() )
316 appearance->SetLayerVisible( layer, true );
317 }
318
319 if( PCB_SELECTION_TOOL* selTool = m_pcbFrame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>() )
320 {
321 selTool->ClearSelection();
322 selTool->AddItemToSel( originalZone, true );
323 }
324
325 m_pcbFrame->FocusOnItem( originalZone, layer );
326}
327
328
330{
331 Bind( wxEVT_IDLE, &DIALOG_ZONE_MANAGER::OnIdle, this );
332}
333
334
336{
337 SelectZoneTableItem( aEvent.GetItem() );
338}
339
340
341void DIALOG_ZONE_MANAGER::SelectZoneTableItem( wxDataViewItem const& aItem )
342{
343 ZONE* zone = m_modelZonesOverview->GetZone( aItem );
344
345 if( !zone )
346 return;
347
349}
350
351
352void DIALOG_ZONE_MANAGER::OnOk( wxCommandEvent& aEvt )
353{
354 m_panelZoneProperties->TransferZoneSettingsFromWindow();
355
356 m_zoneSettingsBag.UpdateClonedZones();
357
358 for( const auto& [ zone, zoneClone ] : m_zoneSettingsBag.GetZonesCloneMap() )
359 {
360 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> filled_zone_to_restore;
361 ZONE* internal_zone = zone; // Duplicate the zone pointer to allow capture on older MacOS (13)
362
363 zone->GetLayerSet().RunOnLayers(
364 [&]( PCB_LAYER_ID layer )
365 {
366 std::shared_ptr<SHAPE_POLY_SET> fill = internal_zone->GetFilledPolysList( layer );
367
368 if( fill )
369 filled_zone_to_restore[layer] = fill;
370 } );
371
372 *zone = *zoneClone;
373
374 for( const auto& [ layer, fill ] : filled_zone_to_restore )
375 zone->SetFilledPolysList( layer, *fill );
376 }
377
378 aEvt.Skip();
379}
380
381
382#if wxUSE_DRAG_AND_DROP
383
384void DIALOG_ZONE_MANAGER::OnBeginDrag( wxDataViewEvent& aEvent )
385{
386 wxTextDataObject* obj = new wxTextDataObject;
387 obj->SetText( "42" ); //FIXME - Workaround for drop on GTK
388 aEvent.SetDataObject( obj );
389 aEvent.SetDragFlags( wxDrag_AllowMove );
390 const wxDataViewItem it = aEvent.GetItem();
391
392 if( it.IsOk() )
394}
395
396
397void DIALOG_ZONE_MANAGER::OnDropPossible( wxDataViewEvent& aEvent )
398{
399 aEvent.SetDropEffect( wxDragMove ); // check 'move' drop effect
400}
401
402
403void DIALOG_ZONE_MANAGER::OnDrop( wxDataViewEvent& aEvent )
404{
405 if( aEvent.GetDataFormat() != wxDF_UNICODETEXT )
406 {
407 aEvent.Veto();
408 return;
409 }
410
411 if( !m_priorityDragIndex.has_value() )
412 return;
413
414 const wxDataViewItem it = aEvent.GetItem();
415
416 if( !it.IsOk() )
417 {
418 aEvent.Veto();
419 return;
420 }
421
422 unsigned int drop_index = m_modelZonesOverview->GetRow( it );
423 const std::optional<unsigned> rtn = m_modelZonesOverview->SwapZonePriority( *m_priorityDragIndex, drop_index );
424
425 if( rtn.has_value() )
426 {
427 const wxDataViewItem item = m_modelZonesOverview->GetItem( *rtn );
428
429 if( item.IsOk() )
430 m_viewZonesOverview->Select( item );
431 }
432}
433
434#endif // wxUSE_DRAG_AND_DROP
435
436
441
442
447
448
453
454
459
460
461void DIALOG_ZONE_MANAGER::OnDeleteClick( wxCommandEvent& aEvent )
462{
463 if( !m_viewZonesOverview->HasSelection() )
464 return;
465
466 const wxDataViewItem selectedItem = m_viewZonesOverview->GetSelection();
467
468 if( !selectedItem.IsOk() )
469 return;
470
471 ZONE* selectedZone = m_modelZonesOverview->GetZone( selectedItem );
472
473 if( !selectedZone )
474 return;
475
476 ZONE* originalZone = GetOriginalZone( selectedZone );
477
478 if( !originalZone )
479 return;
480
481 if( std::find( m_zonesToDelete.begin(), m_zonesToDelete.end(), originalZone ) != m_zonesToDelete.end() )
482 return;
483
484 wxString msg = wxString::Format( _( "Delete zone '%s'?" ), originalZone->GetZoneName() );
485
486 if( !IsOK( this, msg ) )
487 return;
488
489 m_zonesToDelete.push_back( originalZone );
490
491 m_zoneSettingsBag.RemoveZone( originalZone );
492
493 if( originalZone->IsSelected() )
494 {
495 if( PCB_SELECTION_TOOL* selTool = m_pcbFrame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>() )
496 {
497 selTool->RemoveItemFromSel( originalZone );
498 }
499 }
500
501 if( KIGFX::VIEW* view = m_pcbFrame->GetCanvas()->GetView() )
502 view->Hide( originalZone, true );
503
504 m_pcbFrame->GetCanvas()->Refresh();
505
506 wxString currentFilter = m_filterCtrl->GetValue();
507
509 m_viewZonesOverview->AssociateModel( m_modelZonesOverview.get() );
510
511 if( !currentFilter.IsEmpty() )
512 m_modelZonesOverview->ApplyFilter( currentFilter, wxDataViewItem() );
513
514 if( m_modelZonesOverview->GetCount() > 0 )
515 {
516 wxDataViewItem firstItem = m_modelZonesOverview->GetItem( 0 );
517 PostProcessZoneViewSelChange( firstItem );
518 }
519 else
520 {
521 m_zonePreviewNotebook->OnZoneSelectionChanged( nullptr );
522 m_panelZoneProperties->SetZone( nullptr );
523 }
524}
525
526
527void DIALOG_ZONE_MANAGER::OnAutoAssignClick( wxCommandEvent& aEvent )
528{
529 BOARD* board = m_pcbFrame->GetBoard();
530
531 // Save original priorities so we can restore them after copying to clones.
532 // The dialog operates on clones; originals must stay untouched until OnOk.
533 std::unordered_map<ZONE*, unsigned> savedPriorities;
534
535 for( ZONE* zone : board->Zones() )
536 savedPriorities[zone] = zone->GetAssignedPriority();
537
538 if( AutoAssignZonePriorities( board ) )
539 {
540 for( auto& [original, clone] : m_zoneSettingsBag.GetZonesCloneMap() )
541 {
542 unsigned newPri = original->GetAssignedPriority();
543 clone->SetAssignedPriority( newPri );
544 m_zoneSettingsBag.SetZonePriority( clone.get(), newPri );
545 }
546
548 m_viewZonesOverview->GetSelection() ) );
549 }
550
551 for( auto& [zone, priority] : savedPriorities )
552 zone->SetAssignedPriority( priority );
553}
554
555
556void DIALOG_ZONE_MANAGER::OnFilterCtrlCancel( wxCommandEvent& aEvent )
557{
559 aEvent.Skip();
560}
561
562
563void DIALOG_ZONE_MANAGER::OnFilterCtrlSearch( wxCommandEvent& aEvent )
564{
565 PostProcessZoneViewSelChange( m_modelZonesOverview->ApplyFilter( aEvent.GetString(),
566 m_viewZonesOverview->GetSelection() ) );
567 aEvent.Skip();
568}
569
570
572{
573 PostProcessZoneViewSelChange( m_modelZonesOverview->ApplyFilter( aEvent.GetString(),
574 m_viewZonesOverview->GetSelection() ) );
575 aEvent.Skip();
576}
577
578
579void DIALOG_ZONE_MANAGER::OnFilterCtrlEnter( wxCommandEvent& aEvent )
580{
581 PostProcessZoneViewSelChange( m_modelZonesOverview->ApplyFilter( aEvent.GetString(),
582 m_viewZonesOverview->GetSelection() ) );
583 aEvent.Skip();
584}
585
586
587void DIALOG_ZONE_MANAGER::OnLayerFilterChanged( wxCommandEvent& aEvent )
588{
589 int sel = m_layerFilter->GetSelection();
590
591 if( sel <= 0 )
592 {
593 m_modelZonesOverview->SetLayerFilter( UNDEFINED_LAYER );
594 }
595 else
596 {
597 void* data = m_layerFilter->GetClientData( sel );
598 PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( reinterpret_cast<intptr_t>( data ) );
599 m_modelZonesOverview->SetLayerFilter( layer );
600 }
601
603 m_viewZonesOverview->GetSelection() ) );
604}
605
606
608{
609 if( m_isFillingZones )
610 return;
611
612 m_isFillingZones = true;
613
614 if( !m_panelZoneProperties->TransferZoneSettingsFromWindow() )
615 {
616 m_isFillingZones = false;
617 return;
618 }
619
620 m_zoneSettingsBag.UpdateClonedZones();
621
622 BOARD* board = m_pcbFrame->GetBoard();
623 board->IncrementTimeStamp();
624
625 // Save the original zones before swapping so we can restore them later
626 ZONES originalZones = board->Zones();
627
628 // Do not use a commit here since we're operating on cloned zones that are not owned by the
629 // board. Using a commit would create undo entries pointing to the clones, which would cause
630 // corruption when the commit is destroyed.
631 m_filler = std::make_unique<ZONE_FILLER>( board, nullptr );
632 auto reporter = std::make_unique<WX_PROGRESS_REPORTER>( this, _( "Fill All Zones" ), 5, PR_CAN_ABORT );
633 m_filler->SetProgressReporter( reporter.get() );
634
635 // TODO: replace these const_cast calls with a different solution that avoids mutating the
636 // container of the board. This is relatively safe as-is because the original zones list is
637 // swapped back in below, but still should be changed to avoid invalidating the board state
638 // in case this code is refactored to be a non-modal dialog in the future.
639 const_cast<ZONES&>( board->Zones() ) = m_zoneSettingsBag.GetClonedZoneList();
640
641 m_zoneFillComplete = m_filler->Fill( board->Zones() );
642 board->BuildConnectivity();
643
644 m_zonePreviewNotebook->OnZoneSelectionChanged( m_panelZoneProperties->GetZone() );
645
646 // Restore the original zones. The connectivity MUST be rebuilt to remove stale pointers to
647 // cloned zones in case of a cancel.
648 const_cast<ZONES&>( board->Zones() ) = originalZones;
649 board->BuildConnectivity();
650
651 m_isFillingZones = false;
652}
653
654
655void DIALOG_ZONE_MANAGER::OnZoneNameUpdate( wxCommandEvent& aEvent )
656{
657 if( ZONE* zone = m_panelZoneProperties->GetZone() )
658 m_modelZonesOverview->RowChanged( m_modelZonesOverview->GetRow( m_modelZonesOverview->GetItemByZone( zone ) ) );
659}
660
661
662void DIALOG_ZONE_MANAGER::OnZoneNetUpdate( wxCommandEvent& aEvent )
663{
664 if( ZONE* zone = m_panelZoneProperties->GetZone() )
665 m_modelZonesOverview->RowChanged( m_modelZonesOverview->GetRow( m_modelZonesOverview->GetItemByZone( zone ) ) );
666}
667
668
670{
671 unsigned count = aEvent.GetInt();
672
674 btn->Enable( count > 1 );
675}
676
677
678void DIALOG_ZONE_MANAGER::OnCheckBoxClicked( wxCommandEvent& aEvent )
679{
680 const wxObject* sender = aEvent.GetEventObject();
681
682 if( aEvent.GetEventObject() == m_checkName )
683 m_modelZonesOverview->EnableFitterByName( aEvent.IsChecked() );
684 else if( aEvent.GetEventObject() == m_checkNet )
685 m_modelZonesOverview->EnableFitterByNet( aEvent.IsChecked() );
686
687 if( ( sender == m_checkName || sender == m_checkNet ) && !m_filterCtrl->IsEmpty() )
688 m_modelZonesOverview->ApplyFilter( m_filterCtrl->GetValue(), m_viewZonesOverview->GetSelection() );
689
690 if( sender == m_checkAutoSelect && aEvent.IsChecked() )
691 SelectZoneOnCanvas( m_panelZoneProperties->GetZone(), m_zonePreviewNotebook->GetCurrentLayer() );
692}
693
694
696{
697 if( !m_viewZonesOverview->HasSelection() )
698 return;
699
700 const wxDataViewItem selectedItem = m_viewZonesOverview->GetSelection();
701
702 if( !selectedItem.IsOk() )
703 return;
704
705 const unsigned int selectedRow = m_modelZonesOverview->GetRow( selectedItem );
706 const std::optional<unsigned> new_index = m_modelZonesOverview->MoveZoneIndex( selectedRow, aMove );
707
708 if( new_index.has_value() )
709 {
710 wxDataViewItem new_item = m_modelZonesOverview->GetItem( *new_index );
712 }
713}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
@ small_sort_desc
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
const ZONES & Zones() const
Definition board.h:467
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition board.cpp:364
void IncrementTimeStamp()
Definition board.cpp:446
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition board.cpp:936
DIALOG_ZONE_MANAGER_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Zone Manager"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnZoneNameUpdate(wxCommandEvent &aEvent)
void OnViewZonesOverviewOnLeftUp(wxMouseEvent &aEvent) override
~DIALOG_ZONE_MANAGER() override
void GenericProcessChar(wxKeyEvent &event)
PCB_BASE_FRAME * m_pcbFrame
wxObjectDataPtr< MODEL_ZONES_OVERVIEW > m_modelZonesOverview
PANEL_ZONE_PROPERTIES * m_panelZoneProperties
void OnMoveDownClick(wxCommandEvent &aEvent) override
void PostProcessZoneViewSelChange(wxDataViewItem const &aItem)
std::unique_ptr< ZONE_FILLER > m_filler
void OnMoveTopClick(wxCommandEvent &aEvent) override
void OnTableChar(wxKeyEvent &event) override
void onDialogResize(wxSizeEvent &event) override
void OnMoveUpClick(wxCommandEvent &aEvent) override
void OnDialogCharHook(wxKeyEvent &aEvent)
void OnUpdateDisplayedZonesClick(wxCommandEvent &aEvent) override
void MoveSelectedZonePriority(ZONE_INDEX_MOVEMENT aMove)
ZONE_SETTINGS_BAG m_zoneSettingsBag
void OnDataViewCtrlSelectionChanged(wxDataViewEvent &event) override
std::optional< unsigned > m_priorityDragIndex
void OnTableCharHook(wxKeyEvent &event) override
void OnIdle(wxIdleEvent &aEvent)
void OnZoneNetUpdate(wxCommandEvent &aEvent)
void OnCheckBoxClicked(wxCommandEvent &aEvent)
void OnFilterCtrlTextChange(wxCommandEvent &aEvent) override
ZONE * GetOriginalZone(ZONE *aClone)
void NavigateZoneSelection(int aDirection)
bool TransferDataToWindow() override
ZONE_PREVIEW_NOTEBOOK * m_zonePreviewNotebook
void SelectZoneTableItem(wxDataViewItem const &aItem)
void OnOk(wxCommandEvent &aEvt) override
void OnFilterCtrlCancel(wxCommandEvent &aEvent) override
std::vector< ZONE * > m_zonesToDelete
void OnFilterCtrlEnter(wxCommandEvent &aEvent) override
void OnMoveBottomClick(wxCommandEvent &aEvent) override
void SelectZoneOnCanvas(ZONE *aClone, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
void OnZoneSelectionChanged(ZONE *aZone)
DIALOG_ZONE_MANAGER(PCB_BASE_FRAME *aParent)
void OnZonesTableRowCountChange(wxCommandEvent &aEvent)
void OnDeleteClick(wxCommandEvent &aEvent) override
void OnLayerFilterChanged(wxCommandEvent &aEvent) override
void OnFilterCtrlSearch(wxCommandEvent &aEvent) override
void OnAutoAssignClick(wxCommandEvent &aEvent) override
bool IsSelected() const
Definition eda_item.h:134
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
Definition lset.h:263
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:309
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Definition lset.h:63
static std::map< int, wxString > GetColumnNames()
Common, abstract interface for edit frames.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
The selection tool: currently supports:
A bitmap button widget that behaves like a standard dialog button except with an icon.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition zone.h:692
const wxString & GetZoneName() const
Definition zone.h:160
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition zone.h:133
PCB_LAYER_ID GetFirstLayer() const
Definition zone.cpp:596
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition confirm.cpp:274
#define _(s)
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
ZONE_INDEX_MOVEMENT
std::vector< ZONE * > ZONES
IbisParser parser & reporter
#define PR_CAN_ABORT
bool AutoAssignZonePriorities(BOARD *aBoard, PROGRESS_REPORTER *aReporter)
Automatically assign zone priorities based on connectivity analysis of overlapping regions.