DLG_SELECT_3DMODEL rework: better dialog (use split window) and fix a few issues.

This commit is contained in:
jean-pierre charras 2020-04-30 19:49:41 +02:00
parent 86b5971de6
commit 93b9be7ebe
6 changed files with 787 additions and 116 deletions

View File

@ -0,0 +1,552 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration">; </property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dlg_select_3dmodel_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dlg_select_3dmodel_base</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DLG_SELECT_3D_MODELE_BASE</property>
<property name="pos"></property>
<property name="size">468,347</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property>
<property name="title">Select 3D Model</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerMain</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size">-1,400</property>
<property name="name">bSizerUpper</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxSplitterWindow" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_pane_size">0</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_splitterWin</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="sashgravity">0.5</property>
<property name="sashpos">340</property>
<property name="sashsize">-1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="splitmode">wxSPLIT_VERTICAL</property>
<property name="style">wxSP_3D</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<object class="splitteritem" expanded="1">
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelLeft</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerLeft</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxGenericDirCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="defaultfilter">0</property>
<property name="defaultfolder"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="filter"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">300,-1</property>
<property name="moveable">1</property>
<property name="name">m_FileTree</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="show_hidden">0</property>
<property name="size"></property>
<property name="style">wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_EDIT_LABELS|wxDIRCTRL_SELECT_FIRST|wxDIRCTRL_SHOW_FILTERS</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxBORDER_SIMPLE</property>
<event name="OnDirctrlFileActivated">OnFileActivated</event>
<event name="OnDirctrlSelectionChanged">OnSelectionChanged</event>
</object>
</object>
</object>
</object>
</object>
<object class="splitteritem" expanded="1">
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_pane3Dviewer</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">m_Sizer3Dviewer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">protected</property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerLower</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Available paths:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_stDirChoice</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_dirChoices</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChoice">SetRootDir</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Configure Paths</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cfgPathsButt</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">Cfg3DPaths</event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -35,82 +35,70 @@
#include <filename_resolver.h> #include <filename_resolver.h>
#include <pcbnew/class_module.h> #include <pcbnew/class_module.h>
#define ID_FILE_TREE ( wxID_LAST + 1 )
#define ID_SET_DIR ( ID_FILE_TREE + 1 )
#define ID_CFG_PATHS ( ID_SET_DIR + 1 )
wxBEGIN_EVENT_TABLE( DLG_SELECT_3DMODEL, DIALOG_SHIM )
EVT_DIRCTRL_SELECTIONCHANGED( ID_FILE_TREE, DLG_SELECT_3DMODEL::OnSelectionChanged )
EVT_DIRCTRL_FILEACTIVATED( ID_FILE_TREE, DLG_SELECT_3DMODEL::OnFileActivated )
EVT_CHOICE( ID_SET_DIR, DLG_SELECT_3DMODEL::SetRootDir )
EVT_BUTTON( ID_CFG_PATHS, DLG_SELECT_3DMODEL::Cfg3DPaths )
wxEND_EVENT_TABLE()
DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager,
MODULE_3D_SETTINGS* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ) : MODULE_3D_SETTINGS* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ) :
DIALOG_SHIM( aParent, wxID_ANY, _( "Select 3D Model" ), wxDefaultPosition, DLG_SELECT_3D_MODELE_BASE( aParent ),
wxSize( 500,200 ), wxCAPTION | wxRESIZE_BORDER | wxCLOSE_BOX
| wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU ),
m_model( aModelItem ), m_cache( aCacheManager ), m_previousDir( prevModelSelectDir ), m_model( aModelItem ), m_cache( aCacheManager ), m_previousDir( prevModelSelectDir ),
m_previousFilterIndex( prevModelWildcard ) m_previousFilterIndex( prevModelWildcard )
{ {
SetSizeHints( wxSize( 500,200 ), wxDefaultSize );
if( NULL != m_cache ) if( NULL != m_cache )
m_resolver = m_cache->GetResolver(); m_resolver = m_cache->GetResolver();
else else
m_resolver = NULL; m_resolver = NULL;
wxBoxSizer* bSizer0 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer1 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer2 = new wxBoxSizer( wxVERTICAL );
// set to NULL to avoid segfaults when m_FileTree is instantiated // set to NULL to avoid segfaults when m_FileTree is instantiated
// and wxGenericDirCtrl events are posted // and wxGenericDirCtrl events are posted
m_modelViewer = NULL; m_modelViewer = NULL;
dirChoices = NULL;
m_FileTree = new wxGenericDirCtrl( this, ID_FILE_TREE, prevModelSelectDir, wxDefaultPosition, m_modelViewer = new C3D_MODEL_VIEWER( m_pane3Dviewer,
wxSize( 300,100 ), wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_EDIT_LABELS COGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ),
| wxDIRCTRL_SELECT_FIRST | wxDIRCTRL_SHOW_FILTERS | wxBORDER_SIMPLE, wxEmptyString, 0 ); m_cache );
m_modelViewer->SetMinSize( wxSize( 300, -1 ) );
m_Sizer3Dviewer->Add( m_modelViewer, 1, wxEXPAND, 5 );
m_FileTree->ShowHidden( false );
m_FileTree->SetMinSize( wxSize( 300, 400 ) );
m_FileTree->SetLabel( wxT( "3D_MODEL_SELECTOR" ) );
bSizer2->Add( m_FileTree, 1, wxEXPAND | wxALL, 5 );
bSizer1->Add( bSizer2, 3, wxEXPAND, 5 );
m_modelViewer = new C3D_MODEL_VIEWER( this, COGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ), m_cache );
m_modelViewer->SetMinSize( wxSize( 500, 400 ) );
bSizer1->Add( m_modelViewer, 5, wxEXPAND | wxALL | wxCENTER, 5 );
// create the filter list // create the filter list
if( NULL != m_cache ) if( NULL != m_cache )
{ {
std::list< wxString > const* fl = m_cache->GetFileFilters(); std::list< wxString > const* fl = m_cache->GetFileFilters();
std::list< wxString >::const_iterator sL = fl->begin(); std::list< wxString >::const_iterator sL = fl->begin();
std::list< wxString >::const_iterator eL = fl->end();
// The files filter string build from list of loaded plugins:
wxString filter; wxString filter;
while( sL != eL ) // The files filter extensions only build from list of loaded plugins:
wxString ext_list;
while( sL != fl->end() )
{ {
if( !filter.IsEmpty() )
filter.Append( "|" );
filter.Append( *sL ); filter.Append( *sL );
++sL; if( !ext_list.IsEmpty() )
ext_list.Append( ";" );
if( sL != eL ) wxString ext = sL->AfterLast( '|' );
filter.Append( wxT( "|" ) );
if( ext.Len() > 3 ) // Skip *.*
ext_list.Append( ext );
++sL;
} }
if( !filter.empty() ) if( !filter.empty() )
m_FileTree->SetFilter( filter ); {
if( !ext_list.empty() )
{
wxString full_filter;
full_filter.Printf( _( "All supported files (%s)|%s)" ), ext_list, ext_list );
full_filter << '|' << filter;
m_FileTree->SetFilter( full_filter );
}
else
m_FileTree->SetFilter( filter );
}
else else
m_FileTree->SetFilter( wxFileSelectorDefaultWildcardStr ); m_FileTree->SetFilter( wxFileSelectorDefaultWildcardStr );
@ -129,43 +117,19 @@ DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheMana
m_FileTree->SetFilterIndex( 0 ); m_FileTree->SetFilterIndex( 0 );
} }
// Add the path choice box and config button m_FileTree->SetPath( m_previousDir );
wxBoxSizer* hboxDirChoice = new wxBoxSizer( wxHORIZONTAL );
dirChoices = new wxChoice( this, ID_SET_DIR, wxDefaultPosition, wxSize( 320, 20 ) );
dirChoices->SetMinSize( wxSize( 320, 12 ) );
wxStaticText* stDirChoice = new wxStaticText( this, -1, _( "Paths:" ) );
wxButton* cfgPaths = new wxButton( this, ID_CFG_PATHS, _( "Configure Paths" ) );
hboxDirChoice->Add( stDirChoice, 0, wxALL | wxCENTER, 5 );
hboxDirChoice->Add( dirChoices, 1, wxEXPAND | wxALL, 5 );
hboxDirChoice->Add( cfgPaths, 0, wxALL, 5 );
wxButton* btn_OK = new wxButton( this, wxID_OK, _( "OK" ) );
wxButton* btn_Cancel = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
wxStdDialogButtonSizer* hSizer1 = new wxStdDialogButtonSizer();
hSizer1->AddButton( btn_OK );
hSizer1->AddButton( btn_Cancel );
hSizer1->Realize();
bSizer0->Add( bSizer1, 1, wxALL | wxEXPAND, 5 );
bSizer0->Add( hboxDirChoice, 0, wxALL | wxEXPAND, 5 );
bSizer0->Add( hSizer1, 0, wxALL | wxEXPAND, 5 );
updateDirChoiceList(); updateDirChoiceList();
SetSizerAndFit( bSizer0 );
Layout();
Centre( wxBOTH );
m_modelViewer->Refresh(); m_modelViewer->Refresh();
m_modelViewer->SetFocus(); m_modelViewer->SetFocus();
FinishDialogSettings();
} }
bool DLG_SELECT_3DMODEL::TransferDataFromWindow() bool DLG_SELECT_3DMODEL::TransferDataFromWindow()
{ {
if( NULL == m_model || NULL == m_FileTree ) if( !m_model || !m_FileTree )
return true; return true;
m_model->m_Scale.x = 1.0; m_model->m_Scale.x = 1.0;
@ -197,35 +161,27 @@ bool DLG_SELECT_3DMODEL::TransferDataFromWindow()
} }
void DLG_SELECT_3DMODEL::OnSelectionChanged( wxTreeEvent& event ) void DLG_SELECT_3DMODEL::OnSelectionChanged( wxCommandEvent& event )
{ {
if( m_modelViewer ) if( m_modelViewer )
m_modelViewer->Set3DModel( m_FileTree->GetFilePath() ); m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
event.Skip();
return;
} }
void DLG_SELECT_3DMODEL::OnFileActivated( wxTreeEvent& event ) void DLG_SELECT_3DMODEL::OnFileActivated( wxCommandEvent& event )
{ {
if( m_modelViewer ) if( m_modelViewer )
m_modelViewer->Set3DModel( m_FileTree->GetFilePath() ); m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
event.Skip();
SetEscapeId( wxID_OK ); SetEscapeId( wxID_OK );
Close(); Close();
return;
} }
void DLG_SELECT_3DMODEL::SetRootDir( wxCommandEvent& event ) void DLG_SELECT_3DMODEL::SetRootDir( wxCommandEvent& event )
{ {
if( m_FileTree && dirChoices->GetSelection() > 0 ) if( m_FileTree && m_dirChoices->GetSelection() > 0 )
m_FileTree->SetPath( dirChoices->GetString( dirChoices->GetSelection() ) ); m_FileTree->SetPath( m_dirChoices->GetString( m_dirChoices->GetSelection() ) );
return;
} }
@ -238,23 +194,22 @@ void DLG_SELECT_3DMODEL::Cfg3DPaths( wxCommandEvent& event )
void DLG_SELECT_3DMODEL::updateDirChoiceList( void ) void DLG_SELECT_3DMODEL::updateDirChoiceList( void )
{ {
if( NULL == m_FileTree || NULL == m_resolver || NULL == dirChoices ) if( !m_FileTree || !m_resolver || !m_dirChoices )
return; return;
std::list< SEARCH_PATH > const* md = m_resolver->GetPaths(); std::list< SEARCH_PATH > const* md = m_resolver->GetPaths();
std::list< SEARCH_PATH >::const_iterator sL = md->begin(); std::list< SEARCH_PATH >::const_iterator sL = md->begin();
std::list< SEARCH_PATH >::const_iterator eL = md->end();
std::set< wxString > cl; std::set< wxString > cl;
wxString prjDir; wxString prjDir;
// extract the current project dir // extract the current project dir
if( sL != eL ) if( sL != md->end() )
{ {
prjDir = sL->m_pathexp; prjDir = sL->m_pathexp;
++sL; ++sL;
} }
while( sL != eL ) while( sL != md->end() )
{ {
if( !sL->m_pathexp.empty() && sL->m_pathexp.compare( prjDir ) ) if( !sL->m_pathexp.empty() && sL->m_pathexp.compare( prjDir ) )
cl.insert( sL->m_pathexp ); cl.insert( sL->m_pathexp );
@ -265,30 +220,29 @@ void DLG_SELECT_3DMODEL::updateDirChoiceList( void )
if( !cl.empty() ) if( !cl.empty() )
{ {
unsigned int choice = 0; unsigned int choice = 0;
dirChoices->Clear(); m_dirChoices->Clear();
dirChoices->Append( "" ); //Insert a blank string at the beginning to allow selection m_dirChoices->Append( "" ); //Insert a blank string at the beginning to allow selection
if( !prjDir.empty() ) if( !prjDir.empty() )
{ {
dirChoices->Append( prjDir ); m_dirChoices->Append( prjDir );
if( prjDir == m_FileTree->GetPath() ) if( prjDir == m_FileTree->GetPath() )
choice = 1; choice = 1;
} }
std::set< wxString >::const_iterator sI = cl.begin(); std::set< wxString >::const_iterator sI = cl.begin();
std::set< wxString >::const_iterator eI = cl.end();
while( sI != eI ) while( sI != cl.end() )
{ {
if( *sI == m_FileTree->GetPath() ) if( *sI == m_FileTree->GetPath() )
choice = dirChoices->GetCount(); choice = m_dirChoices->GetCount();
dirChoices->Append( *sI ); m_dirChoices->Append( *sI );
++sI; ++sI;
} }
dirChoices->Select( choice ); m_dirChoices->SetSelection( choice );
} }
return; return;

View File

@ -31,22 +31,14 @@
#ifndef DLG_SELECT_3DMODEL_H #ifndef DLG_SELECT_3DMODEL_H
#define DLG_SELECT_3DMODEL_H #define DLG_SELECT_3DMODEL_H
#include <wx/event.h> #include "dlg_select_3dmodel_base.h"
#include <wx/stattext.h>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/dirctrl.h>
#include <wx/sizer.h>
#include <wx/frame.h>
#include <dialog_shim.h>
class MODULE_3D_SETTINGS; class MODULE_3D_SETTINGS;
class S3D_CACHE; class S3D_CACHE;
class FILENAME_RESOLVER; class FILENAME_RESOLVER;
class C3D_MODEL_VIEWER; class C3D_MODEL_VIEWER;
class DLG_SELECT_3DMODEL : public DIALOG_SHIM class DLG_SELECT_3DMODEL : public DLG_SELECT_3D_MODELE_BASE
{ {
private: private:
MODULE_3D_SETTINGS* m_model; // data for the selected model MODULE_3D_SETTINGS* m_model; // data for the selected model
@ -56,9 +48,7 @@ private:
wxString& m_previousDir; wxString& m_previousDir;
int& m_previousFilterIndex; int& m_previousFilterIndex;
wxGenericDirCtrl* m_FileTree;
C3D_MODEL_VIEWER* m_modelViewer; C3D_MODEL_VIEWER* m_modelViewer;
wxChoice* dirChoices;
void updateDirChoiceList( void ); void updateDirChoiceList( void );
@ -67,12 +57,10 @@ public:
wxString& prevModelSelectDir, int& prevModelWildcard ); wxString& prevModelSelectDir, int& prevModelWildcard );
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
void OnSelectionChanged( wxTreeEvent& event ); void OnSelectionChanged( wxCommandEvent& event )override;
void OnFileActivated( wxTreeEvent& event ); void OnFileActivated( wxCommandEvent& event )override;
void SetRootDir( wxCommandEvent& event ); void SetRootDir( wxCommandEvent& event ) override;
void Cfg3DPaths( wxCommandEvent& event ); void Cfg3DPaths( wxCommandEvent& event ) override;
wxDECLARE_EVENT_TABLE();
}; };
#endif // DLG_SELECT_3DMODEL_H #endif // DLG_SELECT_3DMODEL_H

View File

@ -0,0 +1,103 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 10 2019)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dlg_select_3dmodel_base.h"
///////////////////////////////////////////////////////////////////////////
DLG_SELECT_3D_MODELE_BASE::DLG_SELECT_3D_MODELE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxHORIZONTAL );
bSizerUpper->SetMinSize( wxSize( -1,400 ) );
m_splitterWin = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_splitterWin->SetSashGravity( 0.5 );
m_splitterWin->Connect( wxEVT_IDLE, wxIdleEventHandler( DLG_SELECT_3D_MODELE_BASE::m_splitterWinOnIdle ), NULL, this );
m_panelLeft = new wxPanel( m_splitterWin, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerLeft;
bSizerLeft = new wxBoxSizer( wxVERTICAL );
m_FileTree = new wxGenericDirCtrl( m_panelLeft, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_EDIT_LABELS|wxDIRCTRL_SELECT_FIRST|wxDIRCTRL_SHOW_FILTERS|wxBORDER_SIMPLE, wxEmptyString, 0 );
m_FileTree->ShowHidden( false );
m_FileTree->SetMinSize( wxSize( 300,-1 ) );
bSizerLeft->Add( m_FileTree, 1, wxALL|wxEXPAND, 5 );
m_panelLeft->SetSizer( bSizerLeft );
m_panelLeft->Layout();
bSizerLeft->Fit( m_panelLeft );
m_pane3Dviewer = new wxPanel( m_splitterWin, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_Sizer3Dviewer = new wxBoxSizer( wxVERTICAL );
m_pane3Dviewer->SetSizer( m_Sizer3Dviewer );
m_pane3Dviewer->Layout();
m_Sizer3Dviewer->Fit( m_pane3Dviewer );
m_splitterWin->SplitVertically( m_panelLeft, m_pane3Dviewer, 340 );
bSizerUpper->Add( m_splitterWin, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerLower;
bSizerLower = new wxBoxSizer( wxHORIZONTAL );
m_stDirChoice = new wxStaticText( this, wxID_ANY, _("Available paths:"), wxDefaultPosition, wxDefaultSize, 0 );
m_stDirChoice->Wrap( -1 );
bSizerLower->Add( m_stDirChoice, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
wxArrayString m_dirChoicesChoices;
m_dirChoices = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dirChoicesChoices, 0 );
m_dirChoices->SetSelection( 0 );
bSizerLower->Add( m_dirChoices, 1, wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_cfgPathsButt = new wxButton( this, wxID_ANY, _("Configure Paths"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerLower->Add( m_cfgPathsButt, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( bSizerLower, 0, wxEXPAND, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizerMain );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_FileTree->Connect( wxEVT_DIRCTRL_FILEACTIVATED, wxCommandEventHandler( DLG_SELECT_3D_MODELE_BASE::OnFileActivated ), NULL, this );
m_FileTree->Connect( wxEVT_DIRCTRL_SELECTIONCHANGED, wxCommandEventHandler( DLG_SELECT_3D_MODELE_BASE::OnSelectionChanged ), NULL, this );
m_dirChoices->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DLG_SELECT_3D_MODELE_BASE::SetRootDir ), NULL, this );
m_cfgPathsButt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_SELECT_3D_MODELE_BASE::Cfg3DPaths ), NULL, this );
}
DLG_SELECT_3D_MODELE_BASE::~DLG_SELECT_3D_MODELE_BASE()
{
// Disconnect Events
m_FileTree->Disconnect( wxEVT_DIRCTRL_FILEACTIVATED, wxCommandEventHandler( DLG_SELECT_3D_MODELE_BASE::OnFileActivated ), NULL, this );
m_FileTree->Disconnect( wxEVT_DIRCTRL_SELECTIONCHANGED, wxCommandEventHandler( DLG_SELECT_3D_MODELE_BASE::OnSelectionChanged ), NULL, this );
m_dirChoices->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DLG_SELECT_3D_MODELE_BASE::SetRootDir ), NULL, this );
m_cfgPathsButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_SELECT_3D_MODELE_BASE::Cfg3DPaths ), NULL, this );
}

View File

@ -0,0 +1,73 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 10 2019)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/dirctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/splitter.h>
#include <wx/stattext.h>
#include <wx/choice.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DLG_SELECT_3D_MODELE_BASE
///////////////////////////////////////////////////////////////////////////////
class DLG_SELECT_3D_MODELE_BASE : public DIALOG_SHIM
{
private:
protected:
wxSplitterWindow* m_splitterWin;
wxPanel* m_panelLeft;
wxGenericDirCtrl* m_FileTree;
wxPanel* m_pane3Dviewer;
wxBoxSizer* m_Sizer3Dviewer;
wxStaticText* m_stDirChoice;
wxChoice* m_dirChoices;
wxButton* m_cfgPathsButt;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnFileActivated( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSelectionChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void SetRootDir( wxCommandEvent& event ) { event.Skip(); }
virtual void Cfg3DPaths( wxCommandEvent& event ) { event.Skip(); }
public:
DLG_SELECT_3D_MODELE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select 3D Model"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 468,347 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DLG_SELECT_3D_MODELE_BASE();
void m_splitterWinOnIdle( wxIdleEvent& )
{
m_splitterWin->SetSashPosition( 340 );
m_splitterWin->Disconnect( wxEVT_IDLE, wxIdleEventHandler( DLG_SELECT_3D_MODELE_BASE::m_splitterWinOnIdle ), NULL, this );
}
};

View File

@ -30,6 +30,7 @@ set(3D-VIEWER_SRCS
3d_cache/3d_cache.cpp 3d_cache/3d_cache.cpp
3d_cache/3d_plugin_manager.cpp 3d_cache/3d_plugin_manager.cpp
${DIR_DLG}/3d_cache_dialogs.cpp ${DIR_DLG}/3d_cache_dialogs.cpp
${DIR_DLG}/dlg_select_3dmodel_base.cpp
${DIR_DLG}/dlg_select_3dmodel.cpp ${DIR_DLG}/dlg_select_3dmodel.cpp
${DIR_DLG}/panel_prev_3d_base.cpp ${DIR_DLG}/panel_prev_3d_base.cpp
${DIR_DLG}/panel_prev_3d.cpp ${DIR_DLG}/panel_prev_3d.cpp