24#include <wx/dataview.h>
28#include <wx/wupdlock.h>
56 m_isFillingZones(
false ),
57 m_zoneFillComplete(
false ),
61 m_sizerZoneOP->InsertSpacer( m_sizerZoneOP->GetItemCount(), 5 );
72 m_sizerProperties->Add( m_panelZoneProperties, 1, wxEXPAND, 5 );
75 m_sizerPreview->Add( m_zonePreviewNotebook, 1, wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, 5 );
76 m_sizerPreview->Layout();
81 m_viewZonesOverview->AppendIconTextColumn( v, k, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_DEFAULT );
83 m_viewZonesOverview->AppendTextColumn( v, k, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_DEFAULT );
87 m_viewZonesOverview->AssociateModel( m_modelZonesOverview.get() );
88 m_viewZonesOverview->SetLayoutDirection( wxLayout_LeftToRight );
90 m_layerFilter->Clear();
91 m_layerFilter->Append(
_(
"All Layers" ) );
96 for(
ZONE* zone : m_zoneSettingsBag.GetClonedZoneList() )
97 usedLayers |= zone->GetLayerSet();
102 reinterpret_cast<void*
>(
static_cast<intptr_t
>( layer ) ) );
106 m_layerFilter->SetSelection( 0 );
108 m_modelZonesOverview->ApplyFilter( m_filterCtrl->GetValue(), m_viewZonesOverview->GetSelection() );
110 if( m_modelZonesOverview->GetCount() )
111 SelectZoneTableItem( m_modelZonesOverview->GetItem( 0 ) );
114 m_MainBoxSizer->Fit(
this );
115 finishDialogSettings();
117#if wxUSE_DRAG_AND_DROP
118 m_viewZonesOverview->EnableDragSource( wxDF_UNICODETEXT );
119 m_viewZonesOverview->EnableDropTarget( wxDF_UNICODETEXT );
121 int id = m_viewZonesOverview->GetId();
122 Bind( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &DIALOG_ZONE_MANAGER::OnBeginDrag,
this,
id );
123 Bind( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, &DIALOG_ZONE_MANAGER::OnDropPossible,
this,
id );
124 Bind( wxEVT_DATAVIEW_ITEM_DROP, &DIALOG_ZONE_MANAGER::OnDrop,
this,
id );
133 Bind( wxEVT_BOOKCTRL_PAGE_CHANGED,
134 [
this]( wxNotebookEvent& aEvent )
138 m_zonePreviewNotebook->GetId() );
154 long filterInsertPos =
m_filterCtrl->GetInsertionPoint();
177 if( textCtrlHasFocus )
193 if( aEvent.GetKeyCode() == WXK_UP )
197 else if( aEvent.GetKeyCode() == WXK_DOWN )
216 unsigned currentRow = 0;
221 int newRow = (int) currentRow + aDirection;
222 newRow = std::max( 0, std::min( newRow, (
int) count - 1 ) );
224 if( !current.IsOk() || (
unsigned) newRow != currentRow )
257 wxWindowUpdateLocker updateLock(
this );
297 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> filled_zone_to_restore;
298 ZONE* internal_zone = zone;
306 filled_zone_to_restore[layer] = fill;
311 for(
const auto& [ layer, fill ] : filled_zone_to_restore )
312 zone->SetFilledPolysList( layer, *fill );
319#if wxUSE_DRAG_AND_DROP
321void DIALOG_ZONE_MANAGER::OnBeginDrag( wxDataViewEvent& aEvent )
323 wxTextDataObject* obj =
new wxTextDataObject;
324 obj->SetText(
"42" );
325 aEvent.SetDataObject( obj );
326 aEvent.SetDragFlags( wxDrag_AllowMove );
327 const wxDataViewItem it = aEvent.GetItem();
334void DIALOG_ZONE_MANAGER::OnDropPossible( wxDataViewEvent& aEvent )
336 aEvent.SetDropEffect( wxDragMove );
340void DIALOG_ZONE_MANAGER::OnDrop( wxDataViewEvent& aEvent )
342 if( aEvent.GetDataFormat() != wxDF_UNICODETEXT )
351 const wxDataViewItem it = aEvent.GetItem();
362 if( rtn.has_value() )
405 if( !selectedItem.IsOk() )
414 ZONE* originalZone =
nullptr;
418 if( clone.get() == selectedZone )
434 wxString msg = wxString::Format(
_(
"Delete zone '%s'?" ), originalZone->
GetZoneName() );
436 if( !
IsOK(
this, msg ) )
447 selTool->RemoveItemFromSel( originalZone );
452 view->Hide( originalZone,
true );
461 if( !currentFilter.IsEmpty() )
483 std::unordered_map<ZONE*, unsigned> savedPriorities;
486 savedPriorities[zone] = zone->GetAssignedPriority();
492 unsigned newPri = original->GetAssignedPriority();
493 clone->SetAssignedPriority( newPri );
502 for(
auto& [zone, priority] : savedPriorities )
503 zone->SetAssignedPriority( priority );
583 m_filler = std::make_unique<ZONE_FILLER>( board,
nullptr );
584 auto reporter = std::make_unique<WX_PROGRESS_REPORTER>(
this,
_(
"Fill All Zones" ), 5,
PR_CAN_ABORT );
600 const_cast<ZONES&
>( board->
Zones() ) = originalZones;
623 unsigned count = aEvent.GetInt();
628 btn->Enable( count > 1 );
635 const wxObject* sender = aEvent.GetEventObject();
639 else if( aEvent.GetEventObject() ==
m_checkNet )
654 if( !selectedItem.IsOk() )
658 const std::optional<unsigned> new_index =
m_modelZonesOverview->MoveZoneIndex( selectedRow, aMove );
660 if( new_index.has_value() )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
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.
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
std::vector< ZONE * > m_zonesToDelete
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 OnDeleteClick(wxCommandEvent &aEvent) override
void OnLayerFilterChanged(wxCommandEvent &aEvent) override
void OnFilterCtrlSearch(wxCommandEvent &aEvent) override
void OnAutoAssignClick(wxCommandEvent &aEvent) override
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
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
const wxString & GetZoneName() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
PCB_LAYER_ID
A quick note on layer IDs:
std::vector< ZONE * > ZONES
IbisParser parser & reporter
bool AutoAssignZonePriorities(BOARD *aBoard, PROGRESS_REPORTER *aReporter)
Automatically assign zone priorities based on connectivity analysis of overlapping regions.