KiCad PCB EDA Suite
Loading...
Searching...
No Matches
model_zones_overview.h
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
22#pragma once
23
24#include <memory>
25#include <utility>
26#include <vector>
27#include <wx/dataview.h>
28#include <wx/event.h>
29#include <wx/string.h>
30#include <board.h>
31#include <zone.h>
32#include <zone_settings_bag.h>
33
34class PCB_BASE_FRAME;
35class PCB_BASE_FRAME;
36class MANAGED_ZONE;
37
38wxDECLARE_EVENT( EVT_ZONES_OVERVIEW_COUNT_CHANGE, wxCommandEvent );
39
40#define LAYER_BAR_WIDTH 16
41#define LAYER_BAR_HEIGHT 16
42
43
51
52
53class MODEL_ZONES_OVERVIEW : public wxDataViewVirtualListModel
54{
55public:
56 enum
57 {
61
63 };
64
65 static std::map<int, wxString> GetColumnNames()
66 {
67 //NOTE - Build the column name dynamicly in case the display language changed
68 const std::map<int, wxString> ColNames = std::map<int, wxString>{
69 std::make_pair( NAME, _( "Name" ) ),
70 std::make_pair( NET, _( "Net" ) ),
71 std::make_pair( LAYERS, _( "Layers" ) )
72 };
73 return ColNames;
74 }
75
76 MODEL_ZONES_OVERVIEW( wxWindow* aParent, PCB_BASE_FRAME* aFrame, ZONE_SETTINGS_BAG& aZoneSettingsBag );
77
78 ~MODEL_ZONES_OVERVIEW() override = default;
79
80 void EnableFitterByName( bool aEnable );
81
82 void EnableFitterByNet( bool aEnable );
83
84 void SetLayerFilter( PCB_LAYER_ID aLayer );
85
86 void GetValueByRow( wxVariant& aVariant, unsigned aRow, unsigned aCol ) const override;
87
88 bool SetValueByRow( const wxVariant& aVariant, unsigned aRow, unsigned aCol ) override;
89
90 // returns the number of rows
91 unsigned int GetCount() const override;
92
93 ZONE* GetZone( wxDataViewItem const& item ) const;
94
95 wxDataViewItem GetItemByZone( ZONE* ) const;
96
102 std::optional<unsigned> MoveZoneIndex( unsigned aIndex, ZONE_INDEX_MOVEMENT aMovement );
103
109 std::optional<unsigned> SwapZonePriority( unsigned aDragIndex, unsigned aDropIndex );
110
118 wxDataViewItem ApplyFilter( wxString const& aFilterText, wxDataViewItem aSelection );
119
126 wxDataViewItem ClearFilter( wxDataViewItem aSelection );
127
128private:
129 void SortFilteredZones();
130
131 void OnRowCountChange();
132
133private:
134 wxWindow* m_parent;
137 std::vector<ZONE*> m_filteredZones;
141};
bool SetValueByRow(const wxVariant &aVariant, unsigned aRow, unsigned aCol) override
void EnableFitterByNet(bool aEnable)
static std::map< int, wxString > GetColumnNames()
void GetValueByRow(wxVariant &aVariant, unsigned aRow, unsigned aCol) const override
std::optional< unsigned > SwapZonePriority(unsigned aDragIndex, unsigned aDropIndex)
Swap two zone while drag && drop.
~MODEL_ZONES_OVERVIEW() override=default
MODEL_ZONES_OVERVIEW(wxWindow *aParent, PCB_BASE_FRAME *aFrame, ZONE_SETTINGS_BAG &aZoneSettingsBag)
wxDataViewItem ClearFilter(wxDataViewItem aSelection)
Clear up the filter.
void SetLayerFilter(PCB_LAYER_ID aLayer)
ZONE * GetZone(wxDataViewItem const &item) const
wxDataViewItem GetItemByZone(ZONE *) const
std::vector< ZONE * > m_filteredZones
std::optional< unsigned > MoveZoneIndex(unsigned aIndex, ZONE_INDEX_MOVEMENT aMovement)
Move selected zone up/down.
void EnableFitterByName(bool aEnable)
unsigned int GetCount() const override
wxDataViewItem ApplyFilter(wxString const &aFilterText, wxDataViewItem aSelection)
Filter the zones by the filter text.
ZONE_SETTINGS_BAG & m_zoneSettingsBag
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
#define _(s)
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
wxDECLARE_EVENT(EVT_ZONES_OVERVIEW_COUNT_CHANGE, wxCommandEvent)
ZONE_INDEX_MOVEMENT