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;
67 class BOARD;
68 class CINFO3D_VISU;
69 class MODULE;
71 
73 {
74 public:
75  PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager,
76  MODULE* aModuleCopy,
77  COLORS_DESIGN_SETTINGS *aColors,
78  std::vector<MODULE_3D_SETTINGS> *aParentInfoList = NULL );
79 
81 
82 private:
83  wxString currentModelFile;
85 
88 
91 
94 
97 
99  std::vector<MODULE_3D_SETTINGS> *m_parentInfoList;
100 
103 
106 
107  // Methods of the class
108 private:
109  void initPanel();
110 
115  void updateOrientation( wxCommandEvent &event ) override;
116 
117  void onMouseWheelScale( wxMouseEvent& event ) override;
118  void onMouseWheelRot( wxMouseEvent& event ) override;
119  void onMouseWheelOffset( wxMouseEvent& event ) override;
120 
121  void onIncrementRot( wxSpinEvent& event ) override;
122  void onDecrementRot( wxSpinEvent& event ) override;
123  void onIncrementScale( wxSpinEvent& event ) override;
124  void onDecrementScale( wxSpinEvent& event ) override;
125  void onIncrementOffset( wxSpinEvent& event ) override;
126  void onDecrementOffset( wxSpinEvent& event ) override;
127 
134  void getOrientationVars( SGPOINT& aScale, SGPOINT& aRotation, SGPOINT& aOffset );
135 
140  void updateListOnModelCopy();
141 
142 
143  void onEnterPreviewCanvas( wxMouseEvent& event )
144  {
145  m_previewPane->SetFocus();
146  }
147 
148  void View3DISO( wxCommandEvent& event ) override
149  {
150  m_settings3Dviewer->CameraGet().ToggleProjection();
151  m_previewPane->Refresh();
152  }
153 
154  void View3DLeft( wxCommandEvent& event ) override
155  {
156  m_previewPane->SetView3D( 'X' );
157  }
158 
159  void View3DFront( wxCommandEvent& event ) override
160  {
161  m_previewPane->SetView3D( 'Y' );
162  }
163 
164  void View3DTop( wxCommandEvent& event ) override
165  {
166  m_previewPane->SetView3D( 'z' );
167  }
168 
169  void View3DUpdate( wxCommandEvent& event ) override
170  {
171  m_previewPane->ReloadRequest();
172  m_previewPane->Refresh();
173  }
174 
175  void View3DRight( wxCommandEvent& event ) override
176  {
177  m_previewPane->SetView3D( 'x' );
178  }
179 
180  void View3DBack( wxCommandEvent& event ) override
181  {
182  m_previewPane->SetView3D( 'y' );
183  }
184 
185  void View3DBottom( wxCommandEvent& event ) override
186  {
187  m_previewPane->SetView3D( 'Z' );
188  }
189 
190 public:
197  void SetModelDataIdx( int idx, bool aReloadPreviewModule = false );
198 
203  void ResetModelData( bool aReloadPreviewModule = false );
204 
205  void UpdateModelName( wxString const& aModel );
206 
212  bool ValidateWithMessage( wxString& aErrorMessage );
213 
214  bool Validate() override
215  {
216  wxString temp;
217  return ValidateWithMessage(temp);
218  }
219 };
220 
221 #endif // PANEL_PREV_MODEL_H
void ResetModelData(bool aReloadPreviewModule=false)
ResetModelData - Clear the values and reload the preview board.
std::vector< MODULE_3D_SETTINGS > * m_parentInfoList
A pointer to the parent MODULE_3D_SETTINGS list that we will use to copy to the preview module...
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
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 MODULE_3D_SETTINGS 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
PANEL_PREV_3D(wxWindow *aParent, S3D_CACHE *aCacheManager, MODULE *aModuleCopy, COLORS_DESIGN_SETTINGS *aColors, std::vector< MODULE_3D_SETTINGS > *aParentInfoList=NULL)
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
BOARD * m_dummyBoard
A dummy board used to store the copy moduled.
wxString currentModelFile
Used to check if the model file was changed.
void UpdateModelName(wxString const &aModel)
MODULE_3D_SETTINGS m_modelInfo
Current MODULE_3D_SETTINGS that is being edited.