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

#define ID_FILE_TREE   ( wxID_LAST + 1 )

Definition at line 36 of file dlg_select_3dmodel.cpp.

#define ID_SET_DIR   ( ID_FILE_TREE + 1 )

Definition at line 37 of file dlg_select_3dmodel.cpp.

Function Documentation

wxBEGIN_EVENT_TABLE ( DLG_SELECT_3DMODEL  ,
wxDialog   
)

Definition at line 41 of file dlg_select_3dmodel.cpp.

References COGL_ATT_LIST::GetAttributesList().

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