KiCad PCB EDA Suite
Loading...
Searching...
No Matches
model_zones_overview_table.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 (C) 2023 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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25
26#ifndef MODEL_ZONES_OVERVIEW_TABLE_H
27#define MODEL_ZONES_OVERVIEW_TABLE_H
28
29#include <memory>
30#include <utility>
31#include <vector>
32#include <wx/dataview.h>
33#include <wx/event.h>
34#include <wx/string.h>
35#include <board.h>
36#include <zone.h>
37
38class PCB_BASE_FRAME;
39class PCB_BASE_FRAME;
40class MANAGED_ZONE;
41
42wxDECLARE_EVENT( EVT_ZONES_OVERVIEW_COUNT_CHANGE, wxCommandEvent );
43
44
46{
47 MOVE_UP,
49};
50
51
52class MODEL_ZONES_OVERVIEW_TABLE : public wxDataViewVirtualListModel
53{
54public:
55 enum
56 {
60
62 };
63
65 {
68 };
69
70
71 static std::map<int, wxString> GetColumnNames()
72 {
73 //NOTE - Build the column name dynamicly in case the display language changed
74 const std::map<int, wxString> ColNames = std::map<int, wxString>{
75 std::make_pair( NAME, _( "Name" ) ),
76 std::make_pair( NET, _( "Net" ) ),
77 std::make_pair( LAYERS, _( "Layers" ) )
78 };
79 return ColNames;
80 }
81
82 MODEL_ZONES_OVERVIEW_TABLE( std::vector<std::shared_ptr<MANAGED_ZONE>> aZones, BOARD* a_pcb,
83 PCB_BASE_FRAME* aPCB_FRAME, wxWindow* a_dialog );
84
86
87 void EnableFitterByName( bool aEnable );
88
89 void EnableFitterByNet( bool aEnable );
90
91 void GetValueByRow( wxVariant& aVariant, unsigned aRow, unsigned aCol ) const override;
92
93 bool SetValueByRow( const wxVariant& aVariant, unsigned aRow, unsigned aCol ) override;
94
95 // returns the number of rows
96 unsigned int GetCount() const override;
97
98 ZONE* GetZone( wxDataViewItem const& item ) const;
99
100 wxDataViewItem GetItemByZone( ZONE* ) const;
101
107 std::optional<unsigned> MoveZoneIndex( unsigned aIndex, ZONE_INDEX_MOVEMENT aMovement );
108
114 std::optional<unsigned> SwapZonePriority( unsigned aDragIndex, unsigned aDropIndex );
115
123 wxDataViewItem ApplyFilter( wxString const& aFilterText, wxDataViewItem aSelection );
124
131 wxDataViewItem ClearFilter( wxDataViewItem aSelection );
132
133 unsigned int GetAllZonesCount() const { return m_allZones.size(); }
134
135private:
136 void SortZoneContainers();
137
138 void OnRowCountChange();
139
140private:
141 std::vector<std::shared_ptr<MANAGED_ZONE>> m_allZones;
142 std::vector<std::shared_ptr<MANAGED_ZONE>> m_filteredZones;
145 wxWindow* m_dialog;
148};
149
150#endif
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
Workaround to keep the original priorities if user didn't change any.
Definition: managed_zone.h:38
static std::map< int, wxString > GetColumnNames()
bool SetValueByRow(const wxVariant &aVariant, unsigned aRow, unsigned aCol) override
std::optional< unsigned > MoveZoneIndex(unsigned aIndex, ZONE_INDEX_MOVEMENT aMovement)
Move selected zone up/down.
~MODEL_ZONES_OVERVIEW_TABLE() override
wxDataViewItem ApplyFilter(wxString const &aFilterText, wxDataViewItem aSelection)
Filter the zones by the filter text.
void GetValueByRow(wxVariant &aVariant, unsigned aRow, unsigned aCol) const override
std::vector< std::shared_ptr< MANAGED_ZONE > > m_filteredZones
ZONE * GetZone(wxDataViewItem const &item) const
std::vector< std::shared_ptr< MANAGED_ZONE > > m_allZones
std::optional< unsigned > SwapZonePriority(unsigned aDragIndex, unsigned aDropIndex)
Swap two zone while drag && drop.
wxDataViewItem GetItemByZone(ZONE *) const
wxDataViewItem ClearFilter(wxDataViewItem aSelection)
Clear up the filter.
unsigned int GetCount() const override
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Handle a list of polygons defining a copper zone.
Definition: zone.h:73
#define _(s)
wxDECLARE_EVENT(EVT_ZONES_OVERVIEW_COUNT_CHANGE, wxCommandEvent)