KiCad PCB EDA Suite
Loading...
Searching...
No Matches
appearance_controls_3D.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 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <vector>
24
25#include <gal/color4d.h>
26#include <layer_ids.h>
29#include <tool/tool_action.h>
30#include <wx/intl.h>
31
32
33class BITMAP_TOGGLE;
34class COLOR_SWATCH;
38
39using KIGFX::COLOR4D;
40
41
43{
44public:
45
50 {
51 public:
52 int m_Id;
55
58
59 APPEARANCE_SETTING_3D( const wxString& aLabel, int aId, const wxString& aTooltip ) :
60 m_Id( aId ),
61 m_Visible( true ),
62 m_Spacer( false ),
63 m_Ctl_visibility( nullptr ),
64 m_Ctl_color( nullptr ),
65 m_tooltip( aTooltip ),
66 m_label( aLabel )
67 {
68 }
69
70 APPEARANCE_SETTING_3D( const wxString& aLabel, int aId, const TOOL_ACTION& aAction ) :
71 m_Id( aId ),
72 m_Visible( true ),
73 m_Spacer( false ),
74 m_Ctl_visibility( nullptr ),
75 m_Ctl_color( nullptr ),
76 m_label( aLabel ),
77 m_action( &aAction )
78 {
79 }
80
82 m_Id( -1 ),
83 m_Visible( false ),
84 m_Spacer( true ),
85 m_Ctl_visibility( nullptr ),
86 m_Ctl_color( nullptr )
87 {
88 }
89
90 wxString GetTooltip() const
91 {
92 if( m_tooltip.has_value() )
93 return wxGetTranslation( m_tooltip.value() );
94 else if( m_action.has_value() )
95 return m_action.value()->GetTooltip( true );
96 else
97 return wxEmptyString;
98 }
99
100 wxString GetLabel() const
101 {
102 return wxGetTranslation( m_label );
103 }
104
105 private:
106 wxString m_label;
107
108 std::optional<wxString> m_tooltip;
109 std::optional<const TOOL_ACTION*> m_action;
110 };
111
112 APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent, wxWindow* aFocusOwner );
114
115 // We own at least one list of raw pointers. Don't let the compiler fill in copy c'tors that
116 // will only land us in trouble.
119
120 wxSize GetBestSize() const;
121 void OnDarkModeToggle();
122 void OnLayerVisibilityChanged( int aLayer, bool isVisible );
123
125
126 void UpdateLayerCtls();
127
128 void ApplyLayerPreset( const wxString& aPresetName );
129
130 const wxArrayString& GetLayerPresetsMRU() { return m_presetMRU; }
131
133 std::vector<VIEWPORT3D> GetUserViewports() const;
134
136 void SetUserViewports( std::vector<VIEWPORT3D>& aPresetList );
137
138 void ApplyViewport( const wxString& aPresetName );
139
140 const wxArrayString& GetViewportsMRU() { return m_viewportMRU; }
141
142protected:
143 void OnSetFocus( wxFocusEvent& aEvent ) override;
144 void OnSize( wxSizeEvent& aEvent ) override;
145 void OnLanguageChanged( wxCommandEvent& aEvent );
146
147private:
148 void rebuildControls();
149
150 void rebuildLayers();
151
153
155
157
158 void onColorSwatchChanged( COLOR_SWATCH* aSwatch );
159
160 void updateLayerPresetWidget( const wxString& aName );
161
162 void onLayerPresetChanged( wxCommandEvent& aEvent ) override;
163
164 void doApplyLayerPreset( const wxString& aPresetName );
165
166 void onViewportChanged( wxCommandEvent& aEvent ) override;
167 void onUpdateViewportsCb( wxUpdateUIEvent& aEvent ) override;
168
169 void doApplyViewport( const VIEWPORT3D& aViewport );
170
171 void passOnFocus();
172
173private:
175
177 wxWindow* m_focusOwner;
178
179 std::vector<std::unique_ptr<APPEARANCE_SETTING_3D>> m_layerSettings;
180 std::map<int, APPEARANCE_SETTING_3D*> m_layerSettingsMap;
181
182 wxArrayString m_presetMRU;
183
184 std::map<wxString, VIEWPORT3D> m_viewports;
186 wxArrayString m_viewportMRU;
187
189 wxBoxSizer* m_envOuterSizer;
195};
Container for an appearance setting (can control a layer class, object type, etc.)
APPEARANCE_SETTING_3D(const wxString &aLabel, int aId, const TOOL_ACTION &aAction)
std::optional< const TOOL_ACTION * > m_action
APPEARANCE_SETTING_3D(const wxString &aLabel, int aId, const wxString &aTooltip)
Class APPEARANCE_CONTROLS_3D_BASE.
void OnLanguageChanged(wxCommandEvent &aEvent)
GRID_BITMAP_TOGGLE_RENDERER * m_toggleGridRenderer
void onLayerPresetChanged(wxCommandEvent &aEvent) override
void updateLayerPresetWidget(const wxString &aName)
std::vector< VIEWPORT3D > GetUserViewports() const
Return a list of viewports created by the user.
void ApplyViewport(const wxString &aPresetName)
void onColorSwatchChanged(COLOR_SWATCH *aSwatch)
std::vector< std::unique_ptr< APPEARANCE_SETTING_3D > > m_layerSettings
std::map< int, APPEARANCE_SETTING_3D * > m_layerSettingsMap
static const APPEARANCE_SETTING_3D s_layerSettings[]
Template for object appearance settings.
void doApplyLayerPreset(const wxString &aPresetName)
EDA_3D_VIEWER_FRAME * m_frame
void onUpdateViewportsCb(wxUpdateUIEvent &aEvent) override
const wxArrayString & GetViewportsMRU()
APPEARANCE_CONTROLS_3D & operator=(const APPEARANCE_CONTROLS_3D &)=delete
void OnSetFocus(wxFocusEvent &aEvent) override
void OnLayerVisibilityChanged(int aLayer, bool isVisible)
void OnSize(wxSizeEvent &aEvent) override
void doApplyViewport(const VIEWPORT3D &aViewport)
std::map< wxString, VIEWPORT3D > m_viewports
wxCheckBox * m_cbUseBoardEditorCopperColors
APPEARANCE_CONTROLS_3D(const APPEARANCE_CONTROLS_3D &)=delete
void ApplyLayerPreset(const wxString &aPresetName)
void onViewportChanged(wxCommandEvent &aEvent) override
void SetUserViewports(std::vector< VIEWPORT3D > &aPresetList)
Update the current viewports from those saved in the project file.
const wxArrayString & GetLayerPresetsMRU()
A checkbox control except with custom bitmaps for the checked and unchecked states.
Definition: bitmap_toggle.h:45
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:57
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
A toggle button renderer for a wxGrid, similar to BITMAP_TOGGLE.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Icon provider for the "standard" row indicators, for example in layer selection lists.
Represent a single user action.
Definition: tool_action.h:304