KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_preview_3d_model.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) 2016 Mario Luzeiro <[email protected]>
5 * Copyright (C) 2015 Cirilo Bernardo <[email protected]>
6 * Copyright (C) 2015-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef PANEL_PREVIEW_3D_MODEL_H
27#define PANEL_PREVIEW_3D_MODEL_H
28
30
31#include <vector>
32#include <widgets/unit_binder.h>
33#include <tool/tools_holder.h>
35#include <3d_viewer_id.h>
37#include <wx/event.h>
38
39// Define min and max parameter values
40#define MAX_SCALE 10000.0
41#define MAX_ROTATION 180.0
42#define MAX_OFFSET 1000.0
43
44#define SCALE_INCREMENT_FINE 0.02
45#define SCALE_INCREMENT 0.1
46
47#define ROTATION_INCREMENT 90 // in degrees
48#define ROTATION_INCREMENT_FINE 1 // in degrees
49
50#define OFFSET_INCREMENT_MM 0.5
51#define OFFSET_INCREMENT_MM_FINE 0.1
52
53#define OFFSET_INCREMENT_MIL 25.0
54#define OFFSET_INCREMENT_MIL_FINE 5.0
55
56wxDECLARE_EVENT( wxCUSTOM_PANEL_SHOWN_EVENT, wxCommandEvent );
57
58// Declared classes to create pointers
59class WX_INFOBAR;
60class S3D_CACHE;
62class BOARD;
63class BOARD_ADAPTER;
64class FOOTPRINT;
66
68{
69public:
70 PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRINT* aFootprint,
71 std::vector<FP_3DMODEL>* aParentModelList );
72
74
79 void OnMenuEvent( wxMenuEvent& aEvent );
80
81 wxWindow* GetToolCanvas() const override { return m_previewPane; }
82
83 BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
84 CAMERA& GetCurrentCamera() override { return m_currentCamera; }
85
90 void SetSelectedModel( int idx );
91
96 void UpdateDummyFootprint( bool aRelaodRequired = true );
97
103
104private:
108 void loadSettings();
109
113 void updateOrientation( wxCommandEvent& event ) override;
114
115 void onMouseWheelScale( wxMouseEvent& event ) override;
116 void onMouseWheelRot( wxMouseEvent& event ) override;
117 void onMouseWheelOffset( wxMouseEvent& event ) override;
118
119 void onIncrementRot( wxSpinEvent& event ) override
120 {
121 doIncrementRotation( event, 1.0 );
122 }
123 void onDecrementRot( wxSpinEvent& event ) override
124 {
125 doIncrementRotation( event, -1.0 );
126 }
127 void onIncrementScale( wxSpinEvent& event ) override
128 {
129 doIncrementScale( event, 1.0 );
130 }
131 void onDecrementScale( wxSpinEvent& event ) override
132 {
133 doIncrementScale( event, -1.0 );
134 }
135 void onIncrementOffset( wxSpinEvent& event ) override
136 {
137 doIncrementOffset( event, 1.0 );
138 }
139 void onDecrementOffset( wxSpinEvent& event ) override
140 {
141 doIncrementOffset( event, -1.0 );
142 }
143
144 void onOpacitySlider( wxCommandEvent& event ) override;
145
146 void doIncrementScale( wxSpinEvent& aEvent, double aSign );
147 void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
148 void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
149
150 void onUnitsChanged( wxCommandEvent& aEvent );
151 void onPanelShownEvent( wxCommandEvent& aEvent );
152
153 wxString formatScaleValue( double aValue );
154 wxString formatRotationValue( double aValue );
155 wxString formatOffsetValue( double aValue );
156
157 void View3DISO( wxCommandEvent& event ) override
158 {
160 m_previewPane->Refresh();
161 }
162
163 // turn ON or OFF options to show the board body. If OFF, solder paste, soldermask
164 // and board body are hidden, to allows a good view of the 3D model and its pads.
165 // Useful for 3D model placement
166 void setBodyStyleView( wxCommandEvent& event ) override;
167
168 void View3DLeft( wxCommandEvent& event ) override
169 {
170 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_LEFT );
171 }
172
173 void View3DFront( wxCommandEvent& event ) override
174 {
175 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_FRONT );
176 }
177
178 void View3DTop( wxCommandEvent& event ) override
179 {
180 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_TOP );
181 }
182
183 void View3DUpdate( wxCommandEvent& event ) override
184 {
186 m_previewPane->Refresh();
187 }
188
189 void View3DSettings( wxCommandEvent& event ) override;
190
191 void View3DRight( wxCommandEvent& event ) override
192 {
193 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_RIGHT );
194 }
195
196 void View3DBack( wxCommandEvent& event ) override
197 {
198 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_BACK );
199 }
200
201 void View3DBottom( wxCommandEvent& event ) override
202 {
203 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_BOTTOM );
204 }
205
206 void onModify();
207
208private:
215
218
219 std::vector<FP_3DMODEL>* m_parentModelList;
221
226
228};
229
230#endif // PANEL_PREVIEW_3D_MODEL_H
Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:73
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
A class used to derive camera objects from.
Definition: camera.h:103
void ToggleProjection()
Definition: camera.cpp:559
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
void ReloadRequest(BOARD *aBoard=nullptr, S3D_CACHE *aCachePointer=nullptr)
bool SetView3D(VIEW3D_TYPE aRequestedView)
Select a specific 3D view or operation.
Provide an extensible class to resolve 3D model paths.
The class that implements the public interface to the SpaceMouse plug-in.
Class PANEL_PREVIEW_3D_MODEL_BASE.
void View3DTop(wxCommandEvent &event) override
wxString formatOffsetValue(double aValue)
CAMERA & GetCurrentCamera() override
void onMouseWheelRot(wxMouseEvent &event) override
void View3DSettings(wxCommandEvent &event) override
void onOpacitySlider(wxCommandEvent &event) override
void View3DFront(wxCommandEvent &event) override
void onDecrementRot(wxSpinEvent &event) override
void onIncrementScale(wxSpinEvent &event) override
void setBodyStyleView(wxCommandEvent &event) override
BOARD_ADAPTER & GetAdapter() override
void onMouseWheelScale(wxMouseEvent &event) override
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS m_initialRender
true if the board body is show
void UpdateDummyFootprint(bool aRelaodRequired=true)
Copy shapes from the current shape list which are flagged for preview to the copy of footprint that i...
wxString formatScaleValue(double aValue)
void doIncrementRotation(wxSpinEvent &aEvent, double aSign)
void loadSettings()
Load 3D relevant settings from the user configuration.
NL_FOOTPRINT_PROPERTIES_PLUGIN * m_spaceMouse
void View3DBack(wxCommandEvent &event) override
void OnMenuEvent(wxMenuEvent &aEvent)
The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't ...
void onUnitsChanged(wxCommandEvent &aEvent)
void doIncrementOffset(wxSpinEvent &aEvent, double aSign)
wxWindow * GetToolCanvas() const override
Canvas access.
void onIncrementOffset(wxSpinEvent &event) override
FOOTPRINT * GetDummyFootprint() const
Get the dummy footprint that is used for previewing the 3D model.
void onDecrementOffset(wxSpinEvent &event) override
void doIncrementScale(wxSpinEvent &aEvent, double aSign)
void View3DLeft(wxCommandEvent &event) override
void updateOrientation(wxCommandEvent &event) override
It will receive the events from editing the fields.
void View3DISO(wxCommandEvent &event) override
wxString formatRotationValue(double aValue)
void onMouseWheelOffset(wxMouseEvent &event) override
void View3DBottom(wxCommandEvent &event) override
void onDecrementScale(wxSpinEvent &event) override
void onIncrementRot(wxSpinEvent &event) override
void onPanelShownEvent(wxCommandEvent &aEvent)
void SetSelectedModel(int idx)
Set the currently selected index in the model list so that the scale/rotation/offset controls can be ...
void View3DRight(wxCommandEvent &event) override
std::vector< FP_3DMODEL > * m_parentModelList
void View3DUpdate(wxCommandEvent &event) override
EDA_UNITS m_userUnits
Index into m_parentInfoList.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Cache for storing the 3D shapes.
Definition: 3d_cache.h:55
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:76
EDA_UNITS
Definition: eda_units.h:46
wxDECLARE_EVENT(wxCUSTOM_PANEL_SHOWN_EVENT, wxCommandEvent)
Declaration for a track ball camera.