24#include <wx/dataview.h>
28#include <wx/wupdlock.h>
57 m_isFillingZones(
false ),
58 m_zoneFillComplete(
false ),
60 m_canvasSelectReady(
false )
63 m_sizerZoneOP->InsertSpacer( m_sizerZoneOP->GetItemCount(), 5 );
74 m_sizerProperties->Add( m_panelZoneProperties, 1, wxEXPAND, 5 );
77 m_sizerPreview->Add( m_zonePreviewNotebook, 1, wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, 5 );
78 m_sizerPreview->Layout();
83 m_viewZonesOverview->AppendIconTextColumn( v, k, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_DEFAULT );
85 m_viewZonesOverview->AppendTextColumn( v, k, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_DEFAULT );
89 m_viewZonesOverview->AssociateModel( m_modelZonesOverview.get() );
90 m_viewZonesOverview->SetLayoutDirection( wxLayout_LeftToRight );
92 m_layerFilter->Clear();
93 m_layerFilter->Append(
_(
"All Layers" ) );
98 for(
ZONE* zone : m_zoneSettingsBag.GetClonedZoneList() )
99 usedLayers |= zone->GetLayerSet();
104 reinterpret_cast<void*
>(
static_cast<intptr_t
>( layer ) ) );
108 m_layerFilter->SetSelection( 0 );
110 m_modelZonesOverview->ApplyFilter( m_filterCtrl->GetValue(), m_viewZonesOverview->GetSelection() );
112 if( m_modelZonesOverview->GetCount() )
113 SelectZoneTableItem( m_modelZonesOverview->GetItem( 0 ) );
115 m_panelZoneProperties->SetZone(
nullptr );
122 if( m_panelZoneProperties->GetZone() )
123 m_panelZoneProperties->TransferZoneSettingsToWindow();
127 m_MainBoxSizer->Fit(
this );
128 finishDialogSettings();
130#if wxUSE_DRAG_AND_DROP
131 m_viewZonesOverview->EnableDragSource( wxDF_UNICODETEXT );
132 m_viewZonesOverview->EnableDropTarget( wxDF_UNICODETEXT );
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 );
147 wxEVT_BOOKCTRL_PAGE_CHANGED,
148 [
this]( wxNotebookEvent& aEvent )
151 SelectZoneOnCanvas( m_panelZoneProperties->GetZone(), m_zonePreviewNotebook->GetCurrentLayer() );
153 m_zonePreviewNotebook->GetId() );
155 m_canvasSelectReady =
true;
171 long filterInsertPos =
m_filterCtrl->GetInsertionPoint();
194 if( textCtrlHasFocus )
210 if( aEvent.GetKeyCode() == WXK_UP )
212 else if( aEvent.GetKeyCode() == WXK_DOWN )
227 unsigned currentRow = 0;
232 int newRow = (int) currentRow + aDirection;
233 newRow = std::max( 0, std::min( newRow, (
int) count - 1 ) );
235 if( !current.IsOk() || (
unsigned) newRow != currentRow )
268 wxWindowUpdateLocker updateLock(
this );
283 if( clone.get() == aClone )
316 appearance->SetLayerVisible( layer,
true );
321 selTool->ClearSelection();
322 selTool->AddItemToSel( originalZone,
true );
325 m_pcbFrame->FocusOnItem( originalZone, layer );
360 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> filled_zone_to_restore;
361 ZONE* internal_zone = zone;
369 filled_zone_to_restore[layer] = fill;
374 for(
const auto& [ layer, fill ] : filled_zone_to_restore )
375 zone->SetFilledPolysList( layer, *fill );
382#if wxUSE_DRAG_AND_DROP
384void DIALOG_ZONE_MANAGER::OnBeginDrag( wxDataViewEvent& aEvent )
386 wxTextDataObject* obj =
new wxTextDataObject;
387 obj->SetText(
"42" );
388 aEvent.SetDataObject( obj );
389 aEvent.SetDragFlags( wxDrag_AllowMove );
390 const wxDataViewItem it = aEvent.GetItem();
397void DIALOG_ZONE_MANAGER::OnDropPossible( wxDataViewEvent& aEvent )
399 aEvent.SetDropEffect( wxDragMove );
403void DIALOG_ZONE_MANAGER::OnDrop( wxDataViewEvent& aEvent )
405 if( aEvent.GetDataFormat() != wxDF_UNICODETEXT )
414 const wxDataViewItem it = aEvent.GetItem();
425 if( rtn.has_value() )
468 if( !selectedItem.IsOk() )
484 wxString msg = wxString::Format(
_(
"Delete zone '%s'?" ), originalZone->
GetZoneName() );
486 if( !
IsOK(
this, msg ) )
497 selTool->RemoveItemFromSel( originalZone );
502 view->Hide( originalZone,
true );
511 if( !currentFilter.IsEmpty() )
533 std::unordered_map<ZONE*, unsigned> savedPriorities;
536 savedPriorities[zone] = zone->GetAssignedPriority();
542 unsigned newPri = original->GetAssignedPriority();
543 clone->SetAssignedPriority( newPri );
551 for(
auto& [zone, priority] : savedPriorities )
552 zone->SetAssignedPriority( priority );
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 );
648 const_cast<ZONES&
>( board->
Zones() ) = originalZones;
671 unsigned count = aEvent.GetInt();
674 btn->Enable( count > 1 );
680 const wxObject* sender = aEvent.GetEventObject();
684 else if( aEvent.GetEventObject() ==
m_checkNet )
702 if( !selectedItem.IsOk() )
706 const std::optional<unsigned> new_index =
m_modelZonesOverview->MoveZoneIndex( selectedRow, aMove );
708 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
wxCheckBox * m_checkAutoSelect
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
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
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.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
static std::map< int, wxString > GetColumnNames()
Common, abstract interface for edit frames.
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.
PCB_LAYER_ID GetFirstLayer() const
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.