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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef PANEL_PREVIEW_3D_MODEL_H
23#define PANEL_PREVIEW_3D_MODEL_H
24
26
27#include <vector>
28#include <widgets/unit_binder.h>
29#include <tool/tools_holder.h>
31#include <3d_viewer_id.h>
33#include <wx/event.h>
34
35// Define min and max parameter values
36#define MAX_SCALE 10000.0
37#define MAX_ROTATION 180.0
38#define MAX_OFFSET 1000.0
39
40#define SCALE_INCREMENT_FINE 0.02
41#define SCALE_INCREMENT 0.1
42
43#define ROTATION_INCREMENT 90 // in degrees
44#define ROTATION_INCREMENT_FINE 1 // in degrees
45
46#define OFFSET_INCREMENT_MM 0.5
47#define OFFSET_INCREMENT_MM_FINE 0.1
48
49#define OFFSET_INCREMENT_MIL 25.0
50#define OFFSET_INCREMENT_MIL_FINE 5.0
51
52wxDECLARE_EVENT( wxCUSTOM_PANEL_SHOWN_EVENT, wxCommandEvent );
53
54// Declared classes to create pointers
55class WX_INFOBAR;
56class S3D_CACHE;
58class EMBEDDED_FILES;
59class BOARD;
60class BOARD_ADAPTER;
61class FOOTPRINT;
63#if defined(__linux__) || defined(__FreeBSD__)
65#else
67#endif
68
69#define PANEL_PREVIEW_3D_MODEL_ID wxID_HIGHEST + 1244
70
72{
73public:
74 PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRINT* aFootprint,
75 std::vector<FP_3DMODEL>* aParentModelList );
76
78
83 void OnMenuEvent( wxMenuEvent& aEvent );
84
85 wxWindow* GetToolCanvas() const override { return m_previewPane; }
86
89
94 void SetSelectedModel( int idx );
95
100 void UpdateDummyFootprint( bool aRelaodRequired = true );
101
102 void SetEmbeddedFilesDelegate( EMBEDDED_FILES* aDelegate );
103
109
111
112private:
116 void loadSettings();
117
121 void updateOrientation( wxCommandEvent& event ) override;
122
123 void onMouseWheelScale( wxMouseEvent& event ) override;
124 void onMouseWheelRot( wxMouseEvent& event ) override;
125 void onMouseWheelOffset( wxMouseEvent& event ) override;
126
127 void onIncrementRot( wxSpinEvent& event ) override
128 {
129 doIncrementRotation( event, 1.0 );
130 }
131 void onDecrementRot( wxSpinEvent& event ) override
132 {
133 doIncrementRotation( event, -1.0 );
134 }
135 void onIncrementScale( wxSpinEvent& event ) override
136 {
137 doIncrementScale( event, 1.0 );
138 }
139 void onDecrementScale( wxSpinEvent& event ) override
140 {
141 doIncrementScale( event, -1.0 );
142 }
143 void onIncrementOffset( wxSpinEvent& event ) override
144 {
145 doIncrementOffset( event, 1.0 );
146 }
147 void onDecrementOffset( wxSpinEvent& event ) override
148 {
149 doIncrementOffset( event, -1.0 );
150 }
151
152 void onOpacitySlider( wxCommandEvent& event ) override;
153
154 void doIncrementScale( wxSpinEvent& aEvent, double aSign );
155 void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
156 void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
157
158 void onUnitsChanged( wxCommandEvent& aEvent );
159 void onPanelShownEvent( wxCommandEvent& aEvent );
160
161 wxString formatScaleValue( double aValue );
162 wxString formatRotationValue( double aValue );
163 wxString formatOffsetValue( double aValue );
164
165 void evalRotationValue( TEXT_CTRL_EVAL* aRotationControl );
166
167 void View3DISO( wxCommandEvent& event ) override
168 {
169 m_currentCamera.ToggleProjection();
170 m_previewPane->Refresh();
171 }
172
173 // turn ON or OFF options to show the board body. If OFF, solder paste, soldermask
174 // and board body are hidden, to allows a good view of the 3D model and its pads.
175 // Useful for 3D model placement
176 void setBodyStyleView( wxCommandEvent& event ) override;
177
178 void View3DLeft( wxCommandEvent& event ) override
179 {
181 }
182
183 void View3DFront( wxCommandEvent& event ) override
184 {
186 }
187
188 void View3DTop( wxCommandEvent& event ) override
189 {
191 }
192
193 void View3DUpdate( wxCommandEvent& event ) override
194 {
195 m_previewPane->ReloadRequest();
196 m_previewPane->Refresh();
197 }
198
199 void View3DSettings( wxCommandEvent& event ) override;
200
201 void View3DRight( wxCommandEvent& event ) override
202 {
204 }
205
206 void View3DBack( wxCommandEvent& event ) override
207 {
209 }
210
211 void View3DBottom( wxCommandEvent& event ) override
212 {
214 }
215
216 void onModify();
217
219
220private:
227
230
231 std::vector<FP_3DMODEL>* m_parentModelList;
233
237
240
241#if defined(__linux__) || defined(__FreeBSD__)
242 std::unique_ptr<SPNAV_VIEWER_PLUGIN> m_spaceMouse;
243#else
244 std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN> m_spaceMouse;
245#endif
246};
247
248#endif // PANEL_PREVIEW_3D_MODEL_H
@ VIEW3D_BOTTOM
Definition 3d_enums.h:77
Helper class to handle information needed to display 3D board.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
A class used to derive camera objects from.
Definition camera.h:99
Implement a canvas based on a wxGLCanvas.
Provide an extensible class to resolve 3D model paths.
The class that implements the public interface to the SpaceMouse plug-in.
PANEL_PREVIEW_3D_MODEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void View3DTop(wxCommandEvent &event) override
wxString formatOffsetValue(double aValue)
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
void evalRotationValue(TEXT_CTRL_EVAL *aRotationControl)
void onMouseWheelScale(wxMouseEvent &event) override
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS m_initialRender
The 3d viewer Render initial settings (must be saved and restored)
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.
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
PANEL_PREVIEW_3D_MODEL(wxWindow *aParent, PCB_BASE_FRAME *aFrame, FOOTPRINT *aFootprint, std::vector< FP_3DMODEL > *aParentModelList)
FOOTPRINT * GetDummyFootprint() const
Get the dummy footprint that is used for previewing the 3D model.
void onDecrementOffset(wxSpinEvent &event) override
void SetEmbeddedFilesDelegate(EMBEDDED_FILES *aDelegate)
EXTRUDED_3D_BODY * m_extrudedBody
void SetExtrusionTransformMode(EXTRUDED_3D_BODY *aBody)
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
std::unique_ptr< NL_FOOTPRINT_PROPERTIES_PLUGIN > m_spaceMouse
void View3DBottom(wxCommandEvent &event) override
void onDecrementScale(wxSpinEvent &event) override
void onIncrementRot(wxSpinEvent &event) override
void onPanelShownEvent(wxCommandEvent &aEvent)
EMBEDDED_FILES * m_localEmbeddedFiles
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:53
wxTextCtrl wrapper to handle math expression evaluation.
A modified version of the wxInfoBar class that allows us to:
Definition wx_infobar.h:77
EDA_UNITS
Definition eda_units.h:44
wxDECLARE_EVENT(wxCUSTOM_PANEL_SHOWN_EVENT, wxCommandEvent)
Declaration for a track ball camera.