KiCad PCB EDA Suite
DLG_SELECT_3DMODEL Class Reference

#include <dlg_select_3dmodel.h>

Inheritance diagram for DLG_SELECT_3DMODEL:

Public Member Functions

 DLG_SELECT_3DMODEL (wxWindow *aParent, S3D_CACHE *aCacheManager, MODULE_3D_SETTINGS *aModelItem, wxString &prevModelSelectDir, int &prevModelWildcard)
 
bool TransferDataFromWindow () override
 
void OnSelectionChanged (wxTreeEvent &event)
 
void OnFileActivated (wxTreeEvent &event)
 
void SetRootDir (wxCommandEvent &event)
 
void Cfg3DPaths (wxCommandEvent &event)
 
 wxDECLARE_EVENT_TABLE ()
 

Private Member Functions

void updateDirChoiceList (void)
 

Private Attributes

MODULE_3D_SETTINGSm_model
 
S3D_CACHEm_cache
 
S3D_FILENAME_RESOLVERm_resolver
 
wxString & m_previousDir
 
int & m_previousFilterIndex
 
wxGenericDirCtrl * m_FileTree
 
C3D_MODEL_VIEWERm_modelViewer
 
wxChoice * dirChoices
 

Detailed Description

Definition at line 46 of file dlg_select_3dmodel.h.

Constructor & Destructor Documentation

DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL ( wxWindow *  aParent,
S3D_CACHE aCacheManager,
MODULE_3D_SETTINGS aModelItem,
wxString &  prevModelSelectDir,
int &  prevModelWildcard 
)

Member Function Documentation

void DLG_SELECT_3DMODEL::Cfg3DPaths ( wxCommandEvent &  event)

Definition at line 234 of file dlg_select_3dmodel.cpp.

References S3D::Configure3DPaths(), m_resolver, and updateDirChoiceList().

235 {
236  if( S3D::Configure3DPaths( this, m_resolver ) )
238 }
S3D_FILENAME_RESOLVER * m_resolver
bool Configure3DPaths(wxWindow *aParent, S3D_FILENAME_RESOLVER *aResolver)
void DLG_SELECT_3DMODEL::OnFileActivated ( wxTreeEvent &  event)

Definition at line 212 of file dlg_select_3dmodel.cpp.

References m_FileTree, m_modelViewer, and C3D_MODEL_VIEWER::Set3DModel().

213 {
214  if( m_modelViewer )
215  m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
216 
217  event.Skip();
218  SetEscapeId( wxID_OK );
219  Close();
220 
221  return;
222 }
C3D_MODEL_VIEWER * m_modelViewer
void Set3DModel(const S3DMODEL &a3DModel)
Set3DModel - Set this model to be displayed.
wxGenericDirCtrl * m_FileTree
void DLG_SELECT_3DMODEL::OnSelectionChanged ( wxTreeEvent &  event)

Definition at line 202 of file dlg_select_3dmodel.cpp.

References m_FileTree, m_modelViewer, and C3D_MODEL_VIEWER::Set3DModel().

203 {
204  if( m_modelViewer )
205  m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
206 
207  event.Skip();
208  return;
209 }
C3D_MODEL_VIEWER * m_modelViewer
void Set3DModel(const S3DMODEL &a3DModel)
Set3DModel - Set this model to be displayed.
wxGenericDirCtrl * m_FileTree
void DLG_SELECT_3DMODEL::SetRootDir ( wxCommandEvent &  event)

Definition at line 225 of file dlg_select_3dmodel.cpp.

References dirChoices, and m_FileTree.

226 {
227  if( m_FileTree )
228  m_FileTree->SetPath( dirChoices->GetString( dirChoices->GetSelection() ) );
229 
230  return;
231 }
wxGenericDirCtrl * m_FileTree
bool DLG_SELECT_3DMODEL::TransferDataFromWindow ( )
override

Definition at line 168 of file dlg_select_3dmodel.cpp.

References MODULE_3D_SETTINGS::m_Filename, m_FileTree, m_model, MODULE_3D_SETTINGS::m_Offset, m_previousDir, m_previousFilterIndex, m_resolver, MODULE_3D_SETTINGS::m_Rotation, MODULE_3D_SETTINGS::m_Scale, name, S3D_FILENAME_RESOLVER::ShortenPath(), MODULE_3D_SETTINGS::VECTOR3D::x, MODULE_3D_SETTINGS::VECTOR3D::y, and MODULE_3D_SETTINGS::VECTOR3D::z.

169 {
170  if( NULL == m_model || NULL == m_FileTree )
171  return true;
172 
173  m_model->m_Scale.x = 1.0;
174  m_model->m_Scale.y = 1.0;
175  m_model->m_Scale.z = 1.0;
176 
177  m_model->m_Rotation.x = 0.0;
178  m_model->m_Rotation.y = 0.0;
179  m_model->m_Rotation.z = 0.0;
180 
182  m_model->m_Filename.clear();
183 
184  wxString name = m_FileTree->GetFilePath();
185 
186  if( name.empty() )
187  return true;
188 
189  m_previousDir = m_FileTree->GetPath();
190  m_previousFilterIndex = m_FileTree->GetFilterIndex();
191 
192  // file selection mode: retrieve the filename and specify a
193  // path relative to one of the config paths
194  wxFileName fname = m_FileTree->GetFilePath();
195  fname.Normalize();
196  m_model->m_Filename = m_resolver->ShortenPath( fname.GetFullPath() );
197 
198  return true;
199 }
S3D_FILENAME_RESOLVER * m_resolver
VECTOR3D m_Offset
3D model offset (mm)
Definition: class_module.h:101
wxString ShortenPath(const wxString &aFullPathName)
Function ShortenPath produces a relative path based on the existing search directories or returns the...
wxGenericDirCtrl * m_FileTree
wxString m_Filename
The 3D shape filename in 3D library.
Definition: class_module.h:102
const char * name
Definition: DXF_plotter.cpp:61
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: class_module.h:100
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: class_module.h:99
MODULE_3D_SETTINGS * m_model
void DLG_SELECT_3DMODEL::updateDirChoiceList ( void  )
private

Definition at line 241 of file dlg_select_3dmodel.cpp.

References dirChoices, S3D_FILENAME_RESOLVER::GetPaths(), m_FileTree, and m_resolver.

Referenced by Cfg3DPaths().

242 {
243  if( NULL == m_FileTree || NULL == m_resolver || NULL == dirChoices )
244  return;
245 
246  std::list< S3D_ALIAS > const* md = m_resolver->GetPaths();
247  std::list< S3D_ALIAS >::const_iterator sL = md->begin();
248  std::list< S3D_ALIAS >::const_iterator eL = md->end();
249  std::set< wxString > cl;
250  wxString prjDir;
251 
252  // extract the current project dir
253  if( sL != eL )
254  {
255  prjDir = sL->m_pathexp;
256  ++sL;
257  }
258 
259  while( sL != eL )
260  {
261  if( !sL->m_pathexp.empty() && sL->m_pathexp.compare( prjDir ) )
262  cl.insert( sL->m_pathexp );
263 
264  ++sL;
265  }
266 
267  if( !cl.empty() )
268  {
269  dirChoices->Clear();
270 
271  if( !prjDir.empty() )
272  dirChoices->Append( prjDir );
273 
274  std::set< wxString >::const_iterator sI = cl.begin();
275  std::set< wxString >::const_iterator eI = cl.end();
276 
277  while( sI != eI )
278  {
279  dirChoices->Append( *sI );
280  ++sI;
281  }
282 
283  dirChoices->Select( 0 );
284  }
285 
286  return;
287 }
S3D_FILENAME_RESOLVER * m_resolver
wxGenericDirCtrl * m_FileTree
const std::list< S3D_ALIAS > * GetPaths(void)
Function GetPaths returns a pointer to the internal path list; the items in:load. ...
DLG_SELECT_3DMODEL::wxDECLARE_EVENT_TABLE ( )

Member Data Documentation

wxChoice* DLG_SELECT_3DMODEL::dirChoices
private

Definition at line 58 of file dlg_select_3dmodel.h.

Referenced by SetRootDir(), and updateDirChoiceList().

S3D_CACHE* DLG_SELECT_3DMODEL::m_cache
private

Definition at line 50 of file dlg_select_3dmodel.h.

wxGenericDirCtrl* DLG_SELECT_3DMODEL::m_FileTree
private
MODULE_3D_SETTINGS* DLG_SELECT_3DMODEL::m_model
private

Definition at line 49 of file dlg_select_3dmodel.h.

Referenced by TransferDataFromWindow().

C3D_MODEL_VIEWER* DLG_SELECT_3DMODEL::m_modelViewer
private

Definition at line 57 of file dlg_select_3dmodel.h.

Referenced by OnFileActivated(), and OnSelectionChanged().

wxString& DLG_SELECT_3DMODEL::m_previousDir
private

Definition at line 53 of file dlg_select_3dmodel.h.

Referenced by TransferDataFromWindow().

int& DLG_SELECT_3DMODEL::m_previousFilterIndex
private

Definition at line 54 of file dlg_select_3dmodel.h.

Referenced by TransferDataFromWindow().

S3D_FILENAME_RESOLVER* DLG_SELECT_3DMODEL::m_resolver
private

Definition at line 51 of file dlg_select_3dmodel.h.

Referenced by Cfg3DPaths(), TransferDataFromWindow(), and updateDirChoiceList().


The documentation for this class was generated from the following files: