KiCad PCB EDA Suite
dlg_select_3dmodel.cpp File Reference
#include <set>
#include "dlg_select_3dmodel.h"
#include "project.h"
#include "3d_cache/3d_info.h"
#include "3d_cache/3d_cache.h"
#include "3d_cache_dialogs.h"
#include <3d_model_viewer/c3d_model_viewer.h>
#include <common_ogl/cogl_att_list.h>
#include <pcbnew/class_module.h>

Go to the source code of this file.

Macros

#define ID_FILE_TREE   ( wxID_LAST + 1 )
 
#define ID_SET_DIR   ( ID_FILE_TREE + 1 )
 
#define ID_CFG_PATHS   ( ID_SET_DIR + 1 )
 

Functions

 wxBEGIN_EVENT_TABLE (DLG_SELECT_3DMODEL, DIALOG_SHIM) wxEND_EVENT_TABLE() DLG_SELECT_3DMODEL
 

Macro Definition Documentation

#define ID_CFG_PATHS   ( ID_SET_DIR + 1 )

Definition at line 39 of file dlg_select_3dmodel.cpp.

#define ID_FILE_TREE   ( wxID_LAST + 1 )

Definition at line 37 of file dlg_select_3dmodel.cpp.

#define ID_SET_DIR   ( ID_FILE_TREE + 1 )

Definition at line 38 of file dlg_select_3dmodel.cpp.

Function Documentation

wxBEGIN_EVENT_TABLE ( DLG_SELECT_3DMODEL  ,
DIALOG_SHIM   
)

Definition at line 42 of file dlg_select_3dmodel.cpp.

References COGL_ATT_LIST::GetAttributesList().

51  :
52  DIALOG_SHIM( aParent, wxID_ANY, _( "Select 3D Model" ), wxDefaultPosition,
53  wxSize( 500,200 ), wxCAPTION | wxRESIZE_BORDER | wxCLOSE_BOX
54  | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU ),
55  m_model( aModelItem ), m_cache( aCacheManager ), m_previousDir( prevModelSelectDir ),
56  m_previousFilterIndex( prevModelWildcard )
57 {
58  SetSizeHints( wxSize( 500,200 ), wxDefaultSize );
59 
60  if( NULL != m_cache )
61  m_resolver = m_cache->GetResolver();
62  else
63  m_resolver = NULL;
64 
65  wxBoxSizer* bSizer0 = new wxBoxSizer( wxVERTICAL );
66 
67  wxBoxSizer* bSizer1 = new wxBoxSizer( wxHORIZONTAL );
68 
69  wxBoxSizer* bSizer2 = new wxBoxSizer( wxVERTICAL );
70 
71  // set to NULL to avoid segfaults when m_FileTree is instantiated
72  // and wxGenericDirCtrl events are posted
73  m_modelViewer = NULL;
74  dirChoices = NULL;
75 
76  m_FileTree = new wxGenericDirCtrl( this, ID_FILE_TREE, prevModelSelectDir, wxDefaultPosition,
77  wxSize( 300,100 ), wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_EDIT_LABELS
78  | wxDIRCTRL_SELECT_FIRST | wxDIRCTRL_SHOW_FILTERS | wxBORDER_SIMPLE, wxEmptyString, 0 );
79 
80 
81  m_FileTree->ShowHidden( false );
82  m_FileTree->SetMinSize( wxSize( 300, 400 ) );
83  m_FileTree->SetLabel( wxT( "3D_MODEL_SELECTOR" ) );
84 
85  bSizer2->Add( m_FileTree, 1, wxEXPAND | wxALL, 5 );
86  bSizer1->Add( bSizer2, 3, wxEXPAND, 5 );
87 
88  m_modelViewer = new C3D_MODEL_VIEWER( this, COGL_ATT_LIST::GetAttributesList( true ), m_cache );
89  m_modelViewer->SetMinSize( wxSize( 500, 400 ) );
90 
91  bSizer1->Add( m_modelViewer, 5, wxEXPAND | wxALL | wxCENTER, 5 );
92 
93  // create the filter list
94  if( NULL != m_cache )
95  {
96  std::list< wxString > const* fl = m_cache->GetFileFilters();
97  std::list< wxString >::const_iterator sL = fl->begin();
98  std::list< wxString >::const_iterator eL = fl->end();
99  wxString filter;
100 
101  while( sL != eL )
102  {
103  filter.Append( *sL );
104 
105  ++sL;
106 
107  if( sL != eL )
108  filter.Append( wxT( "|" ) );
109  }
110 
111  if( !filter.empty() )
112  m_FileTree->SetFilter( filter );
113  else
114  m_FileTree->SetFilter( wxT( "*.*" ) );
115 
116  if( prevModelWildcard >= 0 && prevModelWildcard < (int)fl->size() )
117  m_FileTree->SetFilterIndex( prevModelWildcard );
118  else
119  {
120  prevModelWildcard = 0;
121  m_FileTree->SetFilterIndex( 0 );
122  }
123  }
124  else
125  {
126  m_FileTree->SetFilter( wxT( "*.*" ) );
127  prevModelWildcard = 0;
128  m_FileTree->SetFilterIndex( 0 );
129  }
130 
131  // Add the path choice box and config button
132  wxBoxSizer* hboxDirChoice = new wxBoxSizer( wxHORIZONTAL );
133  dirChoices = new wxChoice( this, ID_SET_DIR, wxDefaultPosition, wxSize( 320, 20 ) );
134  dirChoices->SetMinSize( wxSize( 320, 12 ) );
135 
136  wxStaticText* stDirChoice = new wxStaticText( this, -1, _( "Paths:" ) );
137  wxButton* cfgPaths = new wxButton( this, ID_CFG_PATHS, _( "Configure Paths" ) );
138  hboxDirChoice->Add( stDirChoice, 0, wxALL | wxCENTER, 5 );
139  hboxDirChoice->Add( dirChoices, 1, wxEXPAND | wxALL, 5 );
140  hboxDirChoice->Add( cfgPaths, 0, wxALL, 5 );
141 
142  wxButton* btn_OK = new wxButton( this, wxID_OK, _( "OK" ) );
143  wxButton* btn_Cancel = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
144 
145  wxStdDialogButtonSizer* hSizer1 = new wxStdDialogButtonSizer();
146  hSizer1->AddButton( btn_OK );
147  hSizer1->AddButton( btn_Cancel );
148  hSizer1->Realize();
149 
150  bSizer0->Add( bSizer1, 1, wxALL | wxEXPAND, 5 );
151  bSizer0->Add( hboxDirChoice, 0, wxALL | wxEXPAND, 5 );
152  bSizer0->Add( hSizer1, 0, wxALL | wxEXPAND, 5 );
153 
154  updateDirChoiceList();
155 
156  SetSizerAndFit( bSizer0 );
157  Layout();
158  Centre( wxBOTH );
159 
160  m_modelViewer->Refresh();
161  m_modelViewer->SetFocus();
162 }
static const int * GetAttributesList(bool aUseAntiAliasing)
Get a list of attributes to pass to wxGLCanvas.
#define ID_FILE_TREE
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:82
Class C3D_MODEL_VIEWER Implement a canvas based on a wxGLCanvas.
#define ID_CFG_PATHS
#define ID_SET_DIR