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, wxDialog) 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  ,
wxDialog   
)

Definition at line 42 of file dlg_select_3dmodel.cpp.

References COGL_ATT_LIST::GetAttributesList().

51  :
52  wxDialog( 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|wxSUNKEN_BORDER, wxEmptyString, 0 );
79 
80 
81  m_FileTree->ShowHidden( false );
82  m_FileTree->SetMinSize( wxSize( 300,100 ) );
83  m_FileTree->SetLabel( wxT( "3D_MODEL_SELECTOR" ) );
84 
85  bSizer2->Add( m_FileTree, 1, wxEXPAND | wxALL, 5 );
86  bSizer1->Add( bSizer2, 1, wxEXPAND, 5 );
87 
88  m_modelViewer = new C3D_MODEL_VIEWER( this,
90  m_cache );
91  m_modelViewer->SetMinSize( wxSize( 512, 384 ) );
92 
93  bSizer1->Add( m_modelViewer, 0, wxCENTER, 5 );
94 
95  // create the filter list
96  if( NULL != m_cache )
97  {
98  std::list< wxString > const* fl = m_cache->GetFileFilters();
99  std::list< wxString >::const_iterator sL = fl->begin();
100  std::list< wxString >::const_iterator eL = fl->end();
101  wxString filter;
102 
103  while( sL != eL )
104  {
105  filter.Append( *sL );
106 
107  ++sL;
108 
109  if( sL != eL )
110  filter.Append( wxT( "|" ) );
111 
112  }
113 
114  if( !filter.empty() )
115  m_FileTree->SetFilter( filter );
116  else
117  m_FileTree->SetFilter( wxT( "*.*" ) );
118 
119  if( prevModelWildcard >= 0 && prevModelWildcard < (int)fl->size() )
120  m_FileTree->SetFilterIndex( prevModelWildcard );
121  else
122  {
123  prevModelWildcard = 0;
124  m_FileTree->SetFilterIndex( 0 );
125  }
126  }
127  else
128  {
129  m_FileTree->SetFilter( wxT( "*.*" ) );
130  prevModelWildcard = 0;
131  m_FileTree->SetFilterIndex( 0 );
132  }
133 
134  // Add the path choice box and config button
135  wxBoxSizer* hboxDirChoice = new wxBoxSizer( wxHORIZONTAL );
136  dirChoices = new wxChoice( this, ID_SET_DIR, wxDefaultPosition, wxSize( 320, 20 ) );
137  dirChoices->SetMinSize( wxSize( 320, 12 ) );
138 
139  wxStaticText* stDirChoice = new wxStaticText( this, -1, _( "Paths:" ) );
140  wxButton* cfgPaths = new wxButton( this, ID_CFG_PATHS, _( "Configure Path" ) );
141  hboxDirChoice->Add( stDirChoice, 0, wxALL | wxCENTER, 5 );
142  hboxDirChoice->Add( dirChoices, 1, wxEXPAND | wxALL, 5 );
143  hboxDirChoice->Add( cfgPaths, 0, wxALL, 5 );
144 
145  wxButton* btn_OK = new wxButton( this, wxID_OK, _( "OK" ) );
146  wxButton* btn_Cancel = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
147 
148  wxStdDialogButtonSizer* hSizer1 = new wxStdDialogButtonSizer();
149  hSizer1->AddButton( btn_OK );
150  hSizer1->AddButton( btn_Cancel );
151  hSizer1->Realize();
152 
153  bSizer0->Add( bSizer1, 1, wxALL | wxEXPAND, 5 );
154  bSizer0->Add( hboxDirChoice, 0, wxALL | wxEXPAND, 5 );
155  bSizer0->Add( hSizer1, 0, wxALL | wxEXPAND, 5 );
156 
157  updateDirChoiceList();
158 
159  SetSizerAndFit( bSizer0 );
160  Layout();
161  Centre( wxBOTH );
162 
163  m_modelViewer->Refresh();
164  m_modelViewer->SetFocus();
165 }
static const int * GetAttributesList(bool aUseAntiAliasing)
Get a list of attributes to pass to wxGLCanvas.
#define ID_FILE_TREE
Class C3D_MODEL_VIEWER Implement a canvas based on a wxGLCanvas.
#define ID_CFG_PATHS
#define ID_SET_DIR