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, 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 EMBEDDED_FILES;
63class BOARD;
64class BOARD_ADAPTER;
65class FOOTPRINT;
66#ifndef __linux__
68#else
70#endif
71
72#define PANEL_PREVIEW_3D_MODEL_ID wxID_HIGHEST + 1244
73
75{
76public:
77 PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRINT* aFootprint,
78 std::vector<FP_3DMODEL>* aParentModelList );
79
81
86 void OnMenuEvent( wxMenuEvent& aEvent );
87
88 wxWindow* GetToolCanvas() const override { return m_previewPane; }
89
92
97 void SetSelectedModel( int idx );
98
103 void UpdateDummyFootprint( bool aRelaodRequired = true );
104
105 void SetEmbeddedFilesDelegate( EMBEDDED_FILES* aDelegate );
106
112
113private:
117 void loadSettings();
118
122 void updateOrientation( wxCommandEvent& event ) override;
123
124 void onMouseWheelScale( wxMouseEvent& event ) override;
125 void onMouseWheelRot( wxMouseEvent& event ) override;
126 void onMouseWheelOffset( wxMouseEvent& event ) override;
127
128 void onIncrementRot( wxSpinEvent& event ) override
129 {
130 doIncrementRotation( event, 1.0 );
131 }
132 void onDecrementRot( wxSpinEvent& event ) override
133 {
134 doIncrementRotation( event, -1.0 );
135 }
136 void onIncrementScale( wxSpinEvent& event ) override
137 {
138 doIncrementScale( event, 1.0 );
139 }
140 void onDecrementScale( wxSpinEvent& event ) override
141 {
142 doIncrementScale( event, -1.0 );
143 }
144 void onIncrementOffset( wxSpinEvent& event ) override
145 {
146 doIncrementOffset( event, 1.0 );
147 }
148 void onDecrementOffset( wxSpinEvent& event ) override
149 {
150 doIncrementOffset( event, -1.0 );
151 }
152
153 void onOpacitySlider( wxCommandEvent& event ) override;
154
155 void doIncrementScale( wxSpinEvent& aEvent, double aSign );
156 void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
157 void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
158
159 void onUnitsChanged( wxCommandEvent& aEvent );
160 void onPanelShownEvent( wxCommandEvent& aEvent );
161
162 wxString formatScaleValue( double aValue );
163 wxString formatRotationValue( double aValue );
164 wxString formatOffsetValue( double aValue );
165
166 void View3DISO( wxCommandEvent& event ) override
167 {
168 m_currentCamera.ToggleProjection();
169 m_previewPane->Refresh();
170 }
171
172 // turn ON or OFF options to show the board body. If OFF, solder paste, soldermask
173 // and board body are hidden, to allows a good view of the 3D model and its pads.
174 // Useful for 3D model placement
175 void setBodyStyleView( wxCommandEvent& event ) override;
176
177 void View3DLeft( wxCommandEvent& event ) override
178 {
180 }
181
182 void View3DFront( wxCommandEvent& event ) override
183 {
185 }
186
187 void View3DTop( wxCommandEvent& event ) override
188 {
190 }
191
192 void View3DUpdate( wxCommandEvent& event ) override
193 {
194 m_previewPane->ReloadRequest();
195 m_previewPane->Refresh();
196 }
197
198 void View3DSettings( wxCommandEvent& event ) override;
199
200 void View3DRight( wxCommandEvent& event ) override
201 {
203 }
204
205 void View3DBack( wxCommandEvent& event ) override
206 {
208 }
209
210 void View3DBottom( wxCommandEvent& event ) override
211 {
213 }
214
215 void onModify();
216
217private:
224
227
228 std::vector<FP_3DMODEL>* m_parentModelList;
230
232
235
236#ifndef __linux__
237 std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN> m_spaceMouse;
238#else
239 std::unique_ptr<SPNAV_VIEWER_PLUGIN> m_spaceMouse;
240#endif
241};
242
243#endif // PANEL_PREVIEW_3D_MODEL_H
@ VIEW3D_BOTTOM
Definition 3d_enums.h:81
Helper class to handle information needed to display 3D board.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
A class used to derive camera objects from.
Definition camera.h:103
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 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)
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)
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:48
wxDECLARE_EVENT(wxCUSTOM_PANEL_SHOWN_EVENT, wxCommandEvent)
Declaration for a track ball camera.