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>

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

#define ID_FILE_TREE   ( wxID_LAST + 1 )

Definition at line 35 of file dlg_select_3dmodel.cpp.

#define ID_SET_DIR   ( ID_FILE_TREE + 1 )

Definition at line 36 of file dlg_select_3dmodel.cpp.

Function Documentation

wxBEGIN_EVENT_TABLE ( DLG_SELECT_3DMODEL  ,
wxDialog   
)

Definition at line 40 of file dlg_select_3dmodel.cpp.

References COGL_ATT_LIST::GetAttributesList().

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