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 233 of file dlg_select_3dmodel.cpp.

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

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

Definition at line 211 of file dlg_select_3dmodel.cpp.

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

212 {
213  if( m_modelViewer )
214  m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
215 
216  event.Skip();
217  SetEscapeId( wxID_OK );
218  Close();
219 
220  return;
221 }
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 201 of file dlg_select_3dmodel.cpp.

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

202 {
203  if( m_modelViewer )
204  m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
205 
206  event.Skip();
207  return;
208 }
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 224 of file dlg_select_3dmodel.cpp.

References dirChoices, and m_FileTree.

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

Definition at line 167 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.

168 {
169  if( NULL == m_model || NULL == m_FileTree )
170  return true;
171 
172  m_model->m_Scale.x = 1.0;
173  m_model->m_Scale.y = 1.0;
174  m_model->m_Scale.z = 1.0;
175 
176  m_model->m_Rotation.x = 0.0;
177  m_model->m_Rotation.y = 0.0;
178  m_model->m_Rotation.z = 0.0;
179 
181  m_model->m_Filename.clear();
182 
183  wxString name = m_FileTree->GetFilePath();
184 
185  if( name.empty() )
186  return true;
187 
188  m_previousDir = m_FileTree->GetPath();
189  m_previousFilterIndex = m_FileTree->GetFilterIndex();
190 
191  // file selection mode: retrieve the filename and specify a
192  // path relative to one of the config paths
193  wxFileName fname = m_FileTree->GetFilePath();
194  fname.Normalize();
195  m_model->m_Filename = m_resolver->ShortenPath( fname.GetFullPath() );
196 
197  return true;
198 }
S3D_FILENAME_RESOLVER * m_resolver
VECTOR3D m_Offset
3D model offset (mm)
Definition: class_module.h:100
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:101
VECTOR3D m_Rotation
3D model rotation (degrees)
Definition: class_module.h:99
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
Definition: class_module.h:98
const char * name
MODULE_3D_SETTINGS * m_model
void DLG_SELECT_3DMODEL::updateDirChoiceList ( void  )
private

Definition at line 240 of file dlg_select_3dmodel.cpp.

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

Referenced by Cfg3DPaths().

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