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, 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#pragma once
27
28#include <memory>
29#include <utility>
30#include <vector>
31#include <wx/dataview.h>
32#include <wx/event.h>
33#include <wx/string.h>
34#include <board.h>
35#include <zone.h>
36
37class PCB_BASE_FRAME;
38class PCB_BASE_FRAME;
39class MANAGED_ZONE;
40
41wxDECLARE_EVENT( EVT_ZONES_OVERVIEW_COUNT_CHANGE, wxCommandEvent );
42
43#define LAYER_BAR_WIDTH 16
44
45
47{
48 MOVE_UP,
50};
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( std::vector<std::shared_ptr<MANAGED_ZONE>> aZones, BOARD* a_pcb,
77 PCB_BASE_FRAME* aPCB_FRAME, wxWindow* a_dialog );
78
79 ~MODEL_ZONES_OVERVIEW() override = default;
80
81 void EnableFitterByName( bool aEnable );
82
83 void EnableFitterByNet( bool aEnable );
84
85 void GetValueByRow( wxVariant& aVariant, unsigned aRow, unsigned aCol ) const override;
86
87 bool SetValueByRow( const wxVariant& aVariant, unsigned aRow, unsigned aCol ) override;
88
89 // returns the number of rows
90 unsigned int GetCount() const override;
91
92 ZONE* GetZone( wxDataViewItem const& item ) const;
93
94 wxDataViewItem GetItemByZone( ZONE* ) const;
95
101 std::optional<unsigned> MoveZoneIndex( unsigned aIndex, ZONE_INDEX_MOVEMENT aMovement );
102
108 std::optional<unsigned> SwapZonePriority( unsigned aDragIndex, unsigned aDropIndex );
109
117 wxDataViewItem ApplyFilter( wxString const& aFilterText, wxDataViewItem aSelection );
118
125 wxDataViewItem ClearFilter( wxDataViewItem aSelection );
126
127 unsigned int GetAllZonesCount() const { return m_allZones.size(); }
128
129private:
130 void SortZoneContainers();
131
132 void OnRowCountChange();
133
134private:
135 std::vector<std::shared_ptr<MANAGED_ZONE>> m_allZones;
136 std::vector<std::shared_ptr<MANAGED_ZONE>> m_filteredZones;
139 wxWindow* m_dialog;
142};
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
Workaround to keep the original priorities if user didn't change any.
Definition: managed_zone.h:38
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
unsigned int GetAllZonesCount() const
wxDataViewItem ClearFilter(wxDataViewItem aSelection)
Clear up the filter.
ZONE * GetZone(wxDataViewItem const &item) const
wxDataViewItem GetItemByZone(ZONE *) const
std::vector< std::shared_ptr< MANAGED_ZONE > > m_allZones
PCB_BASE_FRAME * m_PCB_FRAME
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.
std::vector< std::shared_ptr< MANAGED_ZONE > > m_filteredZones
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Handle a list of polygons defining a copper zone.
Definition: zone.h:74
#define _(s)
wxDECLARE_EVENT(EVT_ZONES_OVERVIEW_COUNT_CHANGE, wxCommandEvent)
ZONE_INDEX_MOVEMENT