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;
41
42wxDECLARE_EVENT( EVT_ZONES_OVERVIEW_COUNT_CHANGE, wxCommandEvent );
43
44using ZONE_PRIORITY_CONTAINER_LIST = std::vector<std::shared_ptr<ZONE_PRIORITY_CONTAINER>>;
45
47{
48 MOVE_UP,
50};
51
52class MODEL_ZONES_OVERVIEW_TABLE : public wxDataViewVirtualListModel
53{
54public:
55 enum
56 {
60
62 };
63
65 {
68 //NOTE - Prevent the hor scroll bar
71 };
72
73
74 static std::map<int, wxString> GetColumnNames()
75 {
76 //NOTE - Build the column name dynamicly in case the display language changed
77 const std::map<int, wxString> ColNames = std::map<int, wxString>{
78 std::make_pair( NAME, _( "Name" ) ), std::make_pair( NET, _( "Net" ) ),
79 std::make_pair( LAYERS, _( "Layers" ) )
80
81 };
82 return ColNames;
83 }
84
86 PCB_BASE_FRAME* aPCB_FRAME, wxWindow* a_dialog );
87
89
90 void EnableFitterByName( bool aEnable );
91
92 void EnableFitterByNet( bool aEnable );
93
94 void GetValueByRow( wxVariant& aVariant, unsigned aRow, unsigned aCol ) const override;
95
96 bool SetValueByRow( const wxVariant& aVariant, unsigned aRow, unsigned aCol ) override;
97
98 // returns the number of rows
99 unsigned int GetCount() const override;
100
101 ZONE* GetZone( wxDataViewItem const& item ) const;
102
103 wxDataViewItem GetItemByZone( ZONE* ) const;
104
110 std::optional<unsigned> MoveZoneIndex( unsigned aIndex, ZONE_INDEX_MOVEMENT aMovement );
111
117 std::optional<unsigned> SwapZonePriority( unsigned aDragIndex, unsigned aDropIndex );
118
126 wxDataViewItem ApplyFilter( wxString const& aFilterText, wxDataViewItem aSelection );
127
134 wxDataViewItem ClearFilter( wxDataViewItem aSelection );
135
136 unsigned int GetAllZonesCount() const { return m_allZoneContainers.size(); }
137
138private:
139 void SortZoneContainers();
140
141 void OnRowCountChange();
142
143
144private:
149 wxWindow* m_dialog;
152};
153
154#endif
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
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
ZONE * GetZone(wxDataViewItem const &item) const
ZONE_PRIORITY_CONTAINER_LIST m_allZoneContainers
ZONE_PRIORITY_CONTAINER_LIST m_filteredZoneContainers
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.
Workaround to keep the original priorities if user didn't change any.
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
#define _(s)
wxDECLARE_EVENT(EVT_ZONES_OVERVIEW_COUNT_CHANGE, wxCommandEvent)
std::vector< std::shared_ptr< ZONE_PRIORITY_CONTAINER > > ZONE_PRIORITY_CONTAINER_LIST