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, S3D_INFO *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

S3D_INFOm_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 47 of file dlg_select_3dmodel.h.

Constructor & Destructor Documentation

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

Member Function Documentation

void DLG_SELECT_3DMODEL::Cfg3DPaths ( wxCommandEvent &  event)

Definition at line 232 of file dlg_select_3dmodel.cpp.

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

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

Definition at line 210 of file dlg_select_3dmodel.cpp.

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

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

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

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

References dirChoices, and m_FileTree.

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

Definition at line 166 of file dlg_select_3dmodel.cpp.

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

167 {
168  if( NULL == m_model || NULL == m_FileTree )
169  return true;
170 
171  m_model->m_Scale.x = 1.0;
172  m_model->m_Scale.y = 1.0;
173  m_model->m_Scale.z = 1.0;
174 
175  m_model->m_Rotation.x = 0.0;
176  m_model->m_Rotation.y = 0.0;
177  m_model->m_Rotation.z = 0.0;
178 
180  m_model->m_Filename.clear();
181 
182  wxString name = m_FileTree->GetFilePath();
183 
184  if( name.empty() )
185  return true;
186 
187  m_previousDir = m_FileTree->GetPath();
188  m_previousFilterIndex = m_FileTree->GetFilterIndex();
189 
190  // file selection mode: retrieve the filename and specify a
191  // path relative to one of the config paths
192  wxFileName fname = m_FileTree->GetFilePath();
193  fname.Normalize();
194  m_model->m_Filename = m_resolver->ShortenPath( fname.GetFullPath() );
195 
196  return true;
197 }
double x
Definition: sg_base.h:70
double y
Definition: sg_base.h:71
SGPOINT m_Offset
an offset (unit = inch) for the 3D shape
Definition: 3d_info.h:44
S3D_FILENAME_RESOLVER * m_resolver
wxString ShortenPath(const wxString &aFullPathName)
Function ShortenPath produces a relative path based on the existing search directories or returns the...
wxGenericDirCtrl * m_FileTree
SGPOINT m_Rotation
an X,Y,Z rotation (unit = degrees) for the 3D shape
Definition: 3d_info.h:43
double z
Definition: sg_base.h:72
SGPOINT m_Scale
scaling factors for the 3D footprint shape
Definition: 3d_info.h:42
wxString m_Filename
The 3D shape filename in 3D library.
Definition: 3d_info.h:45
void DLG_SELECT_3DMODEL::updateDirChoiceList ( void  )
private

Definition at line 239 of file dlg_select_3dmodel.cpp.

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

Referenced by Cfg3DPaths().

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

Referenced by SetRootDir(), and updateDirChoiceList().

S3D_CACHE* DLG_SELECT_3DMODEL::m_cache
private

Definition at line 51 of file dlg_select_3dmodel.h.

wxGenericDirCtrl* DLG_SELECT_3DMODEL::m_FileTree
private
S3D_INFO* DLG_SELECT_3DMODEL::m_model
private

Definition at line 50 of file dlg_select_3dmodel.h.

Referenced by TransferDataFromWindow().

C3D_MODEL_VIEWER* DLG_SELECT_3DMODEL::m_modelViewer
private

Definition at line 58 of file dlg_select_3dmodel.h.

Referenced by OnFileActivated(), and OnSelectionChanged().

wxString& DLG_SELECT_3DMODEL::m_previousDir
private

Definition at line 54 of file dlg_select_3dmodel.h.

Referenced by TransferDataFromWindow().

int& DLG_SELECT_3DMODEL::m_previousFilterIndex
private

Definition at line 55 of file dlg_select_3dmodel.h.

Referenced by TransferDataFromWindow().

S3D_FILENAME_RESOLVER* DLG_SELECT_3DMODEL::m_resolver
private

Definition at line 52 of file dlg_select_3dmodel.h.

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


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