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-2022 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, for spin button command
47#define ROTATION_INCREMENT_WHEEL 90 // in degrees, for mouse wheel command
48#define ROTATION_INCREMENT_WHEEL_FINE 1 // in degrees, for mouse wheel command
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
56
57// Declared classes to create pointers
58class WX_INFOBAR;
59class S3D_CACHE;
61class BOARD;
62class BOARD_ADAPTER;
63class FOOTPRINT;
64
66{
67public:
68 PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRINT* aFootprint,
69 std::vector<FP_3DMODEL>* aParentModelList );
70
72
77 void OnMenuEvent( wxMenuEvent& aEvent );
78
79 wxWindow* GetToolCanvas() const override { return m_previewPane; }
80
81 BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
82 CAMERA& GetCurrentCamera() override { return m_currentCamera; }
83
88 void SetSelectedModel( int idx );
89
94 void UpdateDummyFootprint( bool aRelaodRequired = true );
95
96private:
100 void loadSettings();
101
105 void updateOrientation( wxCommandEvent& event ) override;
106
107 void onMouseWheelScale( wxMouseEvent& event ) override;
108 void onMouseWheelRot( wxMouseEvent& event ) override;
109 void onMouseWheelOffset( wxMouseEvent& event ) override;
110
111 void onIncrementRot( wxSpinEvent& event ) override
112 {
113 doIncrementRotation( event, 1.0 );
114 }
115 void onDecrementRot( wxSpinEvent& event ) override
116 {
117 doIncrementRotation( event, -1.0 );
118 }
119 void onIncrementScale( wxSpinEvent& event ) override
120 {
121 doIncrementScale( event, 1.0 );
122 }
123 void onDecrementScale( wxSpinEvent& event ) override
124 {
125 doIncrementScale( event, -1.0 );
126 }
127 void onIncrementOffset( wxSpinEvent& event ) override
128 {
129 doIncrementOffset( event, 1.0 );
130 }
131 void onDecrementOffset( wxSpinEvent& event ) override
132 {
133 doIncrementOffset( event, -1.0 );
134 }
135
136 void onOpacitySlider( wxCommandEvent& event ) override;
137
138 void updateBoardThickness( wxCommandEvent& event ) override;
139
140 void doIncrementScale( wxSpinEvent& aEvent, double aSign );
141 void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
142 void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
143
144 void onUnitsChanged( wxCommandEvent& aEvent );
145
146 wxString formatScaleValue( double aValue );
147 wxString formatRotationValue( double aValue );
148 wxString formatOffsetValue( double aValue );
149
150 void View3DISO( wxCommandEvent& event ) override
151 {
153 m_previewPane->Refresh();
154 }
155
156 void View3DLeft( wxCommandEvent& event ) override
157 {
159 }
160
161 void View3DFront( wxCommandEvent& event ) override
162 {
164 }
165
166 void View3DTop( wxCommandEvent& event ) override
167 {
169 }
170
171 void View3DUpdate( wxCommandEvent& event ) override
172 {
174 m_previewPane->Refresh();
175 }
176
177 void View3DRight( wxCommandEvent& event ) override
178 {
180 }
181
182 void View3DBack( wxCommandEvent& event ) override
183 {
185 }
186
187 void View3DBottom( wxCommandEvent& event ) override
188 {
190 }
191
192private:
198
201
202 std::vector<FP_3DMODEL>* m_parentModelList;
204
207};
208
209#endif // PANEL_PREVIEW_3D_MODEL_H
@ ID_VIEW3D_BACK
Definition: 3d_viewer_id.h:26
@ ID_VIEW3D_RIGHT
Definition: 3d_viewer_id.h:24
@ ID_VIEW3D_FRONT
Definition: 3d_viewer_id.h:25
@ ID_VIEW3D_TOP
Definition: 3d_viewer_id.h:21
@ ID_VIEW3D_LEFT
Definition: 3d_viewer_id.h:23
@ ID_VIEW3D_BOTTOM
Definition: 3d_viewer_id.h:22
Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:69
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:270
A class used to derive camera objects from.
Definition: camera.h:78
void ToggleProjection()
Definition: camera.cpp:500
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:49
bool SetView3D(int aKeycode)
Helper function to call view commands.
void ReloadRequest(BOARD *aBoard=nullptr, S3D_CACHE *aCachePointer=nullptr)
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 onOpacitySlider(wxCommandEvent &event) override
void View3DFront(wxCommandEvent &event) override
void onDecrementRot(wxSpinEvent &event) override
void onIncrementScale(wxSpinEvent &event) override
BOARD_ADAPTER & GetAdapter() override
void onMouseWheelScale(wxMouseEvent &event) override
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)
UNIT_BINDER m_boardThickness
Index into m_parentInfoList.
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 updateBoardThickness(wxCommandEvent &event) override
void View3DRight(wxCommandEvent &event) override
std::vector< FP_3DMODEL > * m_parentModelList
void View3DUpdate(wxCommandEvent &event) override
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:43
Declaration for a track ball camera.