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 "../3d_info.h"
42 #include <vector>
43 
45 
46 // Define min and max parameter values
47 #define MAX_SCALE 10000.0
48 #define MAX_ROTATION 180.0
49 #define MAX_OFFSET 1000.0
50 
51 #define SCALE_INCREMENT_FINE 0.02
52 #define SCALE_INCREMENT 0.1
53 
54 #define ROTATION_INCREMENT 5 // in degrees, for spin button command
55 #define ROTATION_INCREMENT_WHEEL 15 // in degrees, for mouse wheel command
56 #define ROTATION_INCREMENT_WHEEL_FINE 1 // in degrees, for mouse wheel command
57 
58 #define OFFSET_INCREMENT_MM 0.5
59 #define OFFSET_INCREMENT_MM_FINE 0.1
60 
61 #define OFFSET_INCREMENT_MIL 25.0
62 #define OFFSET_INCREMENT_MIL_FINE 5.0
63 
64 
65 // Declared classes to create pointers
66 class S3D_CACHE;
68 class BOARD;
69 class CINFO3D_VISU;
70 class MODULE;
71 
73 {
74 public:
75  PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager,
76  MODULE* aModuleCopy,
77  std::vector<S3D_INFO> *aParentInfoList = NULL );
78 
80 
81 private:
82  wxString currentModelFile;
84 
87 
90 
93 
96 
98  std::vector<S3D_INFO> *m_parentInfoList;
99 
102 
105 
106  // Methods of the class
107 private:
108  void initPanel();
109 
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  void onDecrementRot( wxSpinEvent& event ) override;
122  void onIncrementScale( wxSpinEvent& event ) override;
123  void onDecrementScale( wxSpinEvent& event ) override;
124  void onIncrementOffset( wxSpinEvent& event ) override;
125  void onDecrementOffset( wxSpinEvent& event ) override;
126 
133  void getOrientationVars( SGPOINT& aScale, SGPOINT& aRotation, SGPOINT& aOffset );
134 
139  void updateListOnModelCopy();
140 
141 
142  void onEnterPreviewCanvas( wxMouseEvent& event )
143  {
144  m_previewPane->SetFocus();
145  }
146 
147  void View3DISO( wxCommandEvent& event ) override
148  {
149  m_settings3Dviewer->CameraGet().ToggleProjection();
150  m_previewPane->Refresh();
151  }
152 
153  void View3DLeft( wxCommandEvent& event ) override
154  {
155  m_previewPane->SetView3D( 'X' );
156  }
157 
158  void View3DFront( wxCommandEvent& event ) override
159  {
160  m_previewPane->SetView3D( 'Y' );
161  }
162 
163  void View3DTop( wxCommandEvent& event ) override
164  {
165  m_previewPane->SetView3D( 'z' );
166  }
167 
168  void View3DUpdate( wxCommandEvent& event ) override
169  {
170  m_previewPane->ReloadRequest();
171  m_previewPane->Refresh();
172  }
173 
174  void View3DRight( wxCommandEvent& event ) override
175  {
176  m_previewPane->SetView3D( 'x' );
177  }
178 
179  void View3DBack( wxCommandEvent& event ) override
180  {
181  m_previewPane->SetView3D( 'y' );
182  }
183 
184  void View3DBottom( wxCommandEvent& event ) override
185  {
186  m_previewPane->SetView3D( 'Z' );
187  }
188 
189 public:
196  void SetModelDataIdx( int idx, bool aReloadPreviewModule = false );
197 
202  void ResetModelData( bool aReloadPreviewModule = false );
203 
204  void UpdateModelName( wxString const& aModel );
205 
211  bool ValidateWithMessage( wxString& aErrorMessage );
212 
213  bool Validate() override
214  {
215  wxString temp;
216  return ValidateWithMessage(temp);
217  }
218 };
219 
220 #endif // PANEL_PREV_MODEL_H
void ResetModelData(bool aReloadPreviewModule=false)
ResetModelData - Clear the values and reload the preview board.
Class PANEL_PREV_3D_BASE.
MODULE * m_copyModule
A pointer to a new copy of the original module.
void View3DRight(wxCommandEvent &event) override
CINFO3D_VISU * m_settings3Dviewer
The settings that will be used for this 3D viewer canvas.
void onDecrementRot(wxSpinEvent &event) override
PANEL_PREV_3D(wxWindow *aParent, S3D_CACHE *aCacheManager, MODULE *aModuleCopy, std::vector< S3D_INFO > *aParentInfoList=NULL)
void onMouseWheelScale(wxMouseEvent &event) override
void onIncrementOffset(wxSpinEvent &event) override
void getOrientationVars(SGPOINT &aScale, SGPOINT &aRotation, SGPOINT &aOffset)
getOrientationVars - gets the transformation from entries and validate it
void onMouseWheelOffset(wxMouseEvent &event) override
bool ValidateWithMessage(wxString &aErrorMessage)
verify X,Y and Z scale factors are acceptable (> 0.001 and < 1000.0)
Class EDA_3D_CANVAS Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:53
void onDecrementScale(wxSpinEvent &event) override
void ReloadRequest(BOARD *aBoard=NULL, S3D_CACHE *aCachePointer=NULL)
void View3DBottom(wxCommandEvent &event) override
int m_currentSelectedIdx
The current selected index of the S3D_INFO list.
void View3DLeft(wxCommandEvent &event) override
void View3DTop(wxCommandEvent &event) override
void View3DBack(wxCommandEvent &event) override
void updateListOnModelCopy()
updateListOnModelCopy - copy the current shape list to the copy of module that is on the preview dumm...
void SetModelDataIdx(int idx, bool aReloadPreviewModule=false)
SetModelDataIdx - This will set the index of the INFO list that was set on the parent.
S3D_FILENAME_RESOLVER * m_resolver
Used to get the full path name.
void onEnterPreviewCanvas(wxMouseEvent &event)
void ToggleProjection()
Definition: ccamera.cpp:417
EDA_3D_CANVAS * m_previewPane
The 3D canvas.
Class CINFO3D_VISU Helper class to handle information needed to display 3D board. ...
Definition: cinfo3d_visu.h:70
void onIncrementRot(wxSpinEvent &event) override
void View3DUpdate(wxCommandEvent &event) override
void onDecrementOffset(wxSpinEvent &event) override
void onMouseWheelRot(wxMouseEvent &event) override
void View3DFront(wxCommandEvent &event) override
void SetView3D(int keycode)
SetView3D - Helper function to call view commands.
bool Validate() 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:169
CCAMERA & CameraGet() const
CameraGet - get current camera in use.
Definition: cinfo3d_visu.h:210
void onIncrementScale(wxSpinEvent &event) override
void View3DISO(wxCommandEvent &event) override
S3D_INFO m_modelInfo
Current S3D_INFO that is being edited.
BOARD * m_dummyBoard
A dummy board used to store the copy moduled.
wxString currentModelFile
Used to check if the model file was changed.
std::vector< S3D_INFO > * m_parentInfoList
A pointer to the parent S3D_INFO list that we will use to copy to the preview module.
void UpdateModelName(wxString const &aModel)