KiCad PCB EDA Suite
panel_prev_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 <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 
44 
45 // Define min and max parameter values
46 #define MAX_SCALE 10000.0
47 #define MAX_ROTATION 180.0
48 #define MAX_OFFSET 1000.0
49 
50 #define SCALE_INCREMENT_FINE 0.02
51 #define SCALE_INCREMENT 0.1
52 
53 #define ROTATION_INCREMENT 5 // in degrees, for spin button command
54 #define ROTATION_INCREMENT_WHEEL 15 // in degrees, for mouse wheel command
55 #define ROTATION_INCREMENT_WHEEL_FINE 1 // in degrees, for mouse wheel command
56 
57 #define OFFSET_INCREMENT_MM 0.5
58 #define OFFSET_INCREMENT_MM_FINE 0.1
59 
60 #define OFFSET_INCREMENT_MIL 25.0
61 #define OFFSET_INCREMENT_MIL_FINE 5.0
62 
63 
64 // Declared classes to create pointers
65 class S3D_CACHE;
66 class FILENAME_RESOLVER;
67 class BOARD;
68 class CINFO3D_VISU;
69 class MODULE;
71 
73 {
74 public:
75  PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule,
76  std::vector<MODULE_3D_SETTINGS> *aParentModelList );
77 
79 
80 private:
83 
86 
87  std::vector<MODULE_3D_SETTINGS>* m_parentModelList;
88  int m_selected;
89 
91 
92  // Methods of the class
93 private:
94  void initPanel();
95 
100  void updateOrientation( wxCommandEvent &event ) override;
101 
102  void onMouseWheelScale( wxMouseEvent& event ) override;
103  void onMouseWheelRot( wxMouseEvent& event ) override;
104  void onMouseWheelOffset( wxMouseEvent& event ) override;
105 
106  void onIncrementRot( wxSpinEvent& event ) override
107  {
108  doIncrementRotation( event, 1.0 );
109  }
110  void onDecrementRot( wxSpinEvent& event ) override
111  {
112  doIncrementRotation( event, -1.0 );
113  }
114  void onIncrementScale( wxSpinEvent& event ) override
115  {
116  doIncrementScale( event, 1.0 );
117  }
118  void onDecrementScale( wxSpinEvent& event ) override
119  {
120  doIncrementScale( event, -1.0 );
121  }
122  void onIncrementOffset( wxSpinEvent& event ) override
123  {
124  doIncrementOffset( event, 1.0 );
125  }
126  void onDecrementOffset( wxSpinEvent& event ) override
127  {
128  doIncrementOffset( event, -1.0 );
129  }
130 
131  void doIncrementScale( wxSpinEvent& aEvent, double aSign );
132  void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
133  void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
134 
135  wxString formatScaleValue( double aValue );
136  wxString formatRotationValue( double aValue );
137  wxString formatOffsetValue( double aValue );
138 
139  void View3DISO( wxCommandEvent& event ) override
140  {
141  m_settings3Dviewer->CameraGet().ToggleProjection();
142  m_previewPane->Refresh();
143  }
144 
145  void View3DLeft( wxCommandEvent& event ) override
146  {
147  m_previewPane->SetView3D( GR_KB_SHIFT + 'X' );
148  }
149 
150  void View3DFront( wxCommandEvent& event ) override
151  {
152  m_previewPane->SetView3D( 'Y' );
153  }
154 
155  void View3DTop( wxCommandEvent& event ) override
156  {
157  m_previewPane->SetView3D( 'Z' );
158  }
159 
160  void View3DUpdate( wxCommandEvent& event ) override
161  {
162  m_previewPane->ReloadRequest();
163  m_previewPane->Refresh();
164  }
165 
166  void View3DRight( wxCommandEvent& event ) override
167  {
168  m_previewPane->SetView3D( 'X' );
169  }
170 
171  void View3DBack( wxCommandEvent& event ) override
172  {
173  m_previewPane->SetView3D( GR_KB_SHIFT + 'Y' );
174  }
175 
176  void View3DBottom( wxCommandEvent& event ) override
177  {
178  m_previewPane->SetView3D( GR_KB_SHIFT + 'Z' );
179  }
180 
181 public:
186  void SetSelectedModel( int idx );
187 
192  void UpdateDummyModule( bool aRelaodRequired = true );
193 };
194 
195 #endif // PANEL_PREV_MODEL_H
Class PANEL_PREV_3D_BASE.
void View3DRight(wxCommandEvent &event) override
CINFO3D_VISU * m_settings3Dviewer
void onDecrementRot(wxSpinEvent &event) override
void onMouseWheelScale(wxMouseEvent &event) override
void onIncrementOffset(wxSpinEvent &event) override
void onMouseWheelOffset(wxMouseEvent &event) override
Class EDA_3D_CANVAS Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:53
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)
std::vector< MODULE_3D_SETTINGS > * m_parentModelList
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
MODULE * m_dummyModule
void ToggleProjection()
Definition: ccamera.cpp:417
EDA_3D_CANVAS * m_previewPane
Class CINFO3D_VISU Helper class to handle information needed to display 3D board. ...
Definition: cinfo3d_visu.h:70
void onIncrementRot(wxSpinEvent &event) override
#define GR_KB_SHIFT
EDA_UNITS_T m_userUnits
Index into m_parentInfoList.
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
void View3DFront(wxCommandEvent &event) override
void updateOrientation(wxCommandEvent &event) override
updateOrientation - it will receive the events from editing the fields
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
bool SetView3D(int aKeycode)
SetView3D - Helper function to call view commands.
void onIncrementScale(wxSpinEvent &event) override
void View3DISO(wxCommandEvent &event) override
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
PANEL_PREV_3D(wxWindow *aParent, PCB_BASE_FRAME *aFrame, MODULE *aModule, std::vector< MODULE_3D_SETTINGS > *aParentModelList)
BOARD * m_dummyBoard
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
EDA_UNITS_T
Definition: common.h:159