KiCad PCB EDA Suite
panel_prev_3d.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 <mrluzeiro@ua.pt>
5  * Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
6  * Copyright (C) 2015-2020 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 
36 #ifndef PANEL_PREV_MODEL_H
37 #define PANEL_PREV_MODEL_H
38 
39 #include "panel_prev_3d_base.h"
40 
41 #include <vector>
42 #include <tool/tools_holder.h>
44 #include <3d_viewer_id.h>
46 
47 // Define min and max parameter values
48 #define MAX_SCALE 10000.0
49 #define MAX_ROTATION 180.0
50 #define MAX_OFFSET 1000.0
51 
52 #define SCALE_INCREMENT_FINE 0.02
53 #define SCALE_INCREMENT 0.1
54 
55 #define ROTATION_INCREMENT 90 // in degrees, for spin button command
56 #define ROTATION_INCREMENT_WHEEL 90 // in degrees, for mouse wheel command
57 #define ROTATION_INCREMENT_WHEEL_FINE 1 // in degrees, for mouse wheel command
58 
59 #define OFFSET_INCREMENT_MM 0.5
60 #define OFFSET_INCREMENT_MM_FINE 0.1
61 
62 #define OFFSET_INCREMENT_MIL 25.0
63 #define OFFSET_INCREMENT_MIL_FINE 5.0
64 
65 
66 // Declared classes to create pointers
67 class WX_INFOBAR;
68 class S3D_CACHE;
69 class FILENAME_RESOLVER;
70 class BOARD;
71 class BOARD_ADAPTER;
72 class FOOTPRINT;
73 
75 {
76 public:
77  PANEL_PREV_3D( 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 
90  BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
91  CAMERA& GetCurrentCamera() override { return m_currentCamera; }
92 
97  void SetSelectedModel( int idx );
98 
103  void UpdateDummyFootprint( bool aRelaodRequired = true );
104 
105 private:
109  void loadCommonSettings();
110 
114  void updateOrientation( wxCommandEvent& event ) override;
115 
116  void onMouseWheelScale( wxMouseEvent& event ) override;
117  void onMouseWheelRot( wxMouseEvent& event ) override;
118  void onMouseWheelOffset( wxMouseEvent& event ) override;
119 
120  void onIncrementRot( wxSpinEvent& event ) override
121  {
122  doIncrementRotation( event, 1.0 );
123  }
124  void onDecrementRot( wxSpinEvent& event ) override
125  {
126  doIncrementRotation( event, -1.0 );
127  }
128  void onIncrementScale( wxSpinEvent& event ) override
129  {
130  doIncrementScale( event, 1.0 );
131  }
132  void onDecrementScale( wxSpinEvent& event ) override
133  {
134  doIncrementScale( event, -1.0 );
135  }
136  void onIncrementOffset( wxSpinEvent& event ) override
137  {
138  doIncrementOffset( event, 1.0 );
139  }
140  void onDecrementOffset( wxSpinEvent& event ) override
141  {
142  doIncrementOffset( event, -1.0 );
143  }
144 
145  void onOpacitySlider( wxCommandEvent& event ) override;
146 
147  void doIncrementScale( wxSpinEvent& aEvent, double aSign );
148  void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
149  void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
150 
151  wxString formatScaleValue( double aValue );
152  wxString formatRotationValue( double aValue );
153  wxString formatOffsetValue( double aValue );
154 
155  void View3DISO( wxCommandEvent& event ) override
156  {
158  m_previewPane->Refresh();
159  }
160 
161  void View3DLeft( wxCommandEvent& event ) override
162  {
164  }
165 
166  void View3DFront( wxCommandEvent& event ) override
167  {
169  }
170 
171  void View3DTop( wxCommandEvent& event ) override
172  {
174  }
175 
176  void View3DUpdate( wxCommandEvent& event ) override
177  {
179  m_previewPane->Refresh();
180  }
181 
182  void View3DRight( wxCommandEvent& event ) override
183  {
185  }
186 
187  void View3DBack( wxCommandEvent& event ) override
188  {
190  }
191 
192  void View3DBottom( wxCommandEvent& event ) override
193  {
195  }
196 
197 private:
203 
206 
207  std::vector<FP_3DMODEL>* m_parentModelList;
209 
211 };
212 
213 #endif // PANEL_PREV_MODEL_H
BOARD_ADAPTER & GetAdapter() override
Definition: panel_prev_3d.h:90
Class PANEL_PREV_3D_BASE.
void View3DRight(wxCommandEvent &event) override
void onOpacitySlider(wxCommandEvent &event) override
void onDecrementRot(wxSpinEvent &event) override
void onMouseWheelScale(wxMouseEvent &event) override
void onIncrementOffset(wxSpinEvent &event) override
CAMERA & GetCurrentCamera() override
Definition: panel_prev_3d.h:91
void onMouseWheelOffset(wxMouseEvent &event) override
WX_INFOBAR * m_infobar
EDA_UNITS m_userUnits
Index into m_parentInfoList.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:48
wxString formatRotationValue(double aValue)
void onDecrementScale(wxSpinEvent &event) override
void doIncrementScale(wxSpinEvent &aEvent, double aSign)
std::vector< FP_3DMODEL > * m_parentModelList
Cache for storing the 3D shapes.
Definition: 3d_cache.h:52
void View3DBottom(wxCommandEvent &event) override
void View3DLeft(wxCommandEvent &event) override
void doIncrementRotation(wxSpinEvent &aEvent, double aSign)
wxString formatScaleValue(double aValue)
void UpdateDummyFootprint(bool aRelaodRequired=true)
Copy shapes from the current shape list which are flagged for preview to the copy of footprint that i...
A class used to derive camera objects from.
Definition: camera.h:77
wxString formatOffsetValue(double aValue)
FOOTPRINT * m_dummyFootprint
void doIncrementOffset(wxSpinEvent &aEvent, double aSign)
void View3DTop(wxCommandEvent &event) override
void View3DBack(wxCommandEvent &event) override
void loadCommonSettings()
Load 3D relevant settings from the user configuration.
void OnMenuEvent(wxMenuEvent &aEvent)
The TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu events aren't ...
wxWindow * GetToolCanvas() const override
Canvas access.
Definition: panel_prev_3d.h:88
EDA_3D_CANVAS * m_previewPane
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 View3DUpdate(wxCommandEvent &event) override
void onDecrementOffset(wxSpinEvent &event) override
void onMouseWheelRot(wxMouseEvent &event) override
EDA_UNITS
Definition: eda_units.h:38
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:71
TRACK_BALL m_trackBallCamera
void View3DFront(wxCommandEvent &event) override
Provide an extensible class to resolve 3D model paths.
void updateOrientation(wxCommandEvent &event) override
It will receive the events from editing the fields.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
bool SetView3D(int aKeycode)
Helper function to call view commands.
void onIncrementScale(wxSpinEvent &event) override
void View3DISO(wxCommandEvent &event) override
CAMERA & m_currentCamera
void ReloadRequest(BOARD *aBoard=nullptr, S3D_CACHE *aCachePointer=nullptr)
void ToggleProjection()
Definition: camera.cpp:424
BOARD * m_dummyBoard
PANEL_PREV_3D(wxWindow *aParent, PCB_BASE_FRAME *aFrame, FOOTPRINT *aFootprint, std::vector< FP_3DMODEL > *aParentModelList)
Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:67
Declaration for a track ball camera.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD_ADAPTER m_boardAdapter