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 );
111 m_MainBoxSizer->Fit(
this );
112 finishDialogSettings();
114#if wxUSE_DRAG_AND_DROP
115 m_viewZonesOverview->EnableDragSource( wxDF_UNICODETEXT );
116 m_viewZonesOverview->EnableDropTarget( wxDF_UNICODETEXT );
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 );
130 Bind( wxEVT_BOOKCTRL_PAGE_CHANGED,
131 [
this]( wxNotebookEvent& aEvent )
134 SelectZoneOnCanvas( m_panelZoneProperties->GetZone(), m_zonePreviewNotebook->GetCurrentLayer() );
136 m_zonePreviewNotebook->GetId() );
138 m_canvasSelectReady =
true;
170 long filterInsertPos =
m_filterCtrl->GetInsertionPoint();
193 if( textCtrlHasFocus )
209 if( aEvent.GetKeyCode() == WXK_UP )
211 else if( aEvent.GetKeyCode() == WXK_DOWN )
226 unsigned currentRow = 0;
231 int newRow = (int) currentRow + aDirection;
232 newRow = std::max( 0, std::min( newRow, (
int) count - 1 ) );
234 if( !current.IsOk() || (
unsigned) newRow != currentRow )
267 wxWindowUpdateLocker updateLock(
this );
282 if( clone.get() == aClone )
315 appearance->SetLayerVisible( layer,
true );
320 selTool->ClearSelection();
321 selTool->AddItemToSel( originalZone,
true );
324 m_pcbFrame->FocusOnItem( originalZone, layer );
359 std::map<PCB_LAYER_ID, std::shared_ptr<SHAPE_POLY_SET>> filled_zone_to_restore;
360 ZONE* internal_zone = zone;
368 filled_zone_to_restore[layer] = fill;
373 for(
const auto& [ layer, fill ] : filled_zone_to_restore )
374 zone->SetFilledPolysList( layer, *fill );
381#if wxUSE_DRAG_AND_DROP
383void DIALOG_ZONE_MANAGER::OnBeginDrag( wxDataViewEvent& aEvent )
385 wxTextDataObject* obj =
new wxTextDataObject;
386 obj->SetText(
"42" );
387 aEvent.SetDataObject( obj );
388 aEvent.SetDragFlags( wxDrag_AllowMove );
389 const wxDataViewItem it = aEvent.GetItem();
396void DIALOG_ZONE_MANAGER::OnDropPossible( wxDataViewEvent& aEvent )
398 aEvent.SetDropEffect( wxDragMove );
402void DIALOG_ZONE_MANAGER::OnDrop( wxDataViewEvent& aEvent )
404 if( aEvent.GetDataFormat() != wxDF_UNICODETEXT )
413 const wxDataViewItem it = aEvent.GetItem();
424 if( rtn.has_value() )
467 if( !selectedItem.IsOk() )
483 wxString msg = wxString::Format(
_(
"Delete zone '%s'?" ), originalZone->
GetZoneName() );
485 if( !
IsOK(
this, msg ) )
496 selTool->RemoveItemFromSel( originalZone );
501 view->Hide( originalZone,
true );
513 layerFilter =
static_cast<PCB_LAYER_ID>(
reinterpret_cast<intptr_t
>( data ) );
528 if( !currentFilter.IsEmpty() )
550 std::unordered_map<ZONE*, unsigned> savedPriorities;
553 savedPriorities[zone] = zone->GetAssignedPriority();
559 unsigned newPri = original->GetAssignedPriority();
560 clone->SetAssignedPriority( newPri );
568 for(
auto& [zone, priority] : savedPriorities )
569 zone->SetAssignedPriority( priority );
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 );
665 const_cast<ZONES&
>( board->
Zones() ) = originalZones;
688 unsigned count = aEvent.GetInt();
691 btn->Enable( count > 1 );
697 const wxObject* sender = aEvent.GetEventObject();
701 else if( aEvent.GetEventObject() ==
m_checkNet )
719 if( !selectedItem.IsOk() )
723 const std::optional<unsigned> new_index =
m_modelZonesOverview->MoveZoneIndex( selectedRow, aMove );
725 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.