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 (C) 2023 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#ifndef APPEARANCE_CONTROLS_3D_H
22#define APPEARANCE_CONTROLS_3D_H
23
24#include <vector>
25
26#include <gal/color4d.h>
27#include <layer_ids.h>
30#include <tool/tool_action.h>
31#include <wx/intl.h>
32
33
34class BITMAP_TOGGLE;
35class COLOR_SWATCH;
39
40using KIGFX::COLOR4D;
41
42
44{
45public:
46
51 {
52 public:
53 int m_Id;
56
59
60 APPEARANCE_SETTING_3D( const wxString& aLabel, int aId, const wxString& aTooltip ) :
61 m_Id( aId ),
62 m_Visible( true ),
63 m_Spacer( false ),
64 m_Ctl_visibility( nullptr ),
65 m_Ctl_color( nullptr ),
66 m_tooltip( aTooltip ),
67 m_label( aLabel )
68 {
69 }
70
71 APPEARANCE_SETTING_3D( const wxString& aLabel, int aId, const TOOL_ACTION& aAction ) :
72 m_Id( aId ),
73 m_Visible( true ),
74 m_Spacer( false ),
75 m_Ctl_visibility( nullptr ),
76 m_Ctl_color( nullptr ),
77 m_label( aLabel ),
78 m_action( &aAction )
79 {
80 }
81
83 m_Id( -1 ),
84 m_Visible( false ),
85 m_Spacer( true ),
86 m_Ctl_visibility( nullptr ),
87 m_Ctl_color( nullptr )
88 {
89 }
90
91 wxString GetTooltip() const
92 {
93 if( m_tooltip.has_value() )
94 return wxGetTranslation( m_tooltip.value() );
95 else if( m_action.has_value() )
96 return m_action.value()->GetTooltip( true );
97 else
98 return wxEmptyString;
99 }
100
101 wxString GetLabel() const
102 {
103 return wxGetTranslation( m_label );
104 }
105
106 private:
107 wxString m_label;
108
109 std::optional<wxString> m_tooltip;
110 std::optional<const TOOL_ACTION*> m_action;
111 };
112
113 APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent, wxWindow* aFocusOwner );
115
116 wxSize GetBestSize() const;
117 void OnDarkModeToggle();
118 void OnLayerVisibilityChanged( int aLayer, bool isVisible );
119
121
122 void UpdateLayerCtls();
123
124 void ApplyLayerPreset( const wxString& aPresetName );
125
126 const wxArrayString& GetLayerPresetsMRU() { return m_presetMRU; }
127
129 std::vector<VIEWPORT3D> GetUserViewports() const;
130
132 void SetUserViewports( std::vector<VIEWPORT3D>& aPresetList );
133
134 void ApplyViewport( const wxString& aPresetName );
135
136 const wxArrayString& GetViewportsMRU() { return m_viewportMRU; }
137
138protected:
139 void OnSetFocus( wxFocusEvent& aEvent ) override;
140 void OnSize( wxSizeEvent& aEvent ) override;
141 void OnLanguageChanged( wxCommandEvent& aEvent );
142
143private:
144 void rebuildControls();
145
146 void rebuildLayers();
147
149
151
153
154 void onColorSwatchChanged( COLOR_SWATCH* aSwatch );
155
156 void updateLayerPresetWidget( const wxString& aName );
157
158 void onLayerPresetChanged( wxCommandEvent& aEvent ) override;
159
160 void doApplyLayerPreset( const LAYER_PRESET_3D& aPreset );
161
162 void onViewportChanged( wxCommandEvent& aEvent ) override;
163 void onUpdateViewportsCb( wxUpdateUIEvent& aEvent ) override;
164
165 void doApplyViewport( const VIEWPORT3D& aViewport );
166
167 void passOnFocus();
168
169private:
171
173 wxWindow* m_focusOwner;
174
175 std::vector<std::unique_ptr<APPEARANCE_SETTING_3D>> m_layerSettings;
176 std::map<int, APPEARANCE_SETTING_3D*> m_layerSettingsMap;
177
178 wxArrayString m_presetMRU;
179
180 std::map<wxString, VIEWPORT3D> m_viewports;
182 wxArrayString m_viewportMRU;
183
185 wxBoxSizer* m_envOuterSizer;
190};
191
192#endif
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
Update the current viewports from those saved in the project file.
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 LAYER_PRESET_3D &aPreset)
EDA_3D_VIEWER_FRAME * m_frame
void onUpdateViewportsCb(wxUpdateUIEvent &aEvent) override
const wxArrayString & GetViewportsMRU()
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
void ApplyLayerPreset(const wxString &aPresetName)
void onViewportChanged(wxCommandEvent &aEvent) override
void SetUserViewports(std::vector< VIEWPORT3D > &aPresetList)
const wxArrayString & GetLayerPresetsMRU()
Return a list of viewports created by the user.
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:269