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 Layout();
111 m_MainBoxSizer->Fit( this );
112 finishDialogSettings();
113
114#if wxUSE_DRAG_AND_DROP
115 m_viewZonesOverview->EnableDragSource( wxDF_UNICODETEXT );
116 m_viewZonesOverview->EnableDropTarget( wxDF_UNICODETEXT );
117
118 int id = m_viewZonesOverview->GetId();
119 Bind( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &DIALOG_ZONE_MANAGER::OnBeginDrag, this, id );
120 Bind( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, &DIALOG_ZONE_MANAGER::OnDropPossible, this, id );
121 Bind( wxEVT_DATAVIEW_ITEM_DROP, &DIALOG_ZONE_MANAGER::OnDrop, this, id );
122#endif // wxUSE_DRAG_AND_DROP
123
124 Bind( EVT_ZONE_NAME_UPDATE, &DIALOG_ZONE_MANAGER::OnZoneNameUpdate, this );
125 Bind( EVT_ZONE_NET_UPDATE, &DIALOG_ZONE_MANAGER::OnZoneNetUpdate, this );
126 Bind( EVT_ZONES_OVERVIEW_COUNT_CHANGE, &DIALOG_ZONE_MANAGER::OnZonesTableRowCountChange, this );
127 Bind( wxEVT_CHECKBOX, &DIALOG_ZONE_MANAGER::OnCheckBoxClicked, this );
128 Bind( wxEVT_IDLE, &DIALOG_ZONE_MANAGER::OnIdle, this );
129 Bind( wxEVT_CHAR_HOOK, &DIALOG_ZONE_MANAGER::OnDialogCharHook, this );
130 Bind( wxEVT_BOOKCTRL_PAGE_CHANGED,
131 [this]( wxNotebookEvent& aEvent )
132 {
133 Layout();
134 SelectZoneOnCanvas( m_panelZoneProperties->GetZone(), m_zonePreviewNotebook->GetCurrentLayer() );
135 },
136 m_zonePreviewNotebook->GetId() );
137
138 m_canvasSelectReady = true;
139}
140
141
143
144
146{
147 m_modelZonesOverview->ApplyFilter( m_filterCtrl->GetValue(), m_viewZonesOverview->GetSelection() );
148
149 if( m_modelZonesOverview->GetCount() )
151 else
152 m_panelZoneProperties->SetZone( nullptr );
153
154 // Control values set before the dialog is shown may not render, so re-apply them once
155 // it is on screen (issue 24797).
156 CallAfter(
157 [this]()
158 {
159 if( m_panelZoneProperties->GetZone() )
160 m_panelZoneProperties->TransferZoneSettingsToWindow();
161 } );
162
163 return true;
164}
165
166
167void DIALOG_ZONE_MANAGER::PostProcessZoneViewSelChange( wxDataViewItem const& aItem )
168{
169 bool textCtrlHasFocus = m_filterCtrl->HasFocus();
170 long filterInsertPos = m_filterCtrl->GetInsertionPoint();
171
172 if( aItem.IsOk() )
173 {
174 m_viewZonesOverview->Select( aItem );
175 m_viewZonesOverview->EnsureVisible( aItem );
176 SelectZoneTableItem( aItem );
177 }
178 else
179 {
180 if( m_modelZonesOverview->GetCount() )
181 {
182 wxDataViewItem first_item = m_modelZonesOverview->GetItem( 0 );
183 m_viewZonesOverview->Select( first_item );
184 m_viewZonesOverview->EnsureVisible( first_item );
185 m_zonePreviewNotebook->OnZoneSelectionChanged( m_modelZonesOverview->GetZone( first_item ) );
186 }
187 else
188 {
189 m_zonePreviewNotebook->OnZoneSelectionChanged( nullptr );
190 }
191 }
192
193 if( textCtrlHasFocus )
194 {
195 m_filterCtrl->SetFocus();
196 m_filterCtrl->SetInsertionPoint( filterInsertPos );
197 }
198}
199
200
202{
203 aEvent.Skip();
204}
205
206
208{
209 if( aEvent.GetKeyCode() == WXK_UP )
211 else if( aEvent.GetKeyCode() == WXK_DOWN )
213 else
214 aEvent.Skip();
215}
216
217
219{
220 unsigned count = m_modelZonesOverview->GetCount();
221
222 if( count == 0 )
223 return;
224
225 wxDataViewItem current = m_viewZonesOverview->GetSelection();
226 unsigned currentRow = 0;
227
228 if( current.IsOk() )
229 currentRow = m_modelZonesOverview->GetRow( current );
230
231 int newRow = (int) currentRow + aDirection;
232 newRow = std::max( 0, std::min( newRow, (int) count - 1 ) );
233
234 if( !current.IsOk() || (unsigned) newRow != currentRow )
235 PostProcessZoneViewSelChange( m_modelZonesOverview->GetItem( (unsigned) newRow ) );
236}
237
238
239void DIALOG_ZONE_MANAGER::OnTableChar( wxKeyEvent& aEvent )
240{
241 GenericProcessChar( aEvent );
242}
243
244
245void DIALOG_ZONE_MANAGER::OnTableCharHook( wxKeyEvent& aEvent )
246{
247 GenericProcessChar( aEvent );
248}
249
250
251void DIALOG_ZONE_MANAGER::OnIdle( wxIdleEvent& aEvent )
252{
253 WXUNUSED( aEvent )
254 m_viewZonesOverview->SetFocus();
255 Unbind( wxEVT_IDLE, &DIALOG_ZONE_MANAGER::OnIdle, this );
256}
257
258
259void DIALOG_ZONE_MANAGER::onDialogResize( wxSizeEvent& event )
260{
261 event.Skip();
262}
263
264
266{
267 wxWindowUpdateLocker updateLock( this );
268
269 m_panelZoneProperties->SetZone( zone );
270 m_zonePreviewNotebook->OnZoneSelectionChanged( zone );
271
272 Layout();
273
274 SelectZoneOnCanvas( zone );
275}
276
277
279{
280 for( const auto& [orig, clone] : m_zoneSettingsBag.GetZonesCloneMap() )
281 {
282 if( clone.get() == aClone )
283 return orig;
284 }
285
286 return nullptr;
287}
288
289
291{
292 if( !m_canvasSelectReady || !m_checkAutoSelect->IsChecked() || !aClone )
293 return;
294
295 ZONE* originalZone = GetOriginalZone( aClone );
296
297 if( !originalZone )
298 return;
299
300 PCB_LAYER_ID layer = aLayer;
301
302 if( layer == UNDEFINED_LAYER || !originalZone->GetLayerSet().Contains( layer ) )
303 {
304 layer = m_pcbFrame->GetActiveLayer();
305
306 if( !originalZone->GetLayerSet().Contains( layer ) )
307 layer = originalZone->GetFirstLayer();
308 }
309
310 m_pcbFrame->SetActiveLayer( layer );
311
312 if( PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_pcbFrame ) )
313 {
314 if( APPEARANCE_CONTROLS* appearance = editFrame->GetAppearancePanel() )
315 appearance->SetLayerVisible( layer, true );
316 }
317
318 if( PCB_SELECTION_TOOL* selTool = m_pcbFrame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>() )
319 {
320 selTool->ClearSelection();
321 selTool->AddItemToSel( originalZone, true );
322 }
323
324 m_pcbFrame->FocusOnItem( originalZone, layer );
325}
326
327
329{
330 Bind( wxEVT_IDLE, &DIALOG_ZONE_MANAGER::OnIdle, this );
331}
332
333
335{
336 SelectZoneTableItem( aEvent.GetItem() );
337}
338
339
340void DIALOG_ZONE_MANAGER::SelectZoneTableItem( wxDataViewItem const& aItem )
341{
342 ZONE* zone = m_modelZonesOverview->GetZone( aItem );
343
344 if( !zone )
345 return;
346
348}
349
350
351void DIALOG_ZONE_MANAGER::OnOk( wxCommandEvent& aEvt )
352{
353 m_panelZoneProperties->TransferZoneSettingsFromWindow();
354
355 m_zoneSettingsBag.UpdateClonedZones();
356
357 for( const auto& [ zone, zoneClone ] : m_zoneSettingsBag.GetZonesCloneMap() )
358 {
359 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> filled_zone_to_restore;
360 ZONE* internal_zone = zone; // Duplicate the zone pointer to allow capture on older MacOS (13)
361
362 zone->GetLayerSet().RunOnLayers(
363 [&]( PCB_LAYER_ID layer )
364 {
365 std::shared_ptr<SHAPE_POLY_SET> fill = internal_zone->GetFilledPolysList( layer );
366
367 if( fill )
368 filled_zone_to_restore[layer] = fill;
369 } );
370
371 *zone = *zoneClone;
372
373 for( const auto& [ layer, fill ] : filled_zone_to_restore )
374 zone->SetFilledPolysList( layer, *fill );
375 }
376
377 aEvt.Skip();
378}
379
380
381#if wxUSE_DRAG_AND_DROP
382
383void DIALOG_ZONE_MANAGER::OnBeginDrag( wxDataViewEvent& aEvent )
384{
385 wxTextDataObject* obj = new wxTextDataObject;
386 obj->SetText( "42" ); //FIXME - Workaround for drop on GTK
387 aEvent.SetDataObject( obj );
388 aEvent.SetDragFlags( wxDrag_AllowMove );
389 const wxDataViewItem it = aEvent.GetItem();
390
391 if( it.IsOk() )
393}
394
395
396void DIALOG_ZONE_MANAGER::OnDropPossible( wxDataViewEvent& aEvent )
397{
398 aEvent.SetDropEffect( wxDragMove ); // check 'move' drop effect
399}
400
401
402void DIALOG_ZONE_MANAGER::OnDrop( wxDataViewEvent& aEvent )
403{
404 if( aEvent.GetDataFormat() != wxDF_UNICODETEXT )
405 {
406 aEvent.Veto();
407 return;
408 }
409
410 if( !m_priorityDragIndex.has_value() )
411 return;
412
413 const wxDataViewItem it = aEvent.GetItem();
414
415 if( !it.IsOk() )
416 {
417 aEvent.Veto();
418 return;
419 }
420
421 unsigned int drop_index = m_modelZonesOverview->GetRow( it );
422 const std::optional<unsigned> rtn = m_modelZonesOverview->SwapZonePriority( *m_priorityDragIndex, drop_index );
423
424 if( rtn.has_value() )
425 {
426 const wxDataViewItem item = m_modelZonesOverview->GetItem( *rtn );
427
428 if( item.IsOk() )
429 m_viewZonesOverview->Select( item );
430 }
431}
432
433#endif // wxUSE_DRAG_AND_DROP
434
435
440
441
446
447
452
453
458
459
460void DIALOG_ZONE_MANAGER::OnDeleteClick( wxCommandEvent& aEvent )
461{
462 if( !m_viewZonesOverview->HasSelection() )
463 return;
464
465 const wxDataViewItem selectedItem = m_viewZonesOverview->GetSelection();
466
467 if( !selectedItem.IsOk() )
468 return;
469
470 ZONE* selectedZone = m_modelZonesOverview->GetZone( selectedItem );
471
472 if( !selectedZone )
473 return;
474
475 ZONE* originalZone = GetOriginalZone( selectedZone );
476
477 if( !originalZone )
478 return;
479
480 if( std::find( m_zonesToDelete.begin(), m_zonesToDelete.end(), originalZone ) != m_zonesToDelete.end() )
481 return;
482
483 wxString msg = wxString::Format( _( "Delete zone '%s'?" ), originalZone->GetZoneName() );
484
485 if( !IsOK( this, msg ) )
486 return;
487
488 m_zonesToDelete.push_back( originalZone );
489
490 m_zoneSettingsBag.RemoveZone( originalZone );
491
492 if( originalZone->IsSelected() )
493 {
494 if( PCB_SELECTION_TOOL* selTool = m_pcbFrame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>() )
495 {
496 selTool->RemoveItemFromSel( originalZone );
497 }
498 }
499
500 if( KIGFX::VIEW* view = m_pcbFrame->GetCanvas()->GetView() )
501 view->Hide( originalZone, true );
502
503 m_pcbFrame->GetCanvas()->Refresh();
504
505 wxString currentFilter = m_filterCtrl->GetValue();
506 PCB_LAYER_ID layerFilter = UNDEFINED_LAYER;
507 bool nameFilter = m_checkName->IsChecked();
508 bool netFilter = m_checkNet->IsChecked();
509
510 if( m_layerFilter->GetSelection() >= 0 )
511 {
512 void* data = m_layerFilter->GetClientData( m_layerFilter->GetSelection() );
513 layerFilter = static_cast<PCB_LAYER_ID>( reinterpret_cast<intptr_t>( data ) );
514 }
515
517 m_viewZonesOverview->AssociateModel( m_modelZonesOverview.get() );
518
519 if( layerFilter != UNDEFINED_LAYER )
520 m_modelZonesOverview->SetLayerFilter( layerFilter );
521
522 if( nameFilter )
523 m_modelZonesOverview->EnableFilterByName( true );
524
525 if( netFilter )
526 m_modelZonesOverview->EnableFilterByNet( true );
527
528 if( !currentFilter.IsEmpty() )
529 m_modelZonesOverview->ApplyFilter( currentFilter, wxDataViewItem() );
530
531 if( m_modelZonesOverview->GetCount() > 0 )
532 {
533 wxDataViewItem firstItem = m_modelZonesOverview->GetItem( 0 );
534 PostProcessZoneViewSelChange( firstItem );
535 }
536 else
537 {
538 m_zonePreviewNotebook->OnZoneSelectionChanged( nullptr );
539 m_panelZoneProperties->SetZone( nullptr );
540 }
541}
542
543
544void DIALOG_ZONE_MANAGER::OnAutoAssignClick( wxCommandEvent& aEvent )
545{
546 BOARD* board = m_pcbFrame->GetBoard();
547
548 // Save original priorities so we can restore them after copying to clones.
549 // The dialog operates on clones; originals must stay untouched until OnOk.
550 std::unordered_map<ZONE*, unsigned> savedPriorities;
551
552 for( ZONE* zone : board->Zones() )
553 savedPriorities[zone] = zone->GetAssignedPriority();
554
555 if( AutoAssignZonePriorities( board ) )
556 {
557 for( auto& [original, clone] : m_zoneSettingsBag.GetZonesCloneMap() )
558 {
559 unsigned newPri = original->GetAssignedPriority();
560 clone->SetAssignedPriority( newPri );
561 m_zoneSettingsBag.SetZonePriority( clone.get(), newPri );
562 }
563
565 m_viewZonesOverview->GetSelection() ) );
566 }
567
568 for( auto& [zone, priority] : savedPriorities )
569 zone->SetAssignedPriority( priority );
570}
571
572
573void DIALOG_ZONE_MANAGER::OnFilterCtrlCancel( wxCommandEvent& aEvent )
574{
576 aEvent.Skip();
577}
578
579
580void DIALOG_ZONE_MANAGER::OnFilterCtrlSearch( wxCommandEvent& aEvent )
581{
582 PostProcessZoneViewSelChange( m_modelZonesOverview->ApplyFilter( aEvent.GetString(),
583 m_viewZonesOverview->GetSelection() ) );
584 aEvent.Skip();
585}
586
587
589{
590 PostProcessZoneViewSelChange( m_modelZonesOverview->ApplyFilter( aEvent.GetString(),
591 m_viewZonesOverview->GetSelection() ) );
592 aEvent.Skip();
593}
594
595
596void DIALOG_ZONE_MANAGER::OnFilterCtrlEnter( wxCommandEvent& aEvent )
597{
598 PostProcessZoneViewSelChange( m_modelZonesOverview->ApplyFilter( aEvent.GetString(),
599 m_viewZonesOverview->GetSelection() ) );
600 aEvent.Skip();
601}
602
603
604void DIALOG_ZONE_MANAGER::OnLayerFilterChanged( wxCommandEvent& aEvent )
605{
606 int sel = m_layerFilter->GetSelection();
607
608 if( sel <= 0 )
609 {
610 m_modelZonesOverview->SetLayerFilter( UNDEFINED_LAYER );
611 }
612 else
613 {
614 void* data = m_layerFilter->GetClientData( sel );
615 PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( reinterpret_cast<intptr_t>( data ) );
616 m_modelZonesOverview->SetLayerFilter( layer );
617 }
618
620 m_viewZonesOverview->GetSelection() ) );
621}
622
623
625{
626 if( m_isFillingZones )
627 return;
628
629 m_isFillingZones = true;
630
631 if( !m_panelZoneProperties->TransferZoneSettingsFromWindow() )
632 {
633 m_isFillingZones = false;
634 return;
635 }
636
637 m_zoneSettingsBag.UpdateClonedZones();
638
639 BOARD* board = m_pcbFrame->GetBoard();
640 board->IncrementTimeStamp();
641
642 // Save the original zones before swapping so we can restore them later
643 ZONES originalZones = board->Zones();
644
645 // Do not use a commit here since we're operating on cloned zones that are not owned by the
646 // board. Using a commit would create undo entries pointing to the clones, which would cause
647 // corruption when the commit is destroyed.
648 m_filler = std::make_unique<ZONE_FILLER>( board, nullptr );
649 auto reporter = std::make_unique<WX_PROGRESS_REPORTER>( this, _( "Fill All Zones" ), 5, PR_CAN_ABORT );
650 m_filler->SetProgressReporter( reporter.get() );
651
652 // TODO: replace these const_cast calls with a different solution that avoids mutating the
653 // container of the board. This is relatively safe as-is because the original zones list is
654 // swapped back in below, but still should be changed to avoid invalidating the board state
655 // in case this code is refactored to be a non-modal dialog in the future.
656 const_cast<ZONES&>( board->Zones() ) = m_zoneSettingsBag.GetClonedZoneList();
657
658 m_zoneFillComplete = m_filler->Fill( board->Zones() );
659 board->BuildConnectivity();
660
661 m_zonePreviewNotebook->OnZoneSelectionChanged( m_panelZoneProperties->GetZone() );
662
663 // Restore the original zones. The connectivity MUST be rebuilt to remove stale pointers to
664 // cloned zones in case of a cancel.
665 const_cast<ZONES&>( board->Zones() ) = originalZones;
666 board->BuildConnectivity();
667
668 m_isFillingZones = false;
669}
670
671
672void DIALOG_ZONE_MANAGER::OnZoneNameUpdate( wxCommandEvent& aEvent )
673{
674 if( ZONE* zone = m_panelZoneProperties->GetZone() )
675 m_modelZonesOverview->RowChanged( m_modelZonesOverview->GetRow( m_modelZonesOverview->GetItemByZone( zone ) ) );
676}
677
678
679void DIALOG_ZONE_MANAGER::OnZoneNetUpdate( wxCommandEvent& aEvent )
680{
681 if( ZONE* zone = m_panelZoneProperties->GetZone() )
682 m_modelZonesOverview->RowChanged( m_modelZonesOverview->GetRow( m_modelZonesOverview->GetItemByZone( zone ) ) );
683}
684
685
687{
688 unsigned count = aEvent.GetInt();
689
691 btn->Enable( count > 1 );
692}
693
694
695void DIALOG_ZONE_MANAGER::OnCheckBoxClicked( wxCommandEvent& aEvent )
696{
697 const wxObject* sender = aEvent.GetEventObject();
698
699 if( aEvent.GetEventObject() == m_checkName )
700 m_modelZonesOverview->EnableFilterByName( aEvent.IsChecked() );
701 else if( aEvent.GetEventObject() == m_checkNet )
702 m_modelZonesOverview->EnableFilterByNet( aEvent.IsChecked() );
703
704 if( ( sender == m_checkName || sender == m_checkNet ) && !m_filterCtrl->IsEmpty() )
705 m_modelZonesOverview->ApplyFilter( m_filterCtrl->GetValue(), m_viewZonesOverview->GetSelection() );
706
707 if( sender == m_checkAutoSelect && aEvent.IsChecked() )
708 SelectZoneOnCanvas( m_panelZoneProperties->GetZone(), m_zonePreviewNotebook->GetCurrentLayer() );
709}
710
711
713{
714 if( !m_viewZonesOverview->HasSelection() )
715 return;
716
717 const wxDataViewItem selectedItem = m_viewZonesOverview->GetSelection();
718
719 if( !selectedItem.IsOk() )
720 return;
721
722 const unsigned int selectedRow = m_modelZonesOverview->GetRow( selectedItem );
723 const std::optional<unsigned> new_index = m_modelZonesOverview->MoveZoneIndex( selectedRow, aMove );
724
725 if( new_index.has_value() )
726 {
727 wxDataViewItem new_item = m_modelZonesOverview->GetItem( *new_index );
729 }
730}
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:411
const ZONES & Zones() const
Definition board.h:469
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:369
void IncrementTimeStamp()
Definition board.cpp:448
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition board.cpp:932
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:68
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:275
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:699
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:630
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.