27#include <wx/dataview.h>
31#include <wx/wupdlock.h>
56 m_isFillingZones(
false ),
57 m_zoneFillComplete(
false )
60 m_sizerZoneOP->InsertSpacer( m_sizerZoneOP->GetItemCount(), 5 );
70 m_sizerProperties->Add( m_panelZoneProperties, 0, wxEXPAND, 5 );
73 m_sizerPreview->Add( m_zonePreviewNotebook, 1, wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, 5 );
78 m_viewZonesOverview->AppendIconTextColumn( v, k, wxDATAVIEW_CELL_INERT, 140 );
80 m_viewZonesOverview->AppendTextColumn( v, k, wxDATAVIEW_CELL_INERT, 160 );
84 m_viewZonesOverview->AssociateModel( m_modelZonesOverview.get() );
85 m_viewZonesOverview->SetLayoutDirection( wxLayout_LeftToRight );
87#if wxUSE_DRAG_AND_DROP
88 m_viewZonesOverview->EnableDragSource( wxDF_UNICODETEXT );
89 m_viewZonesOverview->EnableDropTarget( wxDF_UNICODETEXT );
91 int id = m_viewZonesOverview->GetId();
92 Bind( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &DIALOG_ZONE_MANAGER::OnBeginDrag,
this,
id );
93 Bind( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, &DIALOG_ZONE_MANAGER::OnDropPossible,
this,
id );
94 Bind( wxEVT_DATAVIEW_ITEM_DROP, &DIALOG_ZONE_MANAGER::OnDrop,
this,
id );
103 Bind( wxEVT_BOOKCTRL_PAGE_CHANGED,
104 [
this]( wxNotebookEvent& aEvent )
108 m_zonePreviewNotebook->GetId() );
111 m_MainBoxSizer->Fit(
this );
112 finishDialogSettings();
128 usedLayers |= zone->GetLayerSet();
133 reinterpret_cast<void*
>(
static_cast<intptr_t
>( layer ) ) );
151 long filterInsertPos =
m_filterCtrl->GetInsertionPoint();
174 if( textCtrlHasFocus )
190 if( aEvent.GetKeyCode() == WXK_UP )
194 else if( aEvent.GetKeyCode() == WXK_DOWN )
213 unsigned currentRow = 0;
218 int newRow = (int) currentRow + aDirection;
219 newRow = std::max( 0, std::min( newRow, (
int) count - 1 ) );
221 if( !current.IsOk() || (
unsigned) newRow != currentRow )
254 wxWindowUpdateLocker updateLock(
this );
294 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> filled_zone_to_restore;
295 ZONE* internal_zone = zone;
303 filled_zone_to_restore[layer] = fill;
308 for(
const auto& [ layer, fill ] : filled_zone_to_restore )
309 zone->SetFilledPolysList( layer, *fill );
316#if wxUSE_DRAG_AND_DROP
318void DIALOG_ZONE_MANAGER::OnBeginDrag( wxDataViewEvent& aEvent )
320 wxTextDataObject* obj =
new wxTextDataObject;
321 obj->SetText(
"42" );
322 aEvent.SetDataObject( obj );
323 aEvent.SetDragFlags( wxDrag_AllowMove );
324 const wxDataViewItem it = aEvent.GetItem();
331void DIALOG_ZONE_MANAGER::OnDropPossible( wxDataViewEvent& aEvent )
333 aEvent.SetDropEffect( wxDragMove );
337void DIALOG_ZONE_MANAGER::OnDrop( wxDataViewEvent& aEvent )
339 if( aEvent.GetDataFormat() != wxDF_UNICODETEXT )
348 const wxDataViewItem it = aEvent.GetItem();
359 if( rtn.has_value() )
401 std::unordered_map<ZONE*, unsigned> savedPriorities;
404 savedPriorities[zone] = zone->GetAssignedPriority();
410 unsigned newPri = original->GetAssignedPriority();
411 clone->SetAssignedPriority( newPri );
420 for(
auto& [zone, priority] : savedPriorities )
421 zone->SetAssignedPriority( priority );
501 m_filler = std::make_unique<ZONE_FILLER>( board,
nullptr );
502 auto reporter = std::make_unique<WX_PROGRESS_REPORTER>(
this,
_(
"Fill All Zones" ), 5,
PR_CAN_ABORT );
503 m_filler->SetProgressReporter( reporter.get() );
518 const_cast<ZONES&
>( board->
Zones() ) = originalZones;
541 unsigned count = aEvent.GetInt();
546 btn->Enable( count > 1 );
553 const wxObject* sender = aEvent.GetEventObject();
557 else if( aEvent.GetEventObject() ==
m_checkNet )
572 if( !selectedItem.IsOk() )
576 const std::optional<unsigned> new_index =
m_modelZonesOverview->MoveZoneIndex( selectedRow, aMove );
578 if( new_index.has_value() )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Information pertinent to a Pcbnew printed circuit board.
const ZONES & Zones() const
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
void IncrementTimeStamp()
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
STD_BITMAP_BUTTON * m_btnMoveUp
STD_BITMAP_BUTTON * m_btnAutoAssign
STD_BITMAP_BUTTON * m_btnMoveTop
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)
wxSearchCtrl * m_filterCtrl
wxDataViewCtrl * m_viewZonesOverview
STD_BITMAP_BUTTON * m_btnMoveDown
STD_BITMAP_BUTTON * m_btnMoveBottom
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
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
void OnFilterCtrlEnter(wxCommandEvent &aEvent) override
void OnMoveBottomClick(wxCommandEvent &aEvent) override
void OnZoneSelectionChanged(ZONE *aZone)
DIALOG_ZONE_MANAGER(PCB_BASE_FRAME *aParent)
void OnZonesTableRowCountChange(wxCommandEvent &aEvent)
void OnLayerFilterChanged(wxCommandEvent &aEvent) override
void OnFilterCtrlSearch(wxCommandEvent &aEvent) override
void OnAutoAssignClick(wxCommandEvent &aEvent) override
LSET is a set of PCB_LAYER_IDs.
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static std::map< int, wxString > GetColumnNames()
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Handle a list of polygons defining a copper zone.
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
PCB_LAYER_ID
A quick note on layer IDs:
std::vector< ZONE * > ZONES
bool AutoAssignZonePriorities(BOARD *aBoard, PROGRESS_REPORTER *aReporter)
Automatically assign zone priorities based on connectivity analysis of overlapping regions.