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#define LAYER_BAR_HEIGHT 16
45
46
52
53
54class MODEL_ZONES_OVERVIEW : public wxDataViewVirtualListModel
55{
56public:
57 enum
58 {
62
64 };
65
66 static std::map<int, wxString> GetColumnNames()
67 {
68 //NOTE - Build the column name dynamicly in case the display language changed
69 const std::map<int, wxString> ColNames = std::map<int, wxString>{
70 std::make_pair( NAME, _( "Name" ) ),
71 std::make_pair( NET, _( "Net" ) ),
72 std::make_pair( LAYERS, _( "Layers" ) )
73 };
74 return ColNames;
75 }
76
77 MODEL_ZONES_OVERVIEW( std::vector<std::shared_ptr<MANAGED_ZONE>> aZones, BOARD* a_pcb,
78 PCB_BASE_FRAME* aPCB_FRAME, wxWindow* a_dialog );
79
80 ~MODEL_ZONES_OVERVIEW() override = default;
81
82 void EnableFitterByName( bool aEnable );
83
84 void EnableFitterByNet( bool aEnable );
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
128 unsigned int GetAllZonesCount() const { return m_allZones.size(); }
129
130private:
131 void SortFilteredZones();
132
133 void OnRowCountChange();
134
135private:
136 std::vector<std::shared_ptr<MANAGED_ZONE>> m_allZones;
137 std::vector<std::shared_ptr<MANAGED_ZONE>> m_filteredZones;
140 wxWindow* m_dialog;
143};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
Workaround to keep the original priorities if user didn't change any.
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
MODEL_ZONES_OVERVIEW(std::vector< std::shared_ptr< MANAGED_ZONE > > aZones, BOARD *a_pcb, PCB_BASE_FRAME *aPCB_FRAME, wxWindow *a_dialog)
wxDataViewItem GetItemByZone(ZONE *) const
std::vector< std::shared_ptr< MANAGED_ZONE > > m_allZones
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