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-2016 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 S3D_CACHE;
68 class FILENAME_RESOLVER;
69 class BOARD;
70 class BOARD_ADAPTER;
71 class MODULE;
72 
74 {
75 public:
76  PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule,
77  std::vector<MODULE_3D_SETTINGS>* aParentModelList );
78 
80 
81 private:
86 
89 
90  std::vector<MODULE_3D_SETTINGS>* m_parentModelList;
91  int m_selected;
92 
94 
95  // Methods of the class
96 private:
100  void loadCommonSettings();
101 
106  void updateOrientation( wxCommandEvent &event ) override;
107 
108  void onMouseWheelScale( wxMouseEvent& event ) override;
109  void onMouseWheelRot( wxMouseEvent& event ) override;
110  void onMouseWheelOffset( wxMouseEvent& event ) override;
111 
112  void onIncrementRot( wxSpinEvent& event ) override
113  {
114  doIncrementRotation( event, 1.0 );
115  }
116  void onDecrementRot( wxSpinEvent& event ) override
117  {
118  doIncrementRotation( event, -1.0 );
119  }
120  void onIncrementScale( wxSpinEvent& event ) override
121  {
122  doIncrementScale( event, 1.0 );
123  }
124  void onDecrementScale( wxSpinEvent& event ) override
125  {
126  doIncrementScale( event, -1.0 );
127  }
128  void onIncrementOffset( wxSpinEvent& event ) override
129  {
130  doIncrementOffset( event, 1.0 );
131  }
132  void onDecrementOffset( wxSpinEvent& event ) override
133  {
134  doIncrementOffset( event, -1.0 );
135  }
136 
137  void onOpacitySlider( wxCommandEvent& event ) override;
138 
139  void doIncrementScale( wxSpinEvent& aEvent, double aSign );
140  void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
141  void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
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  void View3DLeft( wxCommandEvent& event ) override
154  {
156  }
157 
158  void View3DFront( wxCommandEvent& event ) override
159  {
161  }
162 
163  void View3DTop( wxCommandEvent& event ) override
164  {
166  }
167 
168  void View3DUpdate( wxCommandEvent& event ) override
169  {
171  m_previewPane->Refresh();
172  }
173 
174  void View3DRight( wxCommandEvent& event ) override
175  {
177  }
178 
179  void View3DBack( wxCommandEvent& event ) override
180  {
182  }
183 
184  void View3DBottom( wxCommandEvent& event ) override
185  {
187  }
188 
189 public:
194  void OnMenuEvent( wxMenuEvent& aEvent );
195 
196  wxWindow* GetToolCanvas() const override { return m_previewPane; }
197 
198  BOARD_ADAPTER& GetAdapter() override { return m_boardAdapter; }
199  CCAMERA& GetCurrentCamera() override { return m_currentCamera; }
200 
205  void SetSelectedModel( int idx );
206 
211  void UpdateDummyModule( bool aRelaodRequired = true );
212 };
213 
214 #endif // PANEL_PREV_MODEL_H
BOARD_ADAPTER & GetAdapter() override
EDA_UNITS
Definition: common.h:198
Declaration for a track ball camera.
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
Class CCAMERA is a virtual class used to derive CCAMERA objects from.
Definition: ccamera.h:79
void onMouseWheelOffset(wxMouseEvent &event) override
EDA_UNITS m_userUnits
Index into m_parentInfoList.
Definition: panel_prev_3d.h:93
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:47
wxString formatRotationValue(double aValue)
void onDecrementScale(wxSpinEvent &event) override
void UpdateDummyModule(bool aRelaodRequired=true)
UpdateModelInfoList - copy shapes from the current shape list which are flagged for preview to the co...
void doIncrementScale(wxSpinEvent &aEvent, double aSign)
S3D_CACHE.
Definition: 3d_cache.h:54
std::vector< MODULE_3D_SETTINGS > * m_parentModelList
Definition: panel_prev_3d.h:90
void ReloadRequest(BOARD *aBoard=NULL, S3D_CACHE *aCachePointer=NULL)
void View3DBottom(wxCommandEvent &event) override
void View3DLeft(wxCommandEvent &event) override
void doIncrementRotation(wxSpinEvent &aEvent, double aSign)
wxString formatScaleValue(double aValue)
wxString formatOffsetValue(double aValue)
void doIncrementOffset(wxSpinEvent &aEvent, double aSign)
void View3DTop(wxCommandEvent &event) override
void View3DBack(wxCommandEvent &event) override
CCAMERA & m_currentCamera
Definition: panel_prev_3d.h:84
MODULE * m_dummyModule
Definition: panel_prev_3d.h:88
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.
void ToggleProjection()
Definition: ccamera.cpp:437
EDA_3D_CANVAS * m_previewPane
Definition: panel_prev_3d.h:82
void onIncrementRot(wxSpinEvent &event) override
void SetSelectedModel(int idx)
SetModelDataIdx - Sets the currently selected index in the model list so that the scale/rotation/offs...
void View3DUpdate(wxCommandEvent &event) override
void onDecrementOffset(wxSpinEvent &event) override
void onMouseWheelRot(wxMouseEvent &event) override
CTRACK_BALL m_trackBallCamera
Definition: panel_prev_3d.h:85
void View3DFront(wxCommandEvent &event) override
CCAMERA & GetCurrentCamera() override
void updateOrientation(wxCommandEvent &event) override
updateOrientation - it will receive the events from editing the fields
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void onIncrementScale(wxSpinEvent &event) override
void View3DISO(wxCommandEvent &event) override
PANEL_PREV_3D(wxWindow *aParent, PCB_BASE_FRAME *aFrame, MODULE *aModule, std::vector< MODULE_3D_SETTINGS > *aParentModelList)
BOARD * m_dummyBoard
Definition: panel_prev_3d.h:87
Class BOARD_ADAPTER Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:68
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD_ADAPTER m_boardAdapter
Definition: panel_prev_3d.h:83