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
38// Define min and max parameter values
39#define MAX_SCALE 10000.0
40#define MAX_ROTATION 180.0
41#define MAX_OFFSET 1000.0
42
43#define SCALE_INCREMENT_FINE 0.02
44#define SCALE_INCREMENT 0.1
45
46#define ROTATION_INCREMENT 90 // in degrees
47#define ROTATION_INCREMENT_FINE 1 // in degrees
48
49#define OFFSET_INCREMENT_MM 0.5
50#define OFFSET_INCREMENT_MM_FINE 0.1
51
52#define OFFSET_INCREMENT_MIL 25.0
53#define OFFSET_INCREMENT_MIL_FINE 5.0
54
55
56// Declared classes to create pointers
57class WX_INFOBAR;
58class S3D_CACHE;
60class BOARD;
61class BOARD_ADAPTER;
62class FOOTPRINT;
63
65{
66public:
67 PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRINT* aFootprint,
68 std::vector<FP_3DMODEL>* aParentModelList );
69
71
76 void OnMenuEvent( wxMenuEvent& aEvent );
77
78 wxWindow* GetToolCanvas() const override { return m_previewPane; }
79
80 BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
81 CAMERA& GetCurrentCamera() override { return m_currentCamera; }
82
87 void SetSelectedModel( int idx );
88
93 void UpdateDummyFootprint( bool aRelaodRequired = true );
94
95private:
99 void loadSettings();
100
104 void updateOrientation( wxCommandEvent& event ) override;
105
106 void onMouseWheelScale( wxMouseEvent& event ) override;
107 void onMouseWheelRot( wxMouseEvent& event ) override;
108 void onMouseWheelOffset( wxMouseEvent& event ) override;
109
110 void onIncrementRot( wxSpinEvent& event ) override
111 {
112 doIncrementRotation( event, 1.0 );
113 }
114 void onDecrementRot( wxSpinEvent& event ) override
115 {
116 doIncrementRotation( event, -1.0 );
117 }
118 void onIncrementScale( wxSpinEvent& event ) override
119 {
120 doIncrementScale( event, 1.0 );
121 }
122 void onDecrementScale( wxSpinEvent& event ) override
123 {
124 doIncrementScale( event, -1.0 );
125 }
126 void onIncrementOffset( wxSpinEvent& event ) override
127 {
128 doIncrementOffset( event, 1.0 );
129 }
130 void onDecrementOffset( wxSpinEvent& event ) override
131 {
132 doIncrementOffset( event, -1.0 );
133 }
134
135 void onOpacitySlider( wxCommandEvent& event ) override;
136
137 void doIncrementScale( wxSpinEvent& aEvent, double aSign );
138 void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
139 void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
140
141 void onUnitsChanged( wxCommandEvent& aEvent );
142
143 wxString formatScaleValue( double aValue );
144 wxString formatRotationValue( double aValue );
145 wxString formatOffsetValue( double aValue );
146
147 void View3DISO( wxCommandEvent& event ) override
148 {
150 m_previewPane->Refresh();
151 }
152
153 // turn ON or OFF options to show the board body. If OFF, solder paste, soldermask
154 // and board body are hidden, to allows a good view of the 3D model and its pads.
155 // Useful for 3D model placement
156 void setBodyStyleView( wxCommandEvent& event ) override;
157
158 void View3DLeft( wxCommandEvent& event ) override
159 {
160 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_LEFT );
161 }
162
163 void View3DFront( wxCommandEvent& event ) override
164 {
165 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_FRONT );
166 }
167
168 void View3DTop( wxCommandEvent& event ) override
169 {
170 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_TOP );
171 }
172
173 void View3DUpdate( wxCommandEvent& event ) override
174 {
176 m_previewPane->Refresh();
177 }
178
179 void View3DSettings( wxCommandEvent& event ) override;
180
181 void View3DRight( wxCommandEvent& event ) override
182 {
183 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_RIGHT );
184 }
185
186 void View3DBack( wxCommandEvent& event ) override
187 {
188 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_BACK );
189 }
190
191 void View3DBottom( wxCommandEvent& event ) override
192 {
193 m_previewPane->SetView3D( VIEW3D_TYPE::VIEW3D_BOTTOM );
194 }
195
196private:
203
206
207 std::vector<FP_3DMODEL>* m_parentModelList;
209
214};
215
216#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:282
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.
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.
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
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 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
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75
EDA_UNITS
Definition: eda_units.h:46
Declaration for a track ball camera.