KiCad PCB EDA Suite
Loading...
Searching...
No Matches
layer_pairs.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef LAYER_PAIRS_H
21#define LAYER_PAIRS_H
22
23#include <memory>
24#include <span>
25#include <string>
26#include <vector>
27#include <optional>
28
29#include <wx/event.h>
30
32
33
34class wxBitmap;
35
36wxDECLARE_EVENT( PCB_LAYER_PAIR_PRESETS_CHANGED, wxCommandEvent );
37wxDECLARE_EVENT( PCB_CURRENT_LAYER_PAIR_CHANGED, wxCommandEvent );
38
42class LAYER_PAIR_SETTINGS: public wxEvtHandler
43{
44public:
52
54
55 bool AddLayerPair( LAYER_PAIR_INFO aPair );
56
60 bool RemoveLayerPair( const LAYER_PAIR& aPair );
61
65 std::span<const LAYER_PAIR_INFO> GetLayerPairs() const;
66 std::span<LAYER_PAIR_INFO> GetLayerPairs();
67
74 std::vector<LAYER_PAIR_INFO> GetEnabledLayerPairs( int& aCurrentIndex ) const;
75
81 void SetLayerPairs( std::span<const LAYER_PAIR_INFO> aPairs );
82
83 const LAYER_PAIR& GetCurrentLayerPair() const { return m_currentPair; }
84
88 void SetCurrentLayerPair( const LAYER_PAIR& aPair );
89
90private:
92 bool removeLayerPairInternal( const LAYER_PAIR& aPair );
93
94 // Ordered store of all preset layer pairs
95 std::vector<LAYER_PAIR_INFO> m_pairs;
96
97 // Keep track of the last manual pair (set, but not a preset)
98 // for quick switching back
99 std::optional<LAYER_PAIR> m_lastManualPair;
100
102};
103
104#endif // LAYER_PAIRS_H
All information about a layer pair as stored in the layer pair store.
Management class for layer pairs in a PCB.
Definition layer_pairs.h:43
std::vector< LAYER_PAIR_INFO > m_pairs
Definition layer_pairs.h:95
std::vector< LAYER_PAIR_INFO > GetEnabledLayerPairs(int &aCurrentIndex) const
Get a vector of all enabled layer pairs, in order.
bool removeLayerPairInternal(const LAYER_PAIR &aPair)
bool AddLayerPair(LAYER_PAIR_INFO aPair)
std::span< const LAYER_PAIR_INFO > GetLayerPairs() const
Returns a span of all stored layer pairs.
std::optional< LAYER_PAIR > m_lastManualPair
Definition layer_pairs.h:99
void SetCurrentLayerPair(const LAYER_PAIR &aPair)
Set the "active" layer pair.
void SetLayerPairs(std::span< const LAYER_PAIR_INFO > aPairs)
Replace the stored layer pairs with the given list.
LAYER_PAIR m_currentPair
bool RemoveLayerPair(const LAYER_PAIR &aPair)
Remove the matching layer pair from the store, if present.
bool addLayerPairInternal(LAYER_PAIR_INFO aPair)
LAYER_PAIR_SETTINGS()
Construct a new layer pair manager.
Definition layer_pairs.h:48
const LAYER_PAIR & GetCurrentLayerPair() const
Definition layer_pairs.h:83
@ B_Cu
Definition layer_ids.h:61
@ F_Cu
Definition layer_ids.h:60
wxDECLARE_EVENT(PCB_LAYER_PAIR_PRESETS_CHANGED, wxCommandEvent)