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 (C) 2024 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef LAYER_PAIRS_H
25#define LAYER_PAIRS_H
26
27#include <memory>
28#include <span>
29#include <string>
30#include <vector>
31#include <optional>
32
33#include <wx/event.h>
34
36
37
38class wxBitmap;
39
40wxDECLARE_EVENT( PCB_LAYER_PAIR_PRESETS_CHANGED, wxCommandEvent );
41wxDECLARE_EVENT( PCB_CURRENT_LAYER_PAIR_CHANGED, wxCommandEvent );
42
46class LAYER_PAIR_SETTINGS: public wxEvtHandler
47{
48public:
54 {
55 }
56
58
59 bool AddLayerPair( LAYER_PAIR_INFO aPair );
60
64 bool RemoveLayerPair( const LAYER_PAIR& aPair );
65
69 std::span<const LAYER_PAIR_INFO> GetLayerPairs() const;
70 std::span<LAYER_PAIR_INFO> GetLayerPairs();
71
78 std::vector<LAYER_PAIR_INFO> GetEnabledLayerPairs( int& aCurrentIndex ) const;
79
85 void SetLayerPairs( std::span<const LAYER_PAIR_INFO> aPairs );
86
87 const LAYER_PAIR& GetCurrentLayerPair() const { return m_currentPair; }
88
92 void SetCurrentLayerPair( const LAYER_PAIR& aPair );
93
94private:
96 bool removeLayerPairInternal( const LAYER_PAIR& aPair );
97
98 // Ordered store of all preset layer pairs
99 std::vector<LAYER_PAIR_INFO> m_pairs;
100
101 // Keep track of the last manual pair (set, but not a preset)
102 // for quick switching back
103 std::optional<LAYER_PAIR> m_lastManualPair;
104
106};
107
108#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:47
std::vector< LAYER_PAIR_INFO > m_pairs
Definition: layer_pairs.h:99
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)
Definition: layer_pairs.cpp:88
bool AddLayerPair(LAYER_PAIR_INFO aPair)
Definition: layer_pairs.cpp:78
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:103
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
Definition: layer_pairs.h:105
bool RemoveLayerPair(const LAYER_PAIR &aPair)
Remove the matching layer pair from the store, if present.
bool addLayerPairInternal(LAYER_PAIR_INFO aPair)
Definition: layer_pairs.cpp:51
LAYER_PAIR_SETTINGS()
Construct a new layer pair manager.
Definition: layer_pairs.h:52
const LAYER_PAIR & GetCurrentLayerPair() const
Definition: layer_pairs.h:87
@ B_Cu
Definition: layer_ids.h:65
@ F_Cu
Definition: layer_ids.h:64
wxDECLARE_EVENT(PCB_LAYER_PAIR_PRESETS_CHANGED, wxCommandEvent)