diff --git a/3d-viewer/3d_cache/3d_cache.cpp b/3d-viewer/3d_cache/3d_cache.cpp index 46d9acadf2..a8b66b5eb4 100644 --- a/3d-viewer/3d_cache/3d_cache.cpp +++ b/3d-viewer/3d_cache/3d_cache.cpp @@ -43,7 +43,7 @@ #include "3d_cache.h" #include "3d_info.h" #include "sg/scenegraph.h" -#include "3d_filename_resolver.h" +#include "filename_resolver.h" #include "3d_plugin_manager.h" #include "plugins/3dapi/ifsg_api.h" @@ -180,7 +180,7 @@ const wxString S3D_CACHE_ENTRY::GetCacheBaseName( void ) S3D_CACHE::S3D_CACHE() { m_DirtyCache = false; - m_FNResolver = new S3D_FILENAME_RESOLVER; + m_FNResolver = new FILENAME_RESOLVER; m_Plugins = new S3D_PLUGIN_MANAGER; return; @@ -217,7 +217,7 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCach // check cache if file is already loaded wxCriticalSectionLocker lock( lock3D_cache ); - std::map< wxString, S3D_CACHE_ENTRY*, S3D::rsort_wxString >::iterator mi; + std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString >::iterator mi; mi = m_CacheMap.find( full3Dpath ); if( mi != m_CacheMap.end() ) @@ -736,7 +736,7 @@ wxString S3D_CACHE::GetProjectDir( void ) } -S3D_FILENAME_RESOLVER* S3D_CACHE::GetResolver( void ) +FILENAME_RESOLVER* S3D_CACHE::GetResolver( void ) { return m_FNResolver; } @@ -818,7 +818,7 @@ wxString S3D_CACHE::GetModelHash( const wxString& aModelFileName ) return wxEmptyString; // check cache if file is already loaded - std::map< wxString, S3D_CACHE_ENTRY*, S3D::rsort_wxString >::iterator mi; + std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString >::iterator mi; mi = m_CacheMap.find( full3Dpath ); if( mi != m_CacheMap.end() ) diff --git a/3d-viewer/3d_cache/3d_cache.h b/3d-viewer/3d_cache/3d_cache.h index 08d901ef3b..305790ff8a 100644 --- a/3d-viewer/3d_cache/3d_cache.h +++ b/3d-viewer/3d_cache/3d_cache.h @@ -32,8 +32,8 @@ #include #include #include -#include "str_rsort.h" -#include "3d_filename_resolver.h" +#include "kicad_string.h" +#include "filename_resolver.h" #include "3d_info.h" #include "plugins/3dapi/c3dmodel.h" @@ -42,7 +42,7 @@ class PGM_BASE; class S3D_CACHE; class S3D_CACHE_ENTRY; class SCENEGRAPH; -class S3D_FILENAME_RESOLVER; +class FILENAME_RESOLVER; class S3D_PLUGIN_MANAGER; @@ -53,10 +53,10 @@ private: std::list< S3D_CACHE_ENTRY* > m_CacheList; /// mapping of file names to cache names and data - std::map< wxString, S3D_CACHE_ENTRY*, S3D::rsort_wxString > m_CacheMap; + std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString > m_CacheMap; /// object to resolve file names - S3D_FILENAME_RESOLVER* m_FNResolver; + FILENAME_RESOLVER* m_FNResolver; /// plugin manager S3D_PLUGIN_MANAGER* m_Plugins; @@ -167,7 +167,7 @@ public: */ SCENEGRAPH* Load( const wxString& aModelFile ); - S3D_FILENAME_RESOLVER* GetResolver( void ); + FILENAME_RESOLVER* GetResolver( void ); /** * Function GetFileFilters diff --git a/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp b/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp index 8fb29884ce..f01ad0944f 100644 --- a/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp +++ b/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp @@ -27,7 +27,7 @@ #include "3d_cache.h" #include "plugins/3dapi/ifsg_api.h" #include "3d_cache_dialogs.h" -#include "dlg_3d_pathconfig.h" +#include "dialog_configure_paths.h" #include "dlg_select_3dmodel.h" @@ -51,16 +51,9 @@ bool S3D::Select3DModel( wxWindow* aParent, S3D_CACHE* aCache, } -bool S3D::Configure3DPaths( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ) +bool S3D::Configure3DPaths( wxWindow* aParent, FILENAME_RESOLVER* aResolver ) { - DLG_3D_PATH_CONFIG* dp = new DLG_3D_PATH_CONFIG( aParent, aResolver ); + DIALOG_CONFIGURE_PATHS dlg( aParent, aResolver ); - if( wxID_OK == dp->ShowModal() ) - { - delete dp; - return true; - } - - delete dp; - return false; + return( dlg.ShowModal() == wxID_OK ); } diff --git a/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.h b/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.h index e6731f938c..7693d02bed 100644 --- a/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.h +++ b/3d-viewer/3d_cache/dialogs/3d_cache_dialogs.h @@ -27,14 +27,14 @@ #include class S3D_CACHE; -class S3D_FILENAME_RESOLVER; +class FILENAME_RESOLVER; namespace S3D { bool Select3DModel( wxWindow* aParent, S3D_CACHE* aCache, wxString& prevModelSelectDir, int& prevModelWildcard, MODULE_3D_SETTINGS* aModel ); - bool Configure3DPaths( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ); + bool Configure3DPaths( wxWindow* aParent, FILENAME_RESOLVER* aResolver ); } #endif // CACHE_DIALOGS_3D_H diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp deleted file mode 100644 index 2f73c8563d..0000000000 --- a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 Cirilo Bernardo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#include -#include -#include -#include "3d_cache/dialogs/dlg_3d_pathconfig.h" -#include "3d_cache/3d_filename_resolver.h" - -DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ) : - DLG_3D_PATH_CONFIG_BASE( aParent ), m_resolver( aResolver ) -{ - initDialog(); - - GetSizer()->SetSizeHints( this ); - Centre(); - - return; -} - - -void DLG_3D_PATH_CONFIG::initDialog() -{ - m_Aliases->EnableEditing( true ); - - // Gives a min width to each column, when the user drags a column - m_Aliases->SetColMinimalWidth( 0, 80 ); - m_Aliases->SetColMinimalWidth( 1, 300 ); - m_Aliases->SetColMinimalWidth( 2, 120 ); - m_Aliases->SetColMinimalAcceptableWidth( 80 ); - - // Set column sizes to this min value - m_Aliases->SetColSize( 0, 80 ); - m_Aliases->SetColSize( 1, 300 ); - m_Aliases->SetColSize( 2, 120 ); - - m_EnvVars->SetColMinimalWidth( 0, 80 ); - m_EnvVars->SetColMinimalWidth( 1, 300 ); - m_EnvVars->SetColMinimalAcceptableWidth( 80 ); - m_EnvVars->SetColSize( 0, 80 ); - m_EnvVars->SetColSize( 1, 300 ); - - if( m_resolver ) - { - updateEnvVars(); - - // prohibit these characters in the alias names: []{}()%~<>"='`;:.,&?/\|$ - m_aliasValidator.SetStyle( wxFILTER_EXCLUDE_CHAR_LIST ); - m_aliasValidator.SetCharExcludes( wxT( "{}[]()%~<>\"='`;:.,&?/\\|$" ) ); - - const std::list< S3D_ALIAS >* rpaths = m_resolver->GetPaths(); - std::list< S3D_ALIAS >::const_iterator rI = rpaths->begin(); - std::list< S3D_ALIAS >::const_iterator rE = rpaths->end(); - size_t listsize = rpaths->size(); - size_t listidx = 0; - - while( rI != rE && ( (*rI).m_alias.StartsWith( "${" ) || (*rI).m_alias.StartsWith( "$(" ) ) ) - { - ++listidx; - ++rI; - } - - if( listidx < listsize ) - m_curdir = (*rI).m_pathexp; - else - return; - - listsize = listsize - listidx - m_Aliases->GetNumberRows(); - - // note: if the list allocation fails we have bigger problems - // and there is no point in trying to notify the user here - if( listsize > 0 && !m_Aliases->InsertRows( 0, listsize ) ) - return; - - int nitems = 0; - wxGridCellTextEditor* pEdAlias; - - while( rI != rE ) - { - m_Aliases->SetCellValue( nitems, 0, rI->m_alias ); - - if( 0 == nitems ) - { - m_Aliases->SetCellEditor( nitems, 0, new wxGridCellTextEditor ); - pEdAlias = (wxGridCellTextEditor*) m_Aliases->GetCellEditor( nitems, 0 ); - pEdAlias->SetValidator( m_aliasValidator ); - pEdAlias->DecRef(); - } - else - { - pEdAlias->IncRef(); - m_Aliases->SetCellEditor( nitems, 0, pEdAlias ); - } - - m_Aliases->SetCellValue( nitems, 1, rI->m_pathvar ); - m_Aliases->SetCellValue( nitems++, 2, rI->m_description ); - - // TODO: implement a wxGridCellEditor which invokes a wxDirDialog - - ++rI; - } - - m_Aliases->AutoSize(); - } -} - - -bool DLG_3D_PATH_CONFIG::TransferDataFromWindow() -{ - if( NULL == m_resolver ) - { - wxMessageBox( _( "[BUG] No valid resolver; data will not be updated" ), - _( "Update 3D search path list" ) ); - - return false; - } - - std::vector alist; - S3D_ALIAS alias; - - int ni = m_Aliases->GetNumberRows(); - - if( ni <= 0 ) - { - // note: UI usability: we should ask a user if they're sure they - // want to clear the entire path list - m_resolver->UpdatePathList( alist ); - return true; - } - - for( int i = 0; i < ni; ++i ) - { - alias.m_alias = m_Aliases->GetCellValue( i, 0 ); - alias.m_pathvar = m_Aliases->GetCellValue( i, 1 ); - alias.m_description = m_Aliases->GetCellValue( i, 2 ); - - if( !alias.m_alias.empty() && !alias.m_pathvar.empty() ) - alist.push_back( alias ); - - } - - return m_resolver->UpdatePathList( alist ); -} - - -void DLG_3D_PATH_CONFIG::OnAddAlias( wxCommandEvent& event ) -{ - int ni = m_Aliases->GetNumberRows(); - - if( m_Aliases->InsertRows( ni, 1 ) ) - { - wxGridCellTextEditor* pEdAlias; - pEdAlias = (wxGridCellTextEditor*) m_Aliases->GetCellEditor( 0, 0 ); - m_Aliases->SetCellEditor( ni, 0, pEdAlias ); - m_Aliases->SelectRow( ni, false ); - m_Aliases->AutoSize(); - Fit(); - - // TODO: set the editors on any newly created rows - } - - event.Skip(); -} - - -void DLG_3D_PATH_CONFIG::OnDelAlias( wxCommandEvent& event ) -{ - wxArrayInt sel = m_Aliases->GetSelectedRows(); - - if( sel.empty() ) - { - wxMessageBox( _( "No entry selected" ), _( "Delete alias entry" ) ); - return; - } - - if( sel.size() > 1 ) - { - wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ), - _( "Delete alias entry" ) ); - return; - } - - if( m_Aliases->GetNumberRows() > 1 ) - { - int ni = sel.front(); - m_Aliases->DeleteRows( ni, 1 ); - - if( ni >= m_Aliases->GetNumberRows() ) - ni = m_Aliases->GetNumberRows() - 1; - - m_Aliases->SelectRow( ni, false ); - m_Aliases->AutoSize(); - Fit(); - } - else - { - m_Aliases->SetCellValue( 0, 0, wxEmptyString ); - m_Aliases->SetCellValue( 0, 1, wxEmptyString ); - m_Aliases->SetCellValue( 0, 2, wxEmptyString ); - } - - event.Skip(); -} - - -void DLG_3D_PATH_CONFIG::OnAliasMoveUp( wxCommandEvent& event ) -{ - wxArrayInt sel = m_Aliases->GetSelectedRows(); - - if( sel.empty() ) - { - wxMessageBox( _( "No entry selected" ), _( "Move alias up" ) ); - return; - } - - if( sel.size() > 1 ) - { - wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ), - _( "Move alias up" ) ); - return; - } - - int ci = sel.front(); - - if( ci > 0 ) - { - S3D_ALIAS al0; - al0.m_alias = m_Aliases->GetCellValue( ci, 0 ); - al0.m_pathvar = m_Aliases->GetCellValue( ci, 1 ); - al0.m_description = m_Aliases->GetCellValue( ci, 2 ); - - int ni = ci - 1; - m_Aliases->SetCellValue( ci, 0, m_Aliases->GetCellValue( ni, 0 ) ); - m_Aliases->SetCellValue( ci, 1, m_Aliases->GetCellValue( ni, 1 ) ); - m_Aliases->SetCellValue( ci, 2, m_Aliases->GetCellValue( ni, 2 ) ); - - m_Aliases->SetCellValue( ni, 0, al0.m_alias ); - m_Aliases->SetCellValue( ni, 1, al0.m_pathvar ); - m_Aliases->SetCellValue( ni, 2, al0.m_description ); - m_Aliases->SelectRow( ni, false ); - } - - event.Skip(); -} - - -void DLG_3D_PATH_CONFIG::OnAliasMoveDown( wxCommandEvent& event ) -{ - wxArrayInt sel = m_Aliases->GetSelectedRows(); - - if( sel.empty() ) - { - wxMessageBox( _( "No entry selected" ), _( "Move alias down" ) ); - return; - } - - if( sel.size() > 1 ) - { - wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ), - _( "Move alias down" ) ); - return; - } - - int ni = m_Aliases->GetNumberRows() - 1; - int ci = sel.front(); - - if( ci < ni ) - { - S3D_ALIAS al0; - al0.m_alias = m_Aliases->GetCellValue( ci, 0 ); - al0.m_pathvar = m_Aliases->GetCellValue( ci, 1 ); - al0.m_description = m_Aliases->GetCellValue( ci, 2 ); - - ni = ci + 1; - m_Aliases->SetCellValue( ci, 0, m_Aliases->GetCellValue( ni, 0 ) ); - m_Aliases->SetCellValue( ci, 1, m_Aliases->GetCellValue( ni, 1 ) ); - m_Aliases->SetCellValue( ci, 2, m_Aliases->GetCellValue( ni, 2 ) ); - - m_Aliases->SetCellValue( ni, 0, al0.m_alias ); - m_Aliases->SetCellValue( ni, 1, al0.m_pathvar ); - m_Aliases->SetCellValue( ni, 2, al0.m_description ); - m_Aliases->SelectRow( ni, false ); - } - - event.Skip(); -} - - -void DLG_3D_PATH_CONFIG::OnConfigEnvVar( wxCommandEvent& event ) -{ - Pgm().ConfigurePaths( this ); - updateEnvVars(); - event.Skip(); -} - - -void DLG_3D_PATH_CONFIG::updateEnvVars( void ) -{ - if( !m_resolver ) - return; - - std::list< wxString > epaths; - - m_resolver->GetKicadPaths( epaths ); - size_t nitems = epaths.size(); - size_t nrows = m_EnvVars->GetNumberRows(); - bool resize = nrows != nitems; // true after adding/removing env vars - - if( nrows > nitems ) - { - size_t ni = nrows - nitems; - m_EnvVars->DeleteRows( 0, ni ); - } - else if( nrows < nitems ) - { - size_t ni = nitems - nrows; - m_EnvVars->InsertRows( 0, ni ); - } - - int j = 0; - - for( const auto& i : epaths ) - { - wxString val = ExpandEnvVarSubstitutions( i ); - m_EnvVars->SetCellValue( j, 0, i ); - m_EnvVars->SetCellValue( j, 1, val ); - m_EnvVars->SetReadOnly( j, 0, true ); - m_EnvVars->SetReadOnly( j, 1, true ); - wxGridCellAttr* ap = m_EnvVars->GetOrCreateCellAttr( j, 0 ); - ap->SetReadOnly( true ); - ap->SetBackgroundColour( *wxLIGHT_GREY ); - m_EnvVars->SetRowAttr( j, ap ); - ++j; - } - - m_EnvVars->AutoSize(); - - // Resizing the full dialog is sometimes needed for a clean display - // i.e. when adding/removing Kicad environment variables - if( resize ) - GetSizer()->SetSizeHints( this ); - - return; -} - - -void DLG_3D_PATH_CONFIG::OnHelp( wxCommandEvent& event ) -{ - wxString msg = _( "Enter the name and path for each 3D alias variable.
KiCad " - "environment variables and their values are shown for " - "reference only and cannot be edited." ); - msg << "

"; - msg << _( "Alias names may not contain any of the characters " ); - msg << "{}[]()%~<>\"='`;:.,&?/\\|$"; - msg << ""; - - HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); - dlg.AddHTML_Text( msg ); - dlg.ShowModal(); - - event.Skip(); -} diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.h b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.h deleted file mode 100644 index e47681ca09..0000000000 --- a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 Cirilo Bernardo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#ifndef DLG_3D_PATHCONFIG_H -#define DLG_3D_PATHCONFIG_H - -#include -#include "dlg_3d_pathconfig_base.h" - -class S3D_FILENAME_RESOLVER; - -class DLG_3D_PATH_CONFIG : public DLG_3D_PATH_CONFIG_BASE -{ -private: - S3D_FILENAME_RESOLVER* m_resolver; - wxString m_curdir; - wxTextValidator m_aliasValidator; - - void initDialog(); - - void OnAddAlias( wxCommandEvent& event ) override; - void OnDelAlias( wxCommandEvent& event ) override; - void OnAliasMoveUp( wxCommandEvent& event ) override; - void OnAliasMoveDown( wxCommandEvent& event ) override; - void OnConfigEnvVar( wxCommandEvent& event ) override; - void OnHelp( wxCommandEvent& event ) override; - -public: - DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ); - bool TransferDataFromWindow() override; - -private: - void updateEnvVars( void ); -}; - -#endif // DLG_3D_PATHCONFIG_H diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.cpp b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.cpp deleted file mode 100644 index 43537b3304..0000000000 --- a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dlg_3d_pathconfig_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DLG_3D_PATH_CONFIG_BASE::DLG_3D_PATH_CONFIG_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( wxSize( -1,-1 ), wxDefaultSize ); - - wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizer5; - bSizer5 = new wxBoxSizer( wxVERTICAL ); - - m_EnvVars = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - - // Grid - m_EnvVars->CreateGrid( 1, 2 ); - m_EnvVars->EnableEditing( true ); - m_EnvVars->EnableGridLines( true ); - m_EnvVars->EnableDragGridSize( false ); - m_EnvVars->SetMargins( 0, 0 ); - - // Columns - m_EnvVars->SetColSize( 0, 150 ); - m_EnvVars->SetColSize( 1, 300 ); - m_EnvVars->EnableDragColMove( false ); - m_EnvVars->EnableDragColSize( true ); - m_EnvVars->SetColLabelSize( 30 ); - m_EnvVars->SetColLabelValue( 0, _("Name") ); - m_EnvVars->SetColLabelValue( 1, _("Path") ); - m_EnvVars->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Rows - m_EnvVars->EnableDragRowSize( true ); - m_EnvVars->SetRowLabelSize( 80 ); - m_EnvVars->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Label Appearance - - // Cell Defaults - m_EnvVars->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_EnvVars->SetMinSize( wxSize( 250,100 ) ); - - bSizer5->Add( m_EnvVars, 1, wxALL|wxEXPAND, 5 ); - - m_btnEnvCfg = new wxButton( this, wxID_ANY, _("Configure Environment Variables"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer5->Add( m_btnEnvCfg, 0, wxALIGN_CENTER|wxALL, 5 ); - - - bSizerMain->Add( bSizer5, 0, wxEXPAND, 5 ); - - m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 ); - - wxBoxSizer* bSizerGrid; - bSizerGrid = new wxBoxSizer( wxHORIZONTAL ); - - m_Aliases = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - - // Grid - m_Aliases->CreateGrid( 1, 3 ); - m_Aliases->EnableEditing( true ); - m_Aliases->EnableGridLines( true ); - m_Aliases->EnableDragGridSize( false ); - m_Aliases->SetMargins( 0, 0 ); - - // Columns - m_Aliases->SetColSize( 0, 80 ); - m_Aliases->SetColSize( 1, 300 ); - m_Aliases->SetColSize( 2, 120 ); - m_Aliases->EnableDragColMove( false ); - m_Aliases->EnableDragColSize( true ); - m_Aliases->SetColLabelSize( 30 ); - m_Aliases->SetColLabelValue( 0, _("Alias") ); - m_Aliases->SetColLabelValue( 1, _("Path") ); - m_Aliases->SetColLabelValue( 2, _("Description") ); - m_Aliases->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Rows - m_Aliases->AutoSizeRows(); - m_Aliases->EnableDragRowSize( false ); - m_Aliases->SetRowLabelSize( 80 ); - m_Aliases->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Label Appearance - - // Cell Defaults - m_Aliases->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_Aliases->SetMinSize( wxSize( -1,150 ) ); - - bSizerGrid->Add( m_Aliases, 1, wxALL|wxEXPAND, 5 ); - - - bSizerMain->Add( bSizerGrid, 1, wxEXPAND, 5 ); - - wxBoxSizer* bSizerButtons; - bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); - - m_btnAddAlias = new wxButton( this, wxID_ANY, _("Add Alias"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButtons->Add( m_btnAddAlias, 0, wxALL, 5 ); - - m_btnDelAlias = new wxButton( this, wxID_ANY, _("Remove Alias"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButtons->Add( m_btnDelAlias, 0, wxALL, 5 ); - - m_btnMoveUp = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButtons->Add( m_btnMoveUp, 0, wxALL, 5 ); - - m_btnMoveDown = new wxButton( this, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButtons->Add( m_btnMoveDown, 0, wxALL, 5 ); - - - bSizerMain->Add( bSizerButtons, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); - - m_sdbSizer2 = new wxStdDialogButtonSizer(); - m_sdbSizer2OK = new wxButton( this, wxID_OK ); - m_sdbSizer2->AddButton( m_sdbSizer2OK ); - m_sdbSizer2Cancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer2->AddButton( m_sdbSizer2Cancel ); - m_sdbSizer2Help = new wxButton( this, wxID_HELP ); - m_sdbSizer2->AddButton( m_sdbSizer2Help ); - m_sdbSizer2->Realize(); - - bSizerMain->Add( m_sdbSizer2, 0, wxALL|wxEXPAND, 5 ); - - - this->SetSizer( bSizerMain ); - this->Layout(); - bSizerMain->Fit( this ); - - this->Centre( wxBOTH ); - - // Connect Events - m_btnEnvCfg->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnConfigEnvVar ), NULL, this ); - m_btnAddAlias->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAddAlias ), NULL, this ); - m_btnDelAlias->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnDelAlias ), NULL, this ); - m_btnMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveUp ), NULL, this ); - m_btnMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveDown ), NULL, this ); - m_sdbSizer2Help->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnHelp ), NULL, this ); -} - -DLG_3D_PATH_CONFIG_BASE::~DLG_3D_PATH_CONFIG_BASE() -{ - // Disconnect Events - m_btnEnvCfg->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnConfigEnvVar ), NULL, this ); - m_btnAddAlias->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAddAlias ), NULL, this ); - m_btnDelAlias->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnDelAlias ), NULL, this ); - m_btnMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveUp ), NULL, this ); - m_btnMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveDown ), NULL, this ); - m_sdbSizer2Help->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnHelp ), NULL, this ); - -} diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp deleted file mode 100644 index 08abd96a56..0000000000 --- a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp +++ /dev/null @@ -1,1046 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dlg_3d_pathconfig_base - 1000 - none - 1 - MyProject1 - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - -1,-1 - DLG_3D_PATH_CONFIG_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - 3D Search Path Configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerMain - wxVERTICAL - none - - 5 - wxEXPAND - 0 - - - bSizer5 - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - 0 - - - - 1 - - - wxALIGN_LEFT - - wxALIGN_TOP - 0 - 1 - wxALIGN_CENTRE - 30 - "Name" "Path" - wxALIGN_CENTRE - 2 - 150,300 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - 0 - 1 - 1 - 1 - - 1 - - - 1 - 0 - 0 - wxID_ANY - - - - 0 - 0 - - 0 - - - 0 - 250,100 - 1 - m_EnvVars - 1 - - - protected - 1 - - Resizable - wxALIGN_CENTRE - 80 - - wxALIGN_CENTRE - - 1 - 1 - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Configure Environment Variables - - 0 - - - 0 - - 1 - m_btnEnvCfg - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnConfigEnvVar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND | wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline2 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - -1,-1 - bSizerGrid - wxHORIZONTAL - none - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - 1 - - - - 1 - - - wxALIGN_LEFT - - wxALIGN_TOP - 0 - 1 - wxALIGN_CENTRE - 30 - "Alias" "Path" "Description" - wxALIGN_CENTRE - 3 - 80,300,120 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - 0 - 0 - 1 - 1 - - 1 - - - 1 - 0 - 0 - wxID_ANY - - - - 0 - 0 - - 0 - - - 0 - -1,150 - 1 - m_Aliases - 1 - - - protected - 1 - - Resizable - wxALIGN_CENTRE - 80 - - wxALIGN_CENTRE - - 1 - 1 - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_HORIZONTAL - 0 - - - bSizerButtons - wxHORIZONTAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Add Alias - - 0 - - - 0 - - 1 - m_btnAddAlias - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnAddAlias - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Remove Alias - - 0 - - - 0 - - 1 - m_btnDelAlias - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnDelAlias - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Move Up - - 0 - - - 0 - - 1 - m_btnMoveUp - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnAliasMoveUp - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Move Down - - 0 - - - 0 - - 1 - m_btnMoveDown - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnAliasMoveDown - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND | wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline1 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 0 - - m_sdbSizer2 - protected - - - - OnHelp - - - - - - - - - - diff --git a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.h b/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.h deleted file mode 100644 index 5aee0aaca7..0000000000 --- a/3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.h +++ /dev/null @@ -1,67 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __DLG_3D_PATHCONFIG_BASE_H__ -#define __DLG_3D_PATHCONFIG_BASE_H__ - -#include -#include -#include -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class DLG_3D_PATH_CONFIG_BASE -/////////////////////////////////////////////////////////////////////////////// -class DLG_3D_PATH_CONFIG_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxGrid* m_EnvVars; - wxButton* m_btnEnvCfg; - wxStaticLine* m_staticline2; - wxGrid* m_Aliases; - wxButton* m_btnAddAlias; - wxButton* m_btnDelAlias; - wxButton* m_btnMoveUp; - wxButton* m_btnMoveDown; - wxStaticLine* m_staticline1; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2OK; - wxButton* m_sdbSizer2Cancel; - wxButton* m_sdbSizer2Help; - - // Virtual event handlers, overide them in your derived class - virtual void OnConfigEnvVar( wxCommandEvent& event ) { event.Skip(); } - virtual void OnAddAlias( wxCommandEvent& event ) { event.Skip(); } - virtual void OnDelAlias( wxCommandEvent& event ) { event.Skip(); } - virtual void OnAliasMoveUp( wxCommandEvent& event ) { event.Skip(); } - virtual void OnAliasMoveDown( wxCommandEvent& event ) { event.Skip(); } - virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("3D Search Path Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DLG_3D_PATH_CONFIG_BASE(); - -}; - -#endif //__DLG_3D_PATHCONFIG_BASE_H__ diff --git a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp index 7ba2847a61..938dd535bf 100644 --- a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp +++ b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp @@ -240,9 +240,9 @@ void DLG_SELECT_3DMODEL::updateDirChoiceList( void ) if( NULL == m_FileTree || NULL == m_resolver || NULL == dirChoices ) return; - std::list< S3D_ALIAS > const* md = m_resolver->GetPaths(); - std::list< S3D_ALIAS >::const_iterator sL = md->begin(); - std::list< S3D_ALIAS >::const_iterator eL = md->end(); + std::list< SEARCH_PATH > const* md = m_resolver->GetPaths(); + std::list< SEARCH_PATH >::const_iterator sL = md->begin(); + std::list< SEARCH_PATH >::const_iterator eL = md->end(); std::set< wxString > cl; wxString prjDir; diff --git a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h index bbee1a18f6..e6e32d5cb8 100644 --- a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h +++ b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h @@ -43,7 +43,7 @@ class MODULE_3D_SETTINGS; class S3D_CACHE; -class S3D_FILENAME_RESOLVER; +class FILENAME_RESOLVER; class C3D_MODEL_VIEWER; class DLG_SELECT_3DMODEL : public DIALOG_SHIM @@ -51,7 +51,7 @@ class DLG_SELECT_3DMODEL : public DIALOG_SHIM private: MODULE_3D_SETTINGS* m_model; // data for the selected model S3D_CACHE* m_cache; // cache manager - S3D_FILENAME_RESOLVER* m_resolver; // 3D filename resolver + FILENAME_RESOLVER* m_resolver; // 3D filename resolver wxString& m_previousDir; int& m_previousFilterIndex; diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.h b/3d-viewer/3d_cache/dialogs/panel_prev_model.h index 264b36d65a..7c7b982feb 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_model.h +++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.h @@ -47,23 +47,23 @@ #define MAX_ROTATION 180.0 #define MAX_OFFSET 1000.0 -#define SCALE_INCREMENT_FINE 0.02 -#define SCALE_INCREMENT 0.1 +#define SCALE_INCREMENT_FINE 0.02 +#define SCALE_INCREMENT 0.1 #define ROTATION_INCREMENT 5 // in degrees, for spin button command #define ROTATION_INCREMENT_WHEEL 15 // in degrees, for mouse wheel command #define ROTATION_INCREMENT_WHEEL_FINE 1 // in degrees, for mouse wheel command -#define OFFSET_INCREMENT_MM 0.5 -#define OFFSET_INCREMENT_MM_FINE 0.1 +#define OFFSET_INCREMENT_MM 0.5 +#define OFFSET_INCREMENT_MM_FINE 0.1 -#define OFFSET_INCREMENT_MIL 25.0 -#define OFFSET_INCREMENT_MIL_FINE 5.0 +#define OFFSET_INCREMENT_MIL 25.0 +#define OFFSET_INCREMENT_MIL_FINE 5.0 // Declared classes to create pointers class S3D_CACHE; -class S3D_FILENAME_RESOLVER; +class FILENAME_RESOLVER; class BOARD; class CINFO3D_VISU; class MODULE; @@ -80,31 +80,31 @@ public: ~PANEL_PREV_3D(); private: - wxString currentModelFile; ///< Used to check if the model file was changed - S3D_FILENAME_RESOLVER *m_resolver; ///< Used to get the full path name + wxString currentModelFile; ///< Used to check if the model file was changed + FILENAME_RESOLVER *m_resolver; ///< Used to get the full path name /// The 3D canvas - EDA_3D_CANVAS *m_previewPane; + EDA_3D_CANVAS *m_previewPane; /// A dummy board used to store the copy moduled - BOARD *m_dummyBoard; + BOARD *m_dummyBoard; /// The settings that will be used for this 3D viewer canvas - CINFO3D_VISU *m_settings3Dviewer; + CINFO3D_VISU *m_settings3Dviewer; /// A pointer to a new copy of the original module - MODULE *m_copyModule; + MODULE *m_copyModule; /// A pointer to the parent MODULE_3D_SETTINGS list that we will use to copy to the preview module std::vector *m_parentInfoList; /// The current selected index of the MODULE_3D_SETTINGS list - int m_currentSelectedIdx; + int m_currentSelectedIdx; /// Current MODULE_3D_SETTINGS that is being edited - MODULE_3D_SETTINGS m_modelInfo; + MODULE_3D_SETTINGS m_modelInfo; - EDA_UNITS_T m_userUnits; + EDA_UNITS_T m_userUnits; // Methods of the class private: diff --git a/3d-viewer/3d_cache/str_rsort.h b/3d-viewer/3d_cache/str_rsort.h deleted file mode 100644 index 35044c6d71..0000000000 --- a/3d-viewer/3d_cache/str_rsort.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Cirilo Bernardo - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * @file str_rsort.h - * provides a wxString sorting functino which works from the - * end of the string towards the beginning - */ - -#ifndef STR_RSORT_H -#define STR_RSORT_H - -#include - -namespace S3D -{ - - struct rsort_wxString - { - bool operator() (const wxString& strA, const wxString& strB ) const - { - // sort a wxString using the reverse character order; for 3d model - // filenames this will typically be a much faster operation than - // a normal alphabetic sort - wxString::const_reverse_iterator sA = strA.rbegin(); - wxString::const_reverse_iterator eA = strA.rend(); - - wxString::const_reverse_iterator sB = strB.rbegin(); - wxString::const_reverse_iterator eB = strB.rend(); - - if( strA.empty() ) - { - if( strB.empty() ) - return false; - - // note: this rule implies that a null string is first in the sort order - return true; - } - - if( strB.empty() ) - return false; - - while( sA != eA && sB != eB ) - { - if( (*sA) == (*sB) ) - { - ++sA; - ++sB; - continue; - } - - if( (*sA) < (*sB) ) - return true; - else - return false; - } - - if( sB == eB ) - return false; - - return true; - } - }; - -} // end NAMESPACE - -#endif // STR_RSORT_H diff --git a/3d-viewer/CMakeLists.txt b/3d-viewer/CMakeLists.txt index 5d6cb66fe1..76ce150944 100644 --- a/3d-viewer/CMakeLists.txt +++ b/3d-viewer/CMakeLists.txt @@ -33,10 +33,7 @@ set(3D-VIEWER_SRCS 3d_cache/3d_cache_wrapper.cpp 3d_cache/3d_cache.cpp 3d_cache/3d_plugin_manager.cpp - 3d_cache/3d_filename_resolver.cpp ${DIR_DLG}/3d_cache_dialogs.cpp - ${DIR_DLG}/dlg_3d_pathconfig_base.cpp - ${DIR_DLG}/dlg_3d_pathconfig.cpp ${DIR_DLG}/dlg_select_3dmodel.cpp ${DIR_DLG}/panel_prev_3d_base.cpp ${DIR_DLG}/panel_prev_model.cpp diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index a7719d4d60..4db26187df 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -153,9 +153,9 @@ set( COMMON_ABOUT_DLG_SRCS ) set( COMMON_DLG_SRCS + dialogs/dialog_configure_paths.cpp + dialogs/dialog_configure_paths_base.cpp dialogs/dialog_display_info_HTML_base.cpp - dialogs/dialog_env_var_config.cpp - dialogs/dialog_env_var_config_base.cpp dialogs/dialog_exit_base.cpp dialogs/dialog_file_dir_picker.cpp dialogs/dialog_hotkeys_editor.cpp @@ -261,6 +261,7 @@ set( COMMON_SRCS env_paths.cpp exceptions.cpp executable_names.cpp + filename_resolver.cpp filter_reader.cpp footprint_filter.cpp footprint_info.cpp diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 98adf34154..6bbd534866 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -81,8 +81,8 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl } else { - wxFAIL_MSG( wxString::Format( "No KIWAY_HOLDER in parent chain. Top window is a %s.", - aParent->GetClassInfo()->GetClassName() ) ); + // There are a few dialogs, such as Configure Paths, which are called + // from the top-level wxFrame. m_units = MILLIMETRES; } diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp new file mode 100644 index 0000000000..ba063f8411 --- /dev/null +++ b/common/dialogs/dialog_configure_paths.cpp @@ -0,0 +1,565 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2015 Wayne Stambaugh + * Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#include +#include +#include +#include +#include + + +enum ENV_VAR_GRID_COLUMNS +{ + EV_NAME_COL = 0, + EV_PATH_COL, + EV_FLAG_COL +}; + +enum SEARCH_PATH_GRID_COLUMNS +{ + SP_ALIAS_COL = 0, + SP_PATH_COL, + SP_DESC_COL +}; + + +DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESOLVER* aResolver ) : + DIALOG_CONFIGURE_PATHS_BASE( aParent ), + m_errorGrid( nullptr ), + m_resolver( aResolver ) +{ + m_btnAddEnvVar->SetBitmap( KiBitmap( small_plus_xpm ) ); + m_btnDeleteEnvVar->SetBitmap( KiBitmap( trash_xpm ) ); + m_btnAddSearchPath->SetBitmap( KiBitmap( small_plus_xpm ) ); + m_btnDeleteSearchPath->SetBitmap( KiBitmap( trash_xpm ) ); + m_btnMoveUp->SetBitmap( KiBitmap( small_up_xpm ) ); + m_btnMoveDown->SetBitmap( KiBitmap( small_down_xpm ) ); + + m_EnvVars->DeleteRows( 0, m_EnvVars->GetNumberRows() ); + m_EnvVars->AppendCols( 1 ); // for the isExternal flags + m_EnvVars->HideCol( EV_FLAG_COL ); + m_EnvVars->UseNativeColHeader( true ); + + if( m_resolver ) + { + m_SearchPaths->DeleteRows( 0, m_SearchPaths->GetNumberRows() ); + m_SearchPaths->UseNativeColHeader( true ); + + // prohibit these characters in the alias names: []{}()%~<>"='`;:.,&?/\|$ + m_aliasValidator.SetStyle( wxFILTER_EXCLUDE_CHAR_LIST ); + m_aliasValidator.SetCharExcludes( wxT( "{}[]()%~<>\"='`;:.,&?/\\|$" ) ); + } + else + m_sb3DSearchPaths->Show( false ); + + SetInitialFocus( m_EnvVars ); + m_sdbSizerOK->SetDefault(); + + // wxFormBuilder doesn't include this event... + m_EnvVars->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this ); + m_SearchPaths->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this ); + + GetSizer()->SetSizeHints( this ); + Centre(); +} + + +DIALOG_CONFIGURE_PATHS::~DIALOG_CONFIGURE_PATHS() +{ + m_EnvVars->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this ); + m_SearchPaths->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this ); +} + + +bool DIALOG_CONFIGURE_PATHS::TransferDataToWindow() +{ + if( !wxDialog::TransferDataToWindow() ) + return false; + + // Environment variables + + const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables(); + + for( auto it = envVars.begin(); it != envVars.end(); ++it ) + AppendEnvVar( it->first, it->second.GetValue(), it->second.GetDefinedExternally() ); + + // 3D search paths + + if( m_resolver ) + { + const std::list* paths = m_resolver->GetPaths(); + auto it = paths->begin(); + + while( it != paths->end() + && ( ( *it ).m_alias.StartsWith( "${" ) || ( *it ).m_alias.StartsWith( "$(" ) ) ) + ++it; + + if( it != paths->end() ) + m_curdir = ( *it ).m_pathexp; + + for( ; it != paths->end(); ++it ) + AppendSearchPath( it->m_alias, it->m_pathvar, it->m_description ); + } + + return true; +} + + +void DIALOG_CONFIGURE_PATHS::AppendEnvVar( const wxString& aName, const wxString& aPath, + bool isExternal ) +{ + int i = m_EnvVars->GetNumberRows(); + + m_EnvVars->AppendRows( 1 ); + + m_EnvVars->SetCellValue( i, EV_NAME_COL, aName ); + + wxGridCellAttr* nameCellAttr = m_EnvVars->GetOrCreateCellAttr( i, EV_NAME_COL ); + wxGridCellTextEditor* nameTextEditor = new GRID_CELL_TEXT_EDITOR(); + nameTextEditor->SetValidator( ENV_VAR_NAME_VALIDATOR() ); + nameCellAttr->SetEditor( nameTextEditor ); + nameCellAttr->SetReadOnly( IsEnvVarImmutable( aName ) ); + nameCellAttr->DecRef(); + + m_EnvVars->SetCellValue( i, EV_PATH_COL, aPath ); + + wxGridCellAttr* pathCellAttr = m_EnvVars->GetOrCreateCellAttr( i, EV_PATH_COL ); + wxSystemColour c = isExternal ? wxSYS_COLOUR_MENU : wxSYS_COLOUR_LISTBOX; + pathCellAttr->SetBackgroundColour( wxSystemSettings::GetColour( c ) ); + pathCellAttr->DecRef(); + + m_EnvVars->SetCellValue( i, EV_FLAG_COL, isExternal ? wxT( "external" ) : wxEmptyString ); +} + + +void DIALOG_CONFIGURE_PATHS::AppendSearchPath( const wxString& aName, const wxString& aPath, + const wxString& aDescription ) +{ + int i = m_SearchPaths->GetNumberRows(); + + m_SearchPaths->AppendRows( 1 ); + + m_SearchPaths->SetCellValue( i, SP_ALIAS_COL, aName ); + + wxGridCellAttr* nameCellAttr = m_SearchPaths->GetOrCreateCellAttr( i, SP_ALIAS_COL ); + wxGridCellTextEditor* nameTextEditor = new GRID_CELL_TEXT_EDITOR(); + nameTextEditor->SetValidator( m_aliasValidator ); + nameCellAttr->SetEditor( nameTextEditor ); + nameCellAttr->DecRef(); + + m_SearchPaths->SetCellValue( i, SP_PATH_COL, aPath ); + m_SearchPaths->SetCellValue( i, SP_DESC_COL, aDescription ); +} + + +bool DIALOG_CONFIGURE_PATHS::TransferDataFromWindow() +{ + if( !wxDialog::TransferDataFromWindow() ) + return false; + + // Commit any pending in-place edits and close the editor + m_EnvVars->DisableCellEditControl(); + m_SearchPaths->DisableCellEditControl(); + + // Environment variables + + ENV_VAR_MAP envVarMap; + + for( int row = 0; row < m_EnvVars->GetNumberRows(); ++row ) + { + wxString name = m_EnvVars->GetCellValue( row, EV_NAME_COL ); + wxString path = m_EnvVars->GetCellValue( row, EV_PATH_COL ); + + if( name.IsEmpty() ) + { + m_errorGrid = m_EnvVars; + m_errorRow = row; + m_errorCol = EV_NAME_COL; + m_errorMsg = _( "Environment variable name cannot be empty." ); + return false; + } + else if( path.IsEmpty() ) + { + m_errorGrid = m_EnvVars; + m_errorRow = row; + m_errorCol = EV_PATH_COL; + m_errorMsg = _( "Environment variable path cannot be empty." ); + return false; + } + + envVarMap[ name ] = ENV_VAR_ITEM( path ); + } + + Pgm().SetLocalEnvVariables( envVarMap ); + + // 3D search paths + + if( m_resolver ) + { + std::vector alist; + SEARCH_PATH alias; + + for( int row = 0; row < m_SearchPaths->GetNumberRows(); ++row ) + { + alias.m_alias = m_SearchPaths->GetCellValue( row, SP_ALIAS_COL ); + alias.m_pathvar = m_SearchPaths->GetCellValue( row, SP_PATH_COL ); + alias.m_description = m_SearchPaths->GetCellValue( row, SP_DESC_COL ); + + if( alias.m_alias.IsEmpty() ) + { + m_errorGrid = m_SearchPaths; + m_errorRow = row; + m_errorCol = SP_ALIAS_COL; + m_errorMsg = _( "3D search path alias cannot be empty." ); + return false; + } + else if( alias.m_pathvar.IsEmpty() ) + { + m_errorGrid = m_SearchPaths; + m_errorRow = row; + m_errorCol = SP_PATH_COL; + m_errorMsg = _( "3D search path cannot be empty." ); + return false; + } + + alist.push_back( alias ); + } + + if( !m_resolver->UpdatePathList( alist ) ) + return false; + } + + return true; +} + + +void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event ) +{ + wxGrid* grid = dynamic_cast( event.GetEventObject() ); + int row = event.GetRow(); + int col = event.GetCol(); + wxString text = event.GetString(); + + if( text.IsEmpty() ) + { + if( grid == m_EnvVars ) + { + if( col == EV_NAME_COL ) + m_errorMsg = _( "Environment variable name cannot be empty." ); + else + m_errorMsg = _( "Environment variable path cannot be empty." ); + } + else + { + if( col == SP_ALIAS_COL ) + m_errorMsg = _( "3D search path alias cannot be empty." ); + else + m_errorMsg = _( "3D search path cannot be empty." ); + } + m_errorGrid = dynamic_cast( event.GetEventObject() ); + m_errorRow = row; + m_errorCol = col; + + event.Veto(); + } + + if( grid == m_EnvVars ) + { + if( col == EV_PATH_COL && m_EnvVars->GetCellValue( row, EV_FLAG_COL ).Length() ) + { + wxString msg1 = _( "This path was defined externally to the running process and\n" + "will only be temporarily overwritten." ); + wxString msg2 = _( "The next time KiCad is launched, any paths that have already\n" + "been defined are honored and any settings defined in the path\n" + "configuration dialog are ignored. If you did not intend for\n" + "this behavior, either rename any conflicting entries or remove\n" + "the external environment variable(s) from your system." ); + KIDIALOG dlg( this, msg1, KIDIALOG::KD_WARNING ); + dlg.ShowDetailedText( msg2 ); + dlg.DoNotShowCheckbox(); + dlg.ShowModal(); + } + else if( col == EV_NAME_COL && m_EnvVars->GetCellValue( row, EV_NAME_COL ) != text ) + { + // Changing name; clear external flag + m_EnvVars->SetCellValue( row, EV_FLAG_COL, wxEmptyString ); + } + } +} + + +void DIALOG_CONFIGURE_PATHS::OnAddEnvVar( wxCommandEvent& event ) +{ + AppendEnvVar( wxEmptyString, wxEmptyString, false ); + + m_EnvVars->MakeCellVisible( m_EnvVars->GetNumberRows() - 1, EV_NAME_COL ); + m_EnvVars->SetGridCursor( m_EnvVars->GetNumberRows() - 1, EV_NAME_COL ); + + m_EnvVars->EnableCellEditControl( true ); + m_EnvVars->ShowCellEditControl(); +} + + +void DIALOG_CONFIGURE_PATHS::OnAddSearchPath( wxCommandEvent& event ) +{ + AppendSearchPath( wxEmptyString, wxEmptyString, wxEmptyString); + + m_SearchPaths->MakeCellVisible( m_SearchPaths->GetNumberRows() - 1, SP_ALIAS_COL ); + m_SearchPaths->SetGridCursor( m_SearchPaths->GetNumberRows() - 1, SP_ALIAS_COL ); + + m_SearchPaths->EnableCellEditControl( true ); + m_SearchPaths->ShowCellEditControl(); +} + + +void DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar( wxCommandEvent& event ) +{ + int curRow = m_EnvVars->GetGridCursorRow(); + + if( !m_EnvVars->HasFocus() || curRow < 0 ) + { + m_EnvVars->SetFocus(); + return; + } + + if( IsEnvVarImmutable( m_EnvVars->GetCellValue( curRow, EV_NAME_COL ) ) ) + { + wxBell(); + return; + } + + m_EnvVars->DeleteRows( curRow, 1 ); + + curRow = std::max( 0, curRow - 1 ); + m_EnvVars->MakeCellVisible( curRow, m_EnvVars->GetGridCursorCol() ); + m_EnvVars->SetGridCursor( curRow, m_EnvVars->GetGridCursorCol() ); +} + + +void DIALOG_CONFIGURE_PATHS::OnDeleteSearchPath( wxCommandEvent& event ) +{ + int curRow = m_SearchPaths->GetGridCursorRow(); + + if( !m_SearchPaths->HasFocus() || curRow < 0 ) + { + m_SearchPaths->SetFocus(); + return; + } + + m_SearchPaths->DeleteRows( curRow, 1 ); + + curRow = std::max( 0, curRow - 1 ); + m_SearchPaths->MakeCellVisible( curRow, m_SearchPaths->GetGridCursorCol() ); + m_SearchPaths->SetGridCursor( curRow, m_SearchPaths->GetGridCursorCol() ); +} + + +void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveUp( wxCommandEvent& event ) +{ + int curRow = m_SearchPaths->GetGridCursorRow(); + int prevRow = curRow - 1; + + m_SearchPaths->DisableCellEditControl(); + + if( curRow > 0 ) + { + for( int i = 0; i < m_SearchPaths->GetNumberCols(); ++i ) + { + wxString tmp = m_SearchPaths->GetCellValue( curRow, i ); + m_SearchPaths->SetCellValue( curRow, i, m_SearchPaths->GetCellValue( prevRow, i ) ); + m_SearchPaths->SetCellValue( prevRow, i, tmp ); + } + + m_SearchPaths->SetGridCursor( prevRow, m_SearchPaths->GetGridCursorCol() ); + } +} + + +void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveDown( wxCommandEvent& event ) +{ + int curRow = m_SearchPaths->GetGridCursorRow(); + int nextRow = curRow + 1; + + m_SearchPaths->DisableCellEditControl(); + + if( curRow < m_SearchPaths->GetNumberRows() - 1 ) + { + for( int i = 0; i < m_SearchPaths->GetNumberCols(); ++i ) + { + wxString tmp = m_SearchPaths->GetCellValue( curRow, i ); + m_SearchPaths->SetCellValue( curRow, i, m_SearchPaths->GetCellValue( nextRow, i ) ); + m_SearchPaths->SetCellValue( nextRow, i, tmp ); + } + + m_SearchPaths->SetGridCursor( nextRow, m_SearchPaths->GetGridCursorCol() ); + } +} + + +void DIALOG_CONFIGURE_PATHS::OnGridCellRightClick( wxGridEvent& aEvent ) +{ + wxASSERT( (int) EV_PATH_COL == (int) SP_PATH_COL ); + + if( aEvent.GetCol() == EV_PATH_COL ) + { + wxMenu menu; + + AddMenuItem( &menu, 1, _( "File Browser..." ), KiBitmap( folder_xpm ) ); + if( GetPopupMenuSelectionFromUser( menu ) == 1 ) + { + wxString title = _( "Select Path" ); + wxString path; // Currently the first opened path is not initialized + + wxDirDialog dlg( nullptr, title, path, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); + + if( dlg.ShowModal() == wxID_OK ) + { + wxGrid* grid = dynamic_cast( aEvent.GetEventObject() ); + grid->SetCellValue( aEvent.GetRow(), EV_PATH_COL, dlg.GetPath() ); + } + } + } +} + + +void DIALOG_CONFIGURE_PATHS::AdjustGridColumns( int aWidth ) +{ + m_EnvVars->AutoSizeColumn( EV_NAME_COL ); + m_EnvVars->SetColSize( EV_NAME_COL, std::max( m_EnvVars->GetColSize( EV_NAME_COL ), 120 ) ); + + m_EnvVars->SetColSize( EV_PATH_COL, aWidth - m_EnvVars->GetColSize( EV_NAME_COL ) ); + + m_SearchPaths->AutoSizeColumn( SP_ALIAS_COL ); + m_SearchPaths->SetColSize( SP_ALIAS_COL, std::max( m_SearchPaths->GetColSize( SP_ALIAS_COL ), 120 ) ); + + m_SearchPaths->AutoSizeColumn( SP_PATH_COL ); + m_SearchPaths->SetColSize( SP_PATH_COL, std::max( m_SearchPaths->GetColSize( SP_PATH_COL ), 300 ) ); + + m_SearchPaths->SetColSize( SP_DESC_COL, aWidth - ( m_SearchPaths->GetColSize( SP_ALIAS_COL ) + + m_SearchPaths->GetColSize( SP_PATH_COL ) ) ); +} + + +void DIALOG_CONFIGURE_PATHS::OnUpdateUI( wxUpdateUIEvent& event ) +{ + if( !m_EnvVars->IsCellEditControlShown() && !m_SearchPaths->IsCellEditControlShown() ) + AdjustGridColumns( m_EnvVars->GetRect().GetWidth() ); + + // Handle a grid error. This is delayed to OnUpdateUI so that we can change focus + // even when the original validation was triggered from a killFocus event (and for + // dialog with notebooks, so that the corresponding notebook page can be shown in + // the background when triggered from an OK). + if( m_errorGrid ) + { + // We will re-enter this routine when the error dialog is displayed, so make + // sure we don't keep putting up more dialogs. + wxGrid* grid = m_errorGrid; + m_errorGrid = nullptr; + + DisplayErrorMessage( this, m_errorMsg ); + + grid->SetFocus(); + grid->MakeCellVisible( m_errorRow, m_errorCol ); + grid->SetGridCursor( m_errorRow, m_errorCol ); + + grid->EnableCellEditControl( true ); + grid->ShowCellEditControl(); + } +} + + +void DIALOG_CONFIGURE_PATHS::OnGridSize( wxSizeEvent& event ) +{ + AdjustGridColumns( event.GetSize().GetX() ); + + event.Skip(); +} + + +void DIALOG_CONFIGURE_PATHS::OnHelp( wxCommandEvent& event ) +{ + wxString msg = _( "Enter the name and value for each environment variable. Grey entries " + "are names that have been defined externally at the system or user " + "level. Environment variables defined at the system or user level " + "take precedence over the ones defined in this table. This means the " + "values in this table are ignored." ); + msg << wxT( "

" ); + msg << _( "To ensure environment variable names are valid on all platforms, the name field " + "will only accept upper case letters, digits, and the underscore characters." ); + msg << wxT( "

" ); + msg << _( "KICAD_SYMBOL_DIR is the base path of the locally installed symbol libraries." ); + msg << wxT( "

" ); + msg << _( "KIGITHUB is used by KiCad to define the URL of the repository " + "of the official KiCad footprint libraries." ); + msg << wxT( "

" ); + msg << _( "KISYS3DMOD is the base path of system footprint 3D " + "shapes (.3Dshapes folders)." ); + msg << wxT( "

" ); + msg << _( "KISYSMOD is the base path of locally installed system " + "footprint libraries (.pretty folders)." ); + msg << wxT( "

" ); + msg << _( "KIPRJMOD is internally defined by KiCad (cannot be edited) and is set " + "to the absolute path of the currently loaded project file. This environment " + "variable can be used to define files and paths relative to the currently loaded " + "project. For instance, ${KIPRJMOD}/libs/footprints.pretty can be defined as a " + "folder containing a project specific footprint library named footprints.pretty." ); + msg << wxT( "

" ); + msg << _( "KICAD_PTEMPLATES is optional and can be defined if you want to " + "create your own project templates folder." ); + + HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); + dlg.SetDialogSizeInDU( 400, 250 ); + + dlg.AddHTML_Text( msg ); + dlg.ShowModal(); +} + + +bool DIALOG_CONFIGURE_PATHS::IsEnvVarImmutable( const wxString aEnvVar ) +{ + /* + * TODO - Instead of defining these values here, + * extract them from elsewhere in the program + * (where they are originally defined) + */ + + static const wxString immutable[] = { + "KIGITHUB", + "KISYS3DMOD", + "KISYSMOD", + "KIPRJMOD", + "KICAD_PTEMPLATES", + "KICAD_SYMBOL_DIR" + }; + + for( const auto& ii : immutable ) + { + if( aEnvVar.Cmp( ii ) == 0 ) + return true; + } + + return false; +} diff --git a/common/dialogs/dialog_configure_paths_base.cpp b/common/dialogs/dialog_configure_paths_base.cpp new file mode 100644 index 0000000000..6a30529413 --- /dev/null +++ b/common/dialogs/dialog_configure_paths_base.cpp @@ -0,0 +1,186 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Dec 30 2017) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_configure_paths_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_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( wxSize( -1,-1 ), wxDefaultSize ); + + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbEnvVars; + sbEnvVars = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Environment Variables") ), wxVERTICAL ); + + m_EnvVars = new wxGrid( sbEnvVars->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + m_EnvVars->CreateGrid( 1, 2 ); + m_EnvVars->EnableEditing( true ); + m_EnvVars->EnableGridLines( true ); + m_EnvVars->EnableDragGridSize( false ); + m_EnvVars->SetMargins( 0, 0 ); + + // Columns + m_EnvVars->SetColSize( 0, 150 ); + m_EnvVars->SetColSize( 1, 454 ); + m_EnvVars->EnableDragColMove( false ); + m_EnvVars->EnableDragColSize( true ); + m_EnvVars->SetColLabelSize( 22 ); + m_EnvVars->SetColLabelValue( 0, _("Name") ); + m_EnvVars->SetColLabelValue( 1, _("Path") ); + m_EnvVars->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + // Rows + m_EnvVars->EnableDragRowSize( true ); + m_EnvVars->SetRowLabelSize( 0 ); + m_EnvVars->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + // Label Appearance + + // Cell Defaults + m_EnvVars->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_EnvVars->SetMinSize( wxSize( 600,150 ) ); + + sbEnvVars->Add( m_EnvVars, 1, wxEXPAND|wxBOTTOM, 5 ); + + wxBoxSizer* bSizerEnvVarBtns; + bSizerEnvVarBtns = new wxBoxSizer( wxHORIZONTAL ); + + m_btnAddEnvVar = new wxBitmapButton( sbEnvVars->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + m_btnAddEnvVar->SetMinSize( wxSize( 29,29 ) ); + + bSizerEnvVarBtns->Add( m_btnAddEnvVar, 0, 0, 5 ); + + m_btnDeleteEnvVar = new wxBitmapButton( sbEnvVars->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + m_btnDeleteEnvVar->SetMinSize( wxSize( 29,29 ) ); + + bSizerEnvVarBtns->Add( m_btnDeleteEnvVar, 0, 0, 5 ); + + + sbEnvVars->Add( bSizerEnvVarBtns, 0, wxEXPAND, 5 ); + + + bSizerMain->Add( sbEnvVars, 1, wxEXPAND|wxALL, 5 ); + + m_sb3DSearchPaths = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("3D Search Paths") ), wxVERTICAL ); + + m_SearchPaths = new wxGrid( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + m_SearchPaths->CreateGrid( 1, 3 ); + m_SearchPaths->EnableEditing( true ); + m_SearchPaths->EnableGridLines( true ); + m_SearchPaths->EnableDragGridSize( false ); + m_SearchPaths->SetMargins( 0, 0 ); + + // Columns + m_SearchPaths->SetColSize( 0, 150 ); + m_SearchPaths->SetColSize( 1, 300 ); + m_SearchPaths->SetColSize( 2, 154 ); + m_SearchPaths->EnableDragColMove( false ); + m_SearchPaths->EnableDragColSize( true ); + m_SearchPaths->SetColLabelSize( 22 ); + m_SearchPaths->SetColLabelValue( 0, _("Alias") ); + m_SearchPaths->SetColLabelValue( 1, _("Path") ); + m_SearchPaths->SetColLabelValue( 2, _("Description") ); + m_SearchPaths->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + // Rows + m_SearchPaths->AutoSizeRows(); + m_SearchPaths->EnableDragRowSize( false ); + m_SearchPaths->SetRowLabelSize( 0 ); + m_SearchPaths->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + // Label Appearance + + // Cell Defaults + m_SearchPaths->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_SearchPaths->SetMinSize( wxSize( 600,150 ) ); + + m_sb3DSearchPaths->Add( m_SearchPaths, 1, wxEXPAND|wxBOTTOM, 5 ); + + wxBoxSizer* bSizerSearchPathBtns; + bSizerSearchPathBtns = new wxBoxSizer( wxHORIZONTAL ); + + m_btnAddSearchPath = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + m_btnAddSearchPath->SetMinSize( wxSize( 29,29 ) ); + + bSizerSearchPathBtns->Add( m_btnAddSearchPath, 0, 0, 5 ); + + m_btnDeleteSearchPath = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + m_btnDeleteSearchPath->SetMinSize( wxSize( 29,29 ) ); + + bSizerSearchPathBtns->Add( m_btnDeleteSearchPath, 0, wxRIGHT, 10 ); + + m_btnMoveUp = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + m_btnMoveUp->SetMinSize( wxSize( 29,29 ) ); + + bSizerSearchPathBtns->Add( m_btnMoveUp, 0, wxLEFT, 10 ); + + m_btnMoveDown = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + m_btnMoveDown->SetMinSize( wxSize( 29,29 ) ); + + bSizerSearchPathBtns->Add( m_btnMoveDown, 0, 0, 5 ); + + + m_sb3DSearchPaths->Add( bSizerSearchPathBtns, 0, wxEXPAND, 5 ); + + + bSizerMain->Add( m_sb3DSearchPaths, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 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_sdbSizerHelp = new wxButton( this, wxID_HELP ); + m_sdbSizer->AddButton( m_sdbSizerHelp ); + m_sdbSizer->Realize(); + + bSizerMain->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 ); + + + this->SetSizer( bSizerMain ); + this->Layout(); + bSizerMain->Fit( this ); + + this->Centre( wxBOTH ); + + // Connect Events + m_EnvVars->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridSize ), NULL, this ); + m_EnvVars->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); + m_btnAddEnvVar->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddEnvVar ), NULL, this ); + m_btnDeleteEnvVar->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnRemoveEnvVar ), NULL, this ); + m_SearchPaths->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellRightClick ), NULL, this ); + m_SearchPaths->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); + m_btnAddSearchPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddSearchPath ), NULL, this ); + m_btnDeleteSearchPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnDeleteSearchPath ), NULL, this ); + m_btnMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnSearchPathMoveUp ), NULL, this ); + m_btnMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnSearchPathMoveDown ), NULL, this ); + m_sdbSizerHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnHelp ), NULL, this ); +} + +DIALOG_CONFIGURE_PATHS_BASE::~DIALOG_CONFIGURE_PATHS_BASE() +{ + // Disconnect Events + m_EnvVars->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridSize ), NULL, this ); + m_EnvVars->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); + m_btnAddEnvVar->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddEnvVar ), NULL, this ); + m_btnDeleteEnvVar->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnRemoveEnvVar ), NULL, this ); + m_SearchPaths->Disconnect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellRightClick ), NULL, this ); + m_SearchPaths->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); + m_btnAddSearchPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddSearchPath ), NULL, this ); + m_btnDeleteSearchPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnDeleteSearchPath ), NULL, this ); + m_btnMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnSearchPathMoveUp ), NULL, this ); + m_btnMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnSearchPathMoveDown ), NULL, this ); + m_sdbSizerHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnHelp ), NULL, this ); + +} diff --git a/common/dialogs/dialog_configure_paths_base.fbp b/common/dialogs/dialog_configure_paths_base.fbp new file mode 100644 index 0000000000..d0015f2bb9 --- /dev/null +++ b/common/dialogs/dialog_configure_paths_base.fbp @@ -0,0 +1,1021 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_configure_paths_base + 1000 + none + 1 + DIALOG_CONFIGURE_PATHS_BASE + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + -1,-1 + DIALOG_CONFIGURE_PATHS_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Configure Paths + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerMain + wxVERTICAL + none + + 5 + wxEXPAND|wxALL + 1 + + wxID_ANY + Environment Variables + + sbEnvVars + wxVERTICAL + 1 + none + + + 5 + wxEXPAND|wxBOTTOM + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTRE + 22 + "Name" "Path" + wxALIGN_CENTRE + 2 + 150,454 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 1 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + 600,150 + 1 + m_EnvVars + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTRE + 0 + + wxALIGN_CENTRE + + 1 + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnGridSize + OnUpdateUI + + + + 5 + wxEXPAND + 0 + + + bSizerEnvVarBtns + wxHORIZONTAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + Add Environment Variable + + 0 + + + 0 + 29,29 + 1 + m_btnAddEnvVar + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddEnvVar + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + Delete Environment Variable + + 0 + + + 0 + 29,29 + 1 + m_btnDeleteEnvVar + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRemoveEnvVar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + + wxID_ANY + 3D Search Paths + + m_sb3DSearchPaths + wxVERTICAL + 1 + protected + + + 5 + wxEXPAND|wxBOTTOM + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + 1 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTRE + 22 + "Alias" "Path" "Description" + wxALIGN_CENTRE + 3 + 150,300,154 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 0 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + 600,150 + 1 + m_SearchPaths + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTRE + 0 + + wxALIGN_CENTRE + + 1 + 1 + + + 0 + + + + + + + + + + + OnGridCellRightClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnUpdateUI + + + + 5 + wxEXPAND + 0 + + + bSizerSearchPathBtns + wxHORIZONTAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + Add Path + + 0 + + + 0 + 29,29 + 1 + m_btnAddSearchPath + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddSearchPath + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + Delete Path + + 0 + + + 0 + 29,29 + 1 + m_btnDeleteSearchPath + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnDeleteSearchPath + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + Move Up + + 0 + + + 0 + 29,29 + 1 + m_btnMoveUp + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSearchPathMoveUp + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + Move Down + + 0 + + + 0 + 29,29 + 1 + m_btnMoveDown + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSearchPathMoveDown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + OnHelp + + + + + + + + + + diff --git a/common/dialogs/dialog_configure_paths_base.h b/common/dialogs/dialog_configure_paths_base.h new file mode 100644 index 0000000000..6a488ba4ea --- /dev/null +++ b/common/dialogs/dialog_configure_paths_base.h @@ -0,0 +1,75 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Dec 30 2017) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_CONFIGURE_PATHS_BASE_H__ +#define __DIALOG_CONFIGURE_PATHS_BASE_H__ + +#include +#include +#include +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_CONFIGURE_PATHS_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_CONFIGURE_PATHS_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxGrid* m_EnvVars; + wxBitmapButton* m_btnAddEnvVar; + wxBitmapButton* m_btnDeleteEnvVar; + wxStaticBoxSizer* m_sb3DSearchPaths; + wxGrid* m_SearchPaths; + wxBitmapButton* m_btnAddSearchPath; + wxBitmapButton* m_btnDeleteSearchPath; + wxBitmapButton* m_btnMoveUp; + wxBitmapButton* m_btnMoveDown; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerCancel; + wxButton* m_sdbSizerHelp; + + // Virtual event handlers, overide them in your derived class + virtual void OnGridSize( wxSizeEvent& event ) { event.Skip(); } + virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void OnAddEnvVar( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRemoveEnvVar( wxCommandEvent& event ) { event.Skip(); } + virtual void OnGridCellRightClick( wxGridEvent& event ) { event.Skip(); } + virtual void OnAddSearchPath( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDeleteSearchPath( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSearchPathMoveUp( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSearchPathMoveDown( wxCommandEvent& event ) { event.Skip(); } + virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Configure Paths"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_CONFIGURE_PATHS_BASE(); + +}; + +#endif //__DIALOG_CONFIGURE_PATHS_BASE_H__ diff --git a/common/dialogs/dialog_env_var_config.cpp b/common/dialogs/dialog_env_var_config.cpp deleted file mode 100644 index e29f6443d5..0000000000 --- a/common/dialogs/dialog_env_var_config.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/* - * This program source code file is part of KICAD, a free EDA CAD application. - * - * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * @file dialog_env_var_config.cpp - */ - -#include - -#include - -#include -#include - -#include - -/** A helper dialog to edit a env var name and/or its value (often a path) - */ -class DIALOG_ENV_VAR_SINGLE : public DIALOG_ENV_VAR_SINGLE_BASE -{ -public: - DIALOG_ENV_VAR_SINGLE( wxWindow* parent, const wxString& aEnvVarName, - const wxString& aEnvVarPath ); - - /// @return the new environment variable name - wxString GetEnvVarName() const - { - return m_envVarName->GetValue(); - } - - /// @return the new environment variable value - wxString GetEnvVarValue() const - { - return m_envVarPath->GetValue(); - } - - /// disable the environment variable name (must be called - /// for predefined environment variable names, not editable - void SetEnvVarProtected() - { - m_envVarName->Enable( false ); - } - -protected: - void OnSelectPath( wxCommandEvent& event ) override; - void onHelpClick( wxCommandEvent& event ) override; - - // Currently, only upper case variable names are accepted. onVarNameChange - // changes on the fly any lower case char by the corresponding upper case - void onVarNameChange( wxCommandEvent& event ) override; - - bool TransferDataFromWindow() override; -}; - - -DIALOG_ENV_VAR_CONFIG::DIALOG_ENV_VAR_CONFIG( wxWindow* aParent, const ENV_VAR_MAP& aEnvVarMap ) : - DIALOG_ENV_VAR_CONFIG_BASE( aParent ) -{ - // Copy environment variables across - m_envVarMap = aEnvVarMap; -} - - -bool DIALOG_ENV_VAR_CONFIG::TransferDataToWindow() -{ - wxLogDebug( wxT( "In DIALOG_ENV_VAR_CONFIG::TransferDataToWindow()." ) ); - - if( !wxDialog::TransferDataToWindow() ) - return false; - - //TODO - /* - // Grab the project path var (not editable) - wxString prjPath; - - wxGetEnv( PROJECT_VAR_NAME, &prjPath ); - - m_kiprjmod->SetLabel( prjPath ); - */ - - //TODO - Call SetAlternateRowColour first to prevent assertion error - //m_pathList->EnableAlternateRowColours( true ); - - PopulatePathList(); - - // Select the first item in the list - SelectListIndex( 0 ); - - GetSizer()->Layout(); - GetSizer()->Fit( this ); - GetSizer()->SetSizeHints( this ); - - return true; -} - - -bool DIALOG_ENV_VAR_CONFIG::TransferDataFromWindow() -{ - if( !wxDialog::TransferDataFromWindow() ) - { - return false; - } - - Pgm().SetLocalEnvVariables( m_envVarMap ); - - return true; -} - - -void DIALOG_ENV_VAR_CONFIG::PopulatePathList() -{ - m_pathList->Freeze(); - - m_pathList->ClearAll(); - - m_pathList->AppendColumn( _( "Name:" ) ); - m_pathList->AppendColumn( _( "Path:" ) ); - - int row = 0; - - for( auto it = m_envVarMap.begin(); it != m_envVarMap.end(); ++it ) - { - long index = m_pathList->InsertItem( row, it->first ); - - m_pathList->SetItem( index, 1, it->second.GetValue() ); - - if( it->second.GetDefinedExternally() ) - { - wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ); - - m_pathList->SetItemBackgroundColour( index, color ); - } - - row++; - } - - m_pathList->SetColumnWidth( 0, wxLIST_AUTOSIZE ); - m_pathList->SetColumnWidth( 1, wxLIST_AUTOSIZE ); - - m_pathList->Update(); - - m_pathList->Thaw(); -} - - -bool DIALOG_ENV_VAR_CONFIG::GetPathAtIndex( unsigned int aIndex, wxString& aEnvVar, - wxString& aEnvPath ) -{ - if( aIndex > m_envVarMap.size() ) - { - return false; - } - - unsigned int idx = 0; - - for( auto it = m_envVarMap.begin(); it != m_envVarMap.end(); ++it ) - { - if( idx == aIndex ) - { - aEnvVar = it->first; - aEnvPath = it->second.GetValue(); - - return true; - } - - idx++; - } - - return false; -} - - -void DIALOG_ENV_VAR_CONFIG::OnAddButton( wxCommandEvent& event ) -{ - DIALOG_ENV_VAR_SINGLE dlg( nullptr, wxEmptyString, wxEmptyString ); - - if( dlg.ShowModal() == wxID_OK ) - { - wxString newName = dlg.GetEnvVarName(); - wxString newPath = dlg.GetEnvVarValue(); - - // Check that the name does not already exist - if( m_envVarMap.count( newName ) > 0 ) - { - //TODO - Improve this message, use DisplayErrorMessage instead - DisplayError( this, _( "Path already exists." ) ); - } - else - { - m_envVarMap[newName] = ENV_VAR_ITEM( newPath ); - - // Update path list - PopulatePathList(); - } - } -} - - -void DIALOG_ENV_VAR_CONFIG::OnEditButton( wxCommandEvent& event ) -{ - EditSelectedEntry(); -} - - -void DIALOG_ENV_VAR_CONFIG::EditSelectedEntry() -{ - wxString envName; - wxString envPath; - - if( GetPathAtIndex( m_pathIndex, envName, envPath ) ) - { - auto dlg = new DIALOG_ENV_VAR_SINGLE( nullptr, envName, envPath ); - - if( IsEnvVarImmutable( envName ) ) - { - dlg->SetEnvVarProtected(); - } - - if( dlg->ShowModal() == wxID_OK ) - { - wxString newName = dlg->GetEnvVarName(); - wxString newPath = dlg->GetEnvVarValue(); - - // If the path name has not been changed - if( envName.Cmp( newName ) == 0 ) - { - m_envVarMap[envName].SetValue( newPath ); - - if( m_envVarMap[envName].GetDefinedExternally() ) - { - m_extDefsChanged = true; - } - } - // Path-name needs to be updated - else - { - if( IsEnvVarImmutable( envName ) ) - { - DisplayErrorMessage( this, - wxString::Format( _( "Environment variable \"%s\" cannot " - "be renamed." ), - envName.ToStdString() ), - _( "The selected environment variable name " - "is required for KiCad functionality and " - "can not be renamed." ) ); - - return; - } - - auto envVar = m_envVarMap[envName]; - - m_envVarMap.erase( envName ); - - envVar.SetValue( newPath ); - envVar.SetDefinedExternally( false ); - m_envVarMap[newName] = envVar; - } - - // Update the path list - PopulatePathList(); - } - - dlg->Destroy(); - } -} - - -void DIALOG_ENV_VAR_CONFIG::OnHelpButton( wxCommandEvent& event ) -{ - wxString msg = _( "Enter the name and value for each environment variable. Grey entries " - "are names that have been defined externally at the system or user " - "level. Environment variables defined at the system or user level " - "take precedence over the ones defined in this table. This means the " - "values in this table are ignored." ); - msg << wxT( "

" ); - msg << _( "To ensure environment variable names are valid on all platforms, the name field " - "will only accept upper case letters, digits, and the underscore characters." ); - msg << wxT( "

" ); - msg << _( "KICAD_SYMBOL_DIR is the base path of the locally installed symbol " - "libraries." ); - msg << wxT( "

" ); - msg << _( "KIGITHUB is used by KiCad to define the URL of the repository " - "of the official KiCad footprint libraries. This is only required if the " - "Github plugin is used to access footprint libraries" ); - msg << wxT( "

" ); - msg << _( "KISYS3DMOD is the base path of system footprint 3D " - "shapes (.3Dshapes folders)." ); - msg << wxT( "

" ); - msg << _( "KISYSMOD is the base path of locally installed system " - "footprint libraries (.pretty folders)." ); - msg << wxT( "

" ); - msg << _( "KIPRJMOD is internally defined by KiCad (cannot be edited) and is set " - "to the absolute path of the currently loaded project file. This environment " - "variable can be used to define files and paths relative to the currently loaded " - "project. For instance, ${KIPRJMOD}/libs/footprints.pretty can be defined as a " - "folder containing a project specific footprint library named footprints.pretty." ); - msg << wxT( "

" ); - msg << _( "KICAD_TEMPLATE_DIR is required and is the path containing the project " - "templates installed with KiCad." ); - msg << wxT( "

" ); - msg << _( "KICAD_USER_TEMPLATE_DIR is required and is the path containing any user " - "specific project templates." ); - - HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); - dlg.SetDialogSizeInDU( 400, 350 ); - - dlg.AddHTML_Text( msg ); - dlg.ShowModal(); -} - - -bool DIALOG_ENV_VAR_CONFIG::IsEnvVarImmutable( const wxString aEnvVar ) -{ - /* - * TODO - Instead of defining these values here, - * extract them from elsewhere in the program - * (where they are originally defined) - */ - - static const wxString immutable[] = { - "KIGITHUB", - "KISYS3DMOD", - "KISYSMOD", - "KIPRJMOD", - "KICAD_SYMBOL_DIR", - "KICAD_TEMPLATE_DIR", - "KICAD_USER_TEMPLATE_DIR" - }; - - for( unsigned int ii=0; ii<6; ii++ ) - { - if( aEnvVar.Cmp( immutable[ii] ) == 0 ) - { - return true; - } - } - - return false; -} - - -void DIALOG_ENV_VAR_CONFIG::OnRemoveButton( wxCommandEvent& event ) -{ - wxString envName; - wxString envPath; - - if( GetPathAtIndex( m_pathIndex, envName, envPath ) ) - { - if( IsEnvVarImmutable( envName ) ) - { - return; - } - - m_envVarMap.erase( envName ); - - PopulatePathList(); - } -} - - -void DIALOG_ENV_VAR_CONFIG::SelectListIndex( unsigned int aIndex ) -{ - if( aIndex >= m_envVarMap.size() ) - { - aIndex = 0; - } - - m_pathIndex = aIndex; - - wxString envName; - wxString envPath; - - if( GetPathAtIndex( m_pathIndex, envName, envPath ) ) - { - // Disable the 'delete' button if the path cannot be deleted - m_deletePathButton->Enable( !IsEnvVarImmutable( envName ) ); - } -} - -void DIALOG_ENV_VAR_CONFIG::OnPathSelected( wxListEvent& event ) -{ - SelectListIndex( event.GetIndex() ); -} - - -void DIALOG_ENV_VAR_CONFIG::OnPathActivated( wxListEvent& event ) -{ - SelectListIndex( event.GetIndex() ); - - EditSelectedEntry(); -} - - -/////////////////////////// -// DIALOG_ENV_VAR_SINGLE // -/////////////////////////// - -DIALOG_ENV_VAR_SINGLE::DIALOG_ENV_VAR_SINGLE( wxWindow* parent, - const wxString& aEnvVarName, - const wxString& aEnvVarPath ) : - DIALOG_ENV_VAR_SINGLE_BASE( parent ) -{ - m_envVarName->SetValue( aEnvVarName ); - m_envVarPath->SetValue( aEnvVarPath ); - m_envVarName->SetValidator( ENV_VAR_NAME_VALIDATOR() ); -} - - -void DIALOG_ENV_VAR_SINGLE::OnSelectPath( wxCommandEvent& event ) -{ - wxString title = _( "Select Path for Environment Variable" ); - wxString path; // Currently the first opened path is not initialized - - wxDirDialog dlg( nullptr, title, path, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); - - if( dlg.ShowModal() == wxID_OK ) - m_envVarPath->SetValue( dlg.GetPath() ); -} - - -void DIALOG_ENV_VAR_SINGLE::onVarNameChange( wxCommandEvent& event ) -{ - wxString upper_var = m_envVarName->GetValue().Upper(); - - if( upper_var != m_envVarName->GetValue() ) - { - int pos = m_envVarName->GetInsertionPoint(); - m_envVarName->ChangeValue( upper_var ); - m_envVarName->SetInsertionPoint( pos ); - } - -} - - -bool DIALOG_ENV_VAR_SINGLE::TransferDataFromWindow() -{ - // The user pressed the OK button, test data validity - wxString name = m_envVarName->GetValue(); - wxString path = m_envVarPath->GetValue(); - - // Neither name nor path can be empty - if( name.IsEmpty() ) - { - DisplayError( this, _( "Environment variable name cannot be empty." ) ); - // Veto: - return false; - } - - if( path.IsEmpty() ) - { - DisplayError( this, _( "Environment variable value cannot be empty." ) ); - // Veto: - return false; - } - - // Name cannot start with a number - if( name.Left( 1 ).IsNumber() ) - { - DisplayError( this, _( "Environment variable names cannot start with a digit (0-9)." ) ); - // Veto: - return false; - } - - // No errors detected - return true; -} - - -void DIALOG_ENV_VAR_SINGLE::onHelpClick( wxCommandEvent& event ) -{ - wxString msg = _( "An environment variable is used for string substitutions.
" - "Environment variables are primarily used for paths to make KiCad portable " - "between platforms.

" - "If an environment variable is defined as MYLIBPATH with a " - "value e:/kicad_libs, then a library name " - "${MYLIBPATH}/mylib.lib gets expanded to " - "e:/kicad_libs/mylib.lib" - "

" - "Note:
" - "Only characters ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ are " - "allowed in environment variable names and the environment variable name " - "cannot start with a digit (0-9)." - ); - - HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); - dlg.SetDialogSizeInDU( 400, 350 ); - - dlg.AddHTML_Text( msg ); - dlg.ShowModal(); -} diff --git a/common/dialogs/dialog_env_var_config_base.cpp b/common/dialogs/dialog_env_var_config_base.cpp deleted file mode 100644 index e0e95bc6ab..0000000000 --- a/common/dialogs/dialog_env_var_config_base.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_env_var_config_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_ENV_VAR_CONFIG_BASE::DIALOG_ENV_VAR_CONFIG_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* mainSizer; - mainSizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxHORIZONTAL ); - - m_pathList = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_VRULES ); - bSizer7->Add( m_pathList, 1, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* bSizer6; - bSizer6 = new wxBoxSizer( wxVERTICAL ); - - m_addPathButton = new wxButton( this, ID_BUTTON_ADD_PATH, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); - m_addPathButton->SetToolTip( _("Add path prefix") ); - - bSizer6->Add( m_addPathButton, 0, wxALL, 5 ); - - m_editPathButton = new wxButton( this, ID_BUTTON_EDIT_PATH, _("Edit"), wxDefaultPosition, wxDefaultSize, 0 ); - m_editPathButton->SetToolTip( _("Edit selected path prefix") ); - - bSizer6->Add( m_editPathButton, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - - m_deletePathButton = new wxButton( this, ID_BUTTON_DELETE_PATH, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 ); - m_deletePathButton->SetToolTip( _("Remove selected path prefix") ); - - bSizer6->Add( m_deletePathButton, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - - - bSizer6->Add( 0, 0, 1, wxEXPAND, 5 ); - - - bSizer7->Add( bSizer6, 0, wxEXPAND, 5 ); - - - mainSizer->Add( bSizer7, 1, wxEXPAND, 5 ); - - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - mainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 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_sdbSizerHelp = new wxButton( this, wxID_HELP ); - m_sdbSizer->AddButton( m_sdbSizerHelp ); - m_sdbSizer->Realize(); - - mainSizer->Add( m_sdbSizer, 0, wxBOTTOM|wxALIGN_RIGHT, 5 ); - - - this->SetSizer( mainSizer ); - this->Layout(); - mainSizer->Fit( this ); - - this->Centre( wxBOTH ); - - // Connect Events - m_pathList->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnPathActivated ), NULL, this ); - m_pathList->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnPathSelected ), NULL, this ); - m_addPathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnAddButton ), NULL, this ); - m_editPathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnEditButton ), NULL, this ); - m_deletePathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnRemoveButton ), NULL, this ); - m_sdbSizerHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnHelpButton ), NULL, this ); -} - -DIALOG_ENV_VAR_CONFIG_BASE::~DIALOG_ENV_VAR_CONFIG_BASE() -{ - // Disconnect Events - m_pathList->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnPathActivated ), NULL, this ); - m_pathList->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnPathSelected ), NULL, this ); - m_addPathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnAddButton ), NULL, this ); - m_editPathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnEditButton ), NULL, this ); - m_deletePathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnRemoveButton ), NULL, this ); - m_sdbSizerHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnHelpButton ), NULL, this ); - -} - -DIALOG_ENV_VAR_SINGLE_BASE::DIALOG_ENV_VAR_SINGLE_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 ); - - wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 0, 3, 0, 0 ); - fgSizer1->AddGrowableCol( 1 ); - fgSizer1->SetFlexibleDirection( wxBOTH ); - fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_envVarNameLabel = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_envVarNameLabel->Wrap( -1 ); - fgSizer1->Add( m_envVarNameLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - m_envVarName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_envVarName, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); - - m_buttonHelp = new wxButton( this, wxID_ANY, _("Help"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_buttonHelp, 0, wxALL, 5 ); - - m_envVarPathLabel = new wxStaticText( this, wxID_ANY, _("Value:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_envVarPathLabel->Wrap( -1 ); - fgSizer1->Add( m_envVarPathLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - - m_envVarPath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_envVarPath->SetMinSize( wxSize( 250,-1 ) ); - - fgSizer1->Add( m_envVarPath, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - - m_selectPathButton = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_selectPathButton, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - - - bSizerMain->Add( fgSizer1, 0, wxALL|wxEXPAND, 5 ); - - - bSizerMain->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline2, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - - m_sdbSizer2 = new wxStdDialogButtonSizer(); - m_sdbSizer2OK = new wxButton( this, wxID_OK ); - m_sdbSizer2->AddButton( m_sdbSizer2OK ); - m_sdbSizer2Cancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer2->AddButton( m_sdbSizer2Cancel ); - m_sdbSizer2->Realize(); - - bSizerMain->Add( m_sdbSizer2, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_RIGHT, 5 ); - - - this->SetSizer( bSizerMain ); - this->Layout(); - bSizerMain->Fit( this ); - - this->Centre( wxBOTH ); - - // Connect Events - m_envVarName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onVarNameChange ), NULL, this ); - m_buttonHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onHelpClick ), NULL, this ); - m_selectPathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::OnSelectPath ), NULL, this ); -} - -DIALOG_ENV_VAR_SINGLE_BASE::~DIALOG_ENV_VAR_SINGLE_BASE() -{ - // Disconnect Events - m_envVarName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onVarNameChange ), NULL, this ); - m_buttonHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onHelpClick ), NULL, this ); - m_selectPathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::OnSelectPath ), NULL, this ); - -} diff --git a/common/dialogs/dialog_env_var_config_base.fbp b/common/dialogs/dialog_env_var_config_base.fbp deleted file mode 100644 index e695b4b20f..0000000000 --- a/common/dialogs/dialog_env_var_config_base.fbp +++ /dev/null @@ -1,1335 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_env_var_config_base - 1000 - none - 1 - dialog_env_var_editor_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_ENV_VAR_CONFIG_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Environment Variable Configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mainSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - - bSizer7 - wxHORIZONTAL - none - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_pathList - 1 - - - protected - 1 - - Resizable - 1 - - wxLC_HRULES|wxLC_REPORT|wxLC_VRULES - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnPathActivated - - - - - OnPathSelected - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - - bSizer6 - wxVERTICAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_BUTTON_ADD_PATH - Add - - 0 - - - 0 - - 1 - m_addPathButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Add path prefix - - wxFILTER_NONE - wxDefaultValidator - - - - - OnAddButton - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_BUTTON_EDIT_PATH - Edit - - 0 - - - 0 - - 1 - m_editPathButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Edit selected path prefix - - wxFILTER_NONE - wxDefaultValidator - - - - - OnEditButton - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_BUTTON_DELETE_PATH - Remove - - 0 - - - 0 - - 1 - m_deletePathButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Remove selected path prefix - - wxFILTER_NONE - wxDefaultValidator - - - - - OnRemoveButton - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - - - - - 5 - wxEXPAND | wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline1 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxALIGN_RIGHT - 0 - - 0 - 1 - 0 - 1 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - OnHelpButton - - - - - - - - - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_ENV_VAR_SINGLE_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Edit Environment Variable - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerMain - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - 3 - wxBOTH - 1 - - 0 - - fgSizer1 - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 0 - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Name: - - 0 - - - 0 - - 1 - m_envVarNameLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_envVarName - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - onVarNameChange - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Help - - 0 - - - 0 - - 1 - m_buttonHelp - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onHelpClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Value: - - 0 - - - 0 - - 1 - m_envVarPathLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - 250,-1 - 1 - m_envVarPath - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Browse - - 0 - - - 0 - - 1 - m_selectPathButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnSelectPath - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline2 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_RIGHT - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer2 - protected - - - - - - - - - - - - - - diff --git a/common/dialogs/dialog_env_var_config_base.h b/common/dialogs/dialog_env_var_config_base.h deleted file mode 100644 index 7ef5f5db36..0000000000 --- a/common/dialogs/dialog_env_var_config_base.h +++ /dev/null @@ -1,102 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __DIALOG_ENV_VAR_CONFIG_BASE_H__ -#define __DIALOG_ENV_VAR_CONFIG_BASE_H__ - -#include -#include -#include -class DIALOG_SHIM; - -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -#define ID_BUTTON_ADD_PATH 1000 -#define ID_BUTTON_EDIT_PATH 1001 -#define ID_BUTTON_DELETE_PATH 1002 - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_ENV_VAR_CONFIG_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_ENV_VAR_CONFIG_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxListCtrl* m_pathList; - wxButton* m_addPathButton; - wxButton* m_editPathButton; - wxButton* m_deletePathButton; - wxStaticLine* m_staticline1; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - wxButton* m_sdbSizerHelp; - - // Virtual event handlers, overide them in your derived class - virtual void OnPathActivated( wxListEvent& event ) { event.Skip(); } - virtual void OnPathSelected( wxListEvent& event ) { event.Skip(); } - virtual void OnAddButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnEditButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnRemoveButton( wxCommandEvent& event ) { event.Skip(); } - virtual void OnHelpButton( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_ENV_VAR_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Environment Variable Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_ENV_VAR_CONFIG_BASE(); - -}; - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_ENV_VAR_SINGLE_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_ENV_VAR_SINGLE_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxStaticText* m_envVarNameLabel; - wxTextCtrl* m_envVarName; - wxButton* m_buttonHelp; - wxStaticText* m_envVarPathLabel; - wxTextCtrl* m_envVarPath; - wxButton* m_selectPathButton; - wxStaticLine* m_staticline2; - wxStdDialogButtonSizer* m_sdbSizer2; - wxButton* m_sdbSizer2OK; - wxButton* m_sdbSizer2Cancel; - - // Virtual event handlers, overide them in your derived class - virtual void onVarNameChange( wxCommandEvent& event ) { event.Skip(); } - virtual void onHelpClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSelectPath( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_ENV_VAR_SINGLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit Environment Variable"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_ENV_VAR_SINGLE_BASE(); - -}; - -#endif //__DIALOG_ENV_VAR_CONFIG_BASE_H__ diff --git a/3d-viewer/3d_cache/3d_filename_resolver.cpp b/common/filename_resolver.cpp similarity index 91% rename from 3d-viewer/3d_cache/3d_filename_resolver.cpp rename to common/filename_resolver.cpp index 0a00c9c4c8..2e6b7ec304 100644 --- a/3d-viewer/3d_cache/3d_filename_resolver.cpp +++ b/common/filename_resolver.cpp @@ -22,7 +22,6 @@ */ #include -#include #include #include #include @@ -32,11 +31,11 @@ #include #include "common.h" -#include "3d_filename_resolver.h" +#include "filename_resolver.h" // configuration file version #define CFGFILE_VERSION 1 -#define S3D_RESOLVER_CONFIG wxT( "3Dresolver.cfg" ) +#define RESOLVER_CONFIG wxT( "3Dresolver.cfg" ) // flag bits used to track different one-off messages to users #define ERRFLG_ALIAS (1) @@ -45,19 +44,19 @@ #define MASK_3D_RESOLVER "3D_RESOLVER" -static wxCriticalSection lock3D_resolver; +static wxCriticalSection lock_resolver; static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult ); -S3D_FILENAME_RESOLVER::S3D_FILENAME_RESOLVER() +FILENAME_RESOLVER::FILENAME_RESOLVER() { m_errflags = 0; m_pgm = NULL; } -bool S3D_FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir ) +bool FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir ) { if( aConfigDir.empty() ) return false; @@ -71,7 +70,7 @@ bool S3D_FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir ) cfgdir.Normalize(); - if( false == cfgdir.DirExists() ) + if( !cfgdir.DirExists() ) return false; m_ConfigDir = cfgdir.GetPath(); @@ -81,7 +80,7 @@ bool S3D_FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir ) } -bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgChanged ) +bool FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgChanged ) { if( aProjDir.empty() ) return false; @@ -95,7 +94,7 @@ bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgCh projdir.Normalize(); - if( false == projdir.DirExists() ) + if( !projdir.DirExists() ) return false; m_curProjDir = projdir.GetPath(); @@ -105,7 +104,7 @@ bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgCh if( m_Paths.empty() ) { - S3D_ALIAS al; + SEARCH_PATH al; al.m_alias = "${KIPRJMOD}"; al.m_pathvar = "${KIPRJMOD}"; al.m_pathexp = m_curProjDir; @@ -145,28 +144,26 @@ bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgCh } -wxString S3D_FILENAME_RESOLVER::GetProjectDir( void ) +wxString FILENAME_RESOLVER::GetProjectDir() { return m_curProjDir; } -void S3D_FILENAME_RESOLVER::SetProgramBase( PGM_BASE* aBase ) +void FILENAME_RESOLVER::SetProgramBase( PGM_BASE* aBase ) { m_pgm = aBase; - if( NULL == m_pgm || m_Paths.empty() ) + if( !m_pgm || m_Paths.empty() ) return; // recreate the path list m_Paths.clear(); createPathList(); - - return; } -bool S3D_FILENAME_RESOLVER::createPathList( void ) +bool FILENAME_RESOLVER::createPathList() { if( !m_Paths.empty() ) return true; @@ -177,7 +174,7 @@ bool S3D_FILENAME_RESOLVER::createPathList( void ) // we cannot set a sensible default so we use an empty string. // the user may change this later with a call to SetProjectDir() - S3D_ALIAS lpath; + SEARCH_PATH lpath; lpath.m_alias = "${KIPRJMOD}"; lpath.m_pathvar = "${KIPRJMOD}"; lpath.m_pathexp = m_curProjDir; @@ -221,8 +218,8 @@ bool S3D_FILENAME_RESOLVER::createPathList( void ) #ifdef DEBUG wxLogTrace( MASK_3D_RESOLVER, " * [3D model] search paths:\n" ); - std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end(); while( sPL != ePL ) { @@ -236,7 +233,7 @@ bool S3D_FILENAME_RESOLVER::createPathList( void ) } -bool S3D_FILENAME_RESOLVER::UpdatePathList( std::vector< S3D_ALIAS >& aPathList ) +bool FILENAME_RESOLVER::UpdatePathList( std::vector< SEARCH_PATH >& aPathList ) { wxUniChar envMarker( '$' ); @@ -252,9 +249,9 @@ bool S3D_FILENAME_RESOLVER::UpdatePathList( std::vector< S3D_ALIAS >& aPathList } -wxString S3D_FILENAME_RESOLVER::ResolvePath( const wxString& aFileName ) +wxString FILENAME_RESOLVER::ResolvePath( const wxString& aFileName ) { - wxCriticalSectionLocker lock( lock3D_resolver ); + wxCriticalSectionLocker lock( lock_resolver ); if( aFileName.empty() ) return wxEmptyString; @@ -329,8 +326,8 @@ wxString S3D_FILENAME_RESOLVER::ResolvePath( const wxString& aFileName ) // a. an aliased shortened name or // b. cannot be determined - std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end(); // check the path relative to the current project directory; // note: this is not necessarily the same as the current working @@ -438,14 +435,14 @@ wxString S3D_FILENAME_RESOLVER::ResolvePath( const wxString& aFileName ) } -bool S3D_FILENAME_RESOLVER::addPath( const S3D_ALIAS& aPath ) +bool FILENAME_RESOLVER::addPath( const SEARCH_PATH& aPath ) { if( aPath.m_alias.empty() || aPath.m_pathvar.empty() ) return false; - wxCriticalSectionLocker lock( lock3D_resolver ); + wxCriticalSectionLocker lock( lock_resolver ); - S3D_ALIAS tpath = aPath; + SEARCH_PATH tpath = aPath; #ifdef _WIN32 while( tpath.m_pathvar.EndsWith( wxT( "\\" ) ) ) @@ -492,8 +489,8 @@ bool S3D_FILENAME_RESOLVER::addPath( const S3D_ALIAS& aPath ) } wxString pname = path.GetPath(); - std::list< S3D_ALIAS >::iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::iterator ePL = m_Paths.end(); while( sPL != ePL ) { @@ -520,7 +517,7 @@ bool S3D_FILENAME_RESOLVER::addPath( const S3D_ALIAS& aPath ) } -bool S3D_FILENAME_RESOLVER::readPathList( void ) +bool FILENAME_RESOLVER::readPathList() { if( m_ConfigDir.empty() ) { @@ -532,7 +529,7 @@ bool S3D_FILENAME_RESOLVER::readPathList( void ) return false; } - wxFileName cfgpath( m_ConfigDir, S3D_RESOLVER_CONFIG ); + wxFileName cfgpath( m_ConfigDir, RESOLVER_CONFIG ); cfgpath.Normalize(); wxString cfgname = cfgpath.GetFullPath(); @@ -565,7 +562,7 @@ bool S3D_FILENAME_RESOLVER::readPathList( void ) } int lineno = 0; - S3D_ALIAS al; + SEARCH_PATH al; size_t idx; int vnum = 0; // version number @@ -619,14 +616,11 @@ bool S3D_FILENAME_RESOLVER::readPathList( void ) if( vnum < CFGFILE_VERSION ) writePathList(); - if( m_Paths.size() != nitems ) - return true; - - return false; + return( m_Paths.size() != nitems ); } -bool S3D_FILENAME_RESOLVER::writePathList( void ) +bool FILENAME_RESOLVER::writePathList() { if( m_ConfigDir.empty() ) { @@ -641,13 +635,13 @@ bool S3D_FILENAME_RESOLVER::writePathList( void ) } // skip all ${ENV_VAR} alias names - std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end(); while( sPL != ePL && ( sPL->m_alias.StartsWith( "${" ) || sPL->m_alias.StartsWith( "$(" ) ) ) ++sPL; - wxFileName cfgpath( m_ConfigDir, S3D_RESOLVER_CONFIG ); + wxFileName cfgpath( m_ConfigDir, RESOLVER_CONFIG ); wxString cfgname = cfgpath.GetFullPath(); std::ofstream cfgFile; @@ -694,7 +688,7 @@ bool S3D_FILENAME_RESOLVER::writePathList( void ) } -void S3D_FILENAME_RESOLVER::checkEnvVarPath( const wxString& aPath ) +void FILENAME_RESOLVER::checkEnvVarPath( const wxString& aPath ) { bool useParen = false; @@ -731,7 +725,7 @@ void S3D_FILENAME_RESOLVER::checkEnvVarPath( const wxString& aPath ) ++sPL; } - S3D_ALIAS lpath; + SEARCH_PATH lpath; lpath.m_alias = envar; lpath.m_pathvar = lpath.m_alias; wxFileName tmpFN; @@ -756,20 +750,19 @@ void S3D_FILENAME_RESOLVER::checkEnvVarPath( const wxString& aPath ) return; m_Paths.insert( sPL, lpath ); - return; } -wxString S3D_FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName ) +wxString FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName ) { wxString fname = aFullPathName; if( m_Paths.empty() ) createPathList(); - wxCriticalSectionLocker lock( lock3D_resolver ); - std::list< S3D_ALIAS >::const_iterator sL = m_Paths.begin(); - std::list< S3D_ALIAS >::const_iterator eL = m_Paths.end(); + wxCriticalSectionLocker lock( lock_resolver ); + std::list< SEARCH_PATH >::const_iterator sL = m_Paths.begin(); + std::list< SEARCH_PATH >::const_iterator eL = m_Paths.end(); size_t idx; while( sL != eL ) @@ -807,7 +800,7 @@ wxString S3D_FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName ) idx = fname.find( fps ); - if( std::string::npos != idx && 0 == idx ) + if( idx == 0 ) { fname = fname.substr( fps.size() ); @@ -851,13 +844,13 @@ wxString S3D_FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName ) -const std::list< S3D_ALIAS >* S3D_FILENAME_RESOLVER::GetPaths( void ) +const std::list< SEARCH_PATH >* FILENAME_RESOLVER::GetPaths() { return &m_Paths; } -bool S3D_FILENAME_RESOLVER::SplitAlias( const wxString& aFileName, +bool FILENAME_RESOLVER::SplitAlias( const wxString& aFileName, wxString& anAlias, wxString& aRelPath ) { anAlias.clear(); @@ -976,7 +969,7 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& } -bool S3D_FILENAME_RESOLVER::ValidateFileName( const wxString& aFileName, bool& hasAlias ) +bool FILENAME_RESOLVER::ValidateFileName( const wxString& aFileName, bool& hasAlias ) { // Rules: // 1. The generic form of an aliased 3D relative path is: @@ -1034,7 +1027,7 @@ bool S3D_FILENAME_RESOLVER::ValidateFileName( const wxString& aFileName, bool& h } -bool S3D_FILENAME_RESOLVER::GetKicadPaths( std::list< wxString >& paths ) +bool FILENAME_RESOLVER::GetKicadPaths( std::list< wxString >& paths ) { paths.clear(); diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 23df10a564..3a1344da15 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include @@ -517,7 +517,7 @@ bool PGM_BASE::InitPgm() else { tmpFileName.AppendDir( wxT( "packages3d" ) ); - envVarItem.SetDefinedExternally( false ); + envVarItem.SetDefinedExternally( true ); } envVarItem.SetValue( tmpFileName.GetFullPath() ); @@ -975,40 +975,8 @@ void PGM_BASE::SetLocalEnvVariables( const ENV_VAR_MAP& aEnvVarMap ) } -void PGM_BASE::ConfigurePaths( wxWindow* aParent ) +void PGM_BASE::ConfigurePaths( wxWindow* aParent, FILENAME_RESOLVER* aResolver ) { - DIALOG_ENV_VAR_CONFIG dlg_envvars( aParent, GetLocalEnvVariables() ); - - if( dlg_envvars.ShowModal() == wxID_CANCEL ) - return; - - ENV_VAR_MAP envVarMap = dlg_envvars.GetEnvVarMap(); - - for( ENV_VAR_MAP_ITER it = envVarMap.begin(); it != envVarMap.end(); ++it ) - { - wxLogTrace( traceEnvVars, wxT( "Environment variable %s=%s defined externally = %d" ), - GetChars( it->first ), GetChars( it->second.GetValue() ), - it->second.GetDefinedExternally() ); - } - - // If any of the environment variables are defined externally, warn the user that the - // next time kicad is run that the externally defined variables will be used instead of - // the user's settings. This is by design. - if( dlg_envvars.ExternalDefsChanged() && m_show_env_var_dialog ) - { - wxString msg1 = _( "Warning! Some of paths you have configured have been defined \n" - "externally to the running process and will be temporarily overwritten." ); - wxString msg2 = _( "The next time KiCad is launched, any paths that have already\n" - "been defined are honored and any settings defined in the path\n" - "configuration dialog are ignored. If you did not intend for this\n" - "behavior, either rename any conflicting entries or remove the\n" - "external environment variable definition(s) from your system." ); - wxRichMessageDialog dlg( aParent, msg1, _( "Warning" ), wxOK | wxCENTRE ); - dlg.ShowDetailedText( msg2 ); - dlg.ShowCheckBox( _( "Do not show this message again." ) ); - dlg.ShowModal(); - m_show_env_var_dialog = !dlg.IsCheckBoxChecked(); - } - - SetLocalEnvVariables( dlg_envvars.GetEnvVarMap() ); + DIALOG_CONFIGURE_PATHS dlg( aParent, aResolver ); + dlg.ShowModal(); } diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index dc65c0a530..31d612af9b 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -41,6 +41,7 @@ #include #include #include +#include <3d_cache/3d_cache.h> #include #include @@ -974,7 +975,7 @@ void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber ) void CVPCB_MAINFRAME::OnConfigurePaths( wxCommandEvent& aEvent ) { - Pgm().ConfigurePaths( this ); + Pgm().ConfigurePaths( this, Prj().Get3DCacheManager()->GetResolver() ); } diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index e91eb576a5..d72fa995f4 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -263,7 +263,7 @@ void SCH_BASE_FRAME::UpdateStatusBar() void SCH_BASE_FRAME::OnConfigurePaths( wxCommandEvent& aEvent ) { - Pgm().ConfigurePaths( this ); + Pgm().ConfigurePaths( this, nullptr ); } diff --git a/include/dialog_configure_paths.h b/include/dialog_configure_paths.h new file mode 100644 index 0000000000..bf12896eb9 --- /dev/null +++ b/include/dialog_configure_paths.h @@ -0,0 +1,87 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2015 Wayne Stambaugh + * Copyright (C) 2015-2018 Kicad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _DIALOG_CONFIGURE_PATHS_H_ +#define _DIALOG_CONFIGURE_PATHS_H_ + +#include <../common/dialogs/dialog_configure_paths_base.h> + +#include +#include + + +class EDA_DRAW_FRAME; +class FILENAME_RESOLVER; + +/** + * DIALOG_CONFIGURE_PATHS class declaration + */ + +class DIALOG_CONFIGURE_PATHS: public DIALOG_CONFIGURE_PATHS_BASE +{ +public: + DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESOLVER* aResolver ); + virtual ~DIALOG_CONFIGURE_PATHS(); + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + +protected: + // Various button callbacks + virtual void OnGridCellRightClick( wxGridEvent& event ) override; + virtual void OnGridSize( wxSizeEvent& event ) override; + virtual void OnUpdateUI( wxUpdateUIEvent& event ) override; + virtual void OnGridCellChanging( wxGridEvent& event ); + virtual void OnAddEnvVar( wxCommandEvent& event ) override; + virtual void OnRemoveEnvVar( wxCommandEvent& event ) override; + virtual void OnAddSearchPath( wxCommandEvent& event ) override; + virtual void OnDeleteSearchPath( wxCommandEvent& event ) override; + virtual void OnSearchPathMoveUp( wxCommandEvent& event ) override; + virtual void OnSearchPathMoveDown( wxCommandEvent& event ) override; + virtual void OnHelp( wxCommandEvent& event ) override; + + void AppendEnvVar( const wxString& aName, const wxString& aPath, + bool isExternal ); + void AppendSearchPath( const wxString& aName, const wxString& aPath, + const wxString& aDescription ); + void AdjustGridColumns( int aWidth ); + + /** + * Determine if a particular ENV_VAR is protected + */ + bool IsEnvVarImmutable( const wxString aEnvVar ); + +private: + wxString m_errorMsg; + wxGrid* m_errorGrid; + int m_errorRow; + int m_errorCol; + + FILENAME_RESOLVER* m_resolver; + wxString m_curdir; + wxTextValidator m_aliasValidator; + +}; + +#endif // _DIALOG_CONFIGURE_PATHS_H_ diff --git a/include/dialog_env_var_config.h b/include/dialog_env_var_config.h deleted file mode 100644 index 783da0ad5c..0000000000 --- a/include/dialog_env_var_config.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This program source code file is part of KICAD, a free EDA CAD application. - * - * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2015 Kicad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef _DIALOG_ENV_VAR_CONFIG_H_ -#define _DIALOG_ENV_VAR_CONFIG_H_ - -class EDA_DRAW_FRAME; - -#include <../common/dialogs/dialog_env_var_config_base.h> - -#include - - -/** - * DIALOG_ENV_VAR_CONFIG class declaration - */ - -class DIALOG_ENV_VAR_CONFIG: public DIALOG_ENV_VAR_CONFIG_BASE -{ -private: - ENV_VAR_MAP m_envVarMap; - bool m_extDefsChanged = false; - -protected: - - /** - * Update the displayed list of ENV_VAR paths - */ - void PopulatePathList(); - - /** - * Edit the currently selected ENV_VAR entry - */ - void EditSelectedEntry(); - - // Various button callbacks - virtual void OnAddButton( wxCommandEvent& event ) override; - virtual void OnEditButton( wxCommandEvent& event ) override; - virtual void OnRemoveButton( wxCommandEvent& event ) override; - virtual void OnHelpButton( wxCommandEvent& event ) override; - - virtual void OnPathSelected( wxListEvent& event ) override; - virtual void OnPathActivated( wxListEvent& event ) override; - - // Variable for keeping track of currently selected list index - unsigned int m_pathIndex = 0; - - /** - * Extract the NAME and PATH data from the ENV_VAR at the provided index - * @param aIndex is the index to extract data from - * @return true if data was extracted else false - */ - bool GetPathAtIndex( unsigned int aIndex, wxString& aEnvVar, wxString& aEnvPath ); - - /** - * Determine if a particular ENV_VAR is protected - * @param aEnvVar is the name of the ENV_VAR - */ - bool IsEnvVarImmutable( const wxString aEnvVar ); - - /** - * Select the ENV_VAR at the provided index - */ - void SelectListIndex( unsigned int aIndex ); - -public: - DIALOG_ENV_VAR_CONFIG( wxWindow* parent, const ENV_VAR_MAP& aEnvVarMap ); - virtual ~DIALOG_ENV_VAR_CONFIG() {} - - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - bool ExternalDefsChanged() const { return m_extDefsChanged; } - - const ENV_VAR_MAP& GetEnvVarMap() const - { - return m_envVarMap; - } -}; - -#endif // _DIALOG_ENV_VAR_CONFIG_H_ diff --git a/3d-viewer/3d_cache/3d_filename_resolver.h b/include/filename_resolver.h similarity index 93% rename from 3d-viewer/3d_cache/3d_filename_resolver.h rename to include/filename_resolver.h index 432bbb70cc..21bd9c833c 100644 --- a/3d-viewer/3d_cache/3d_filename_resolver.h +++ b/include/filename_resolver.h @@ -22,7 +22,7 @@ */ /** - * @file 3d_filename_resolver.h + * @file filename_resolver.h * provides an extensible class to resolve 3D model paths. Initially * the legacy behavior will be implemented and an incomplete path * would be checked against the project directory or the KISYS3DMOD @@ -30,18 +30,17 @@ * paths may be specified. */ -#ifndef FILENAME_RESOLVER_3D_H -#define FILENAME_RESOLVER_3D_H +#ifndef FILENAME_RESOLVER_H +#define FILENAME_RESOLVER_H #include #include #include #include -#include "str_rsort.h" class PGM_BASE; -struct S3D_ALIAS +struct SEARCH_PATH { wxString m_alias; // alias to the base path wxString m_pathvar; // base path as stored in the config file @@ -49,11 +48,11 @@ struct S3D_ALIAS wxString m_description; // description of the aliased path }; -class S3D_FILENAME_RESOLVER +class FILENAME_RESOLVER { private: wxString m_ConfigDir; // 3D configuration directory - std::list< S3D_ALIAS > m_Paths; // list of base paths to search from + std::list< SEARCH_PATH > m_Paths; // list of base paths to search from int m_errflags; PGM_BASE* m_pgm; wxString m_curProjDir; @@ -76,7 +75,7 @@ private: * @param aPath is the alias set to be checked and added * @return true if aPath is valid */ - bool addPath( const S3D_ALIAS& aPath ); + bool addPath( const SEARCH_PATH& aPath ); /** * Function readPathList @@ -105,7 +104,7 @@ private: void checkEnvVarPath( const wxString& aPath ); public: - S3D_FILENAME_RESOLVER(); + FILENAME_RESOLVER(); /** * Function Set3DConfigDir @@ -143,7 +142,7 @@ public: * clears the current path list and substitutes the given path * list, updating the path configuration file on success. */ - bool UpdatePathList( std::vector< S3D_ALIAS >& aPathList ); + bool UpdatePathList( std::vector< SEARCH_PATH >& aPathList ); /** * Function ResolvePath @@ -175,7 +174,7 @@ public: * * @return pointer to the internal path list */ - const std::list< S3D_ALIAS >* GetPaths( void ); + const std::list< SEARCH_PATH >* GetPaths( void ); /** * Function SplitAlias @@ -201,4 +200,4 @@ public: bool GetKicadPaths( std::list< wxString >& paths ); }; -#endif // FILENAME_RESOLVER_3D_H +#endif // FILENAME_RESOLVER_H diff --git a/include/kicad_string.h b/include/kicad_string.h index f8ffe1a8e3..e997aa2928 100644 --- a/include/kicad_string.h +++ b/include/kicad_string.h @@ -189,4 +189,52 @@ bool ReplaceIllegalFileNameChars( wxString& aName, int aReplaceChar = 0 ); extern "C" char* strtok_r( char* str, const char* delim, char** nextp ); #endif +/** + * A helper for sorting strings from the rear. Useful for things like 3d model names + * where they tend to be largely repititous at the front. + */ +struct rsort_wxString +{ + bool operator() (const wxString& strA, const wxString& strB ) const + { + wxString::const_reverse_iterator sA = strA.rbegin(); + wxString::const_reverse_iterator eA = strA.rend(); + + wxString::const_reverse_iterator sB = strB.rbegin(); + wxString::const_reverse_iterator eB = strB.rend(); + + if( strA.empty() ) + { + if( strB.empty() ) + return false; + + // note: this rule implies that a null string is first in the sort order + return true; + } + + if( strB.empty() ) + return false; + + while( sA != eA && sB != eB ) + { + if( (*sA) == (*sB) ) + { + ++sA; + ++sB; + continue; + } + + if( (*sA) < (*sB) ) + return true; + else + return false; + } + + if( sB == eB ) + return false; + + return true; + } +}; + #endif // KICAD_STRING_H_ diff --git a/include/pgm_base.h b/include/pgm_base.h index 0fa00f7be9..92a67cd176 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -43,6 +43,8 @@ class wxApp; class wxMenu; class wxWindow; +class FILENAME_RESOLVER; + // inter program module calling #define VTBL_ENTRY virtual @@ -279,11 +281,8 @@ public: * the footprint library table and the 3D model importer. It was added to PGM_BASE because * it will eventually find use for in schematic I/O design so it needs to accessible by * almost every KiCad application. - * - * @param aParent - a pointer the wxWindow parent of the dialog or NULL to use the top level - * window. */ - VTBL_ENTRY void ConfigurePaths( wxWindow* aParent = NULL ); + VTBL_ENTRY void ConfigurePaths( wxWindow* aParent, FILENAME_RESOLVER* aResolver ); /** * Function App diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 899815b38f..4368bec1a5 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -588,5 +588,5 @@ void KICAD_MANAGER_FRAME::Process_Config( wxCommandEvent& event ) void KICAD_MANAGER_FRAME::OnConfigurePaths( wxCommandEvent& aEvent ) { - Pgm().ConfigurePaths( this ); + Pgm().ConfigurePaths( this, nullptr ); } diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp index 15fbc3f563..a7c1fbf7f2 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp @@ -49,13 +49,13 @@ #include #include #include +#include #include #include #include "3d_cache/dialogs/panel_prev_model.h" #include "3d_cache/dialogs/3d_cache_dialogs.h" #include "3d_cache/3d_cache.h" -#include "3d_cache/3d_filename_resolver.h" #include @@ -312,7 +312,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::InitModeditProperties() wxString origPath; wxString alias; wxString shortPath; - S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); + FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); while( sM != eM ) { @@ -498,7 +498,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::Edit3DShapeFileName() WX_TEXT_ENTRY_DIALOG dlg( this, wxEmptyString, wxEmptyString, filename ); bool hasAlias; - S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); + FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); if( dlg.ShowModal() != wxID_OK ) return; @@ -573,7 +573,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::BrowseAndAdd3DShapeFile() prj.SetRString( PROJECT::VIEWER_3D_PATH, initialpath ); sidx = wxString::Format( wxT( "%i" ), filter ); prj.SetRString( PROJECT::VIEWER_3D_FILTER_INDEX, sidx ); - S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); + FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); wxString alias; wxString shortPath; wxString filename = model.m_Filename; diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index 1031a96497..e7afd5266f 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -53,11 +53,11 @@ #include #include #include +#include "filename_resolver.h" #include #include "3d_cache/dialogs/panel_prev_model.h" #include "3d_cache/dialogs/3d_cache_dialogs.h" #include "3d_cache/3d_cache.h" -#include "3d_cache/3d_filename_resolver.h" #include @@ -157,7 +157,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::initModeditProperties() wxString origPath; wxString alias; wxString shortPath; - S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); + FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); while( sM != eM ) { @@ -371,7 +371,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::Edit3DShapeFileName() WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filepath:" ), _( "Edit 3D Shape Name" ), filename ); bool hasAlias; - S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); + FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); if( dlg.ShowModal() != wxID_OK ) return; @@ -449,7 +449,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::BrowseAndAdd3DShapeFile() wxString origPath = model.m_Filename; wxString alias; wxString shortPath; - S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); + FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver(); if( res && res->SplitAlias( origPath, alias, shortPath ) ) { diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp index 647218e2a2..144313b0b8 100644 --- a/pcbnew/exporters/export_idf.cpp +++ b/pcbnew/exporters/export_idf.cpp @@ -39,7 +39,7 @@ #include "project.h" #include "kiway.h" #include "3d_cache/3d_cache.h" -#include "3d_cache/3d_filename_resolver.h" +#include "filename_resolver.h" #ifndef PCBNEW #define PCBNEW // needed to define the right value of Millimeter2iu(x) @@ -49,7 +49,7 @@ // assumed default graphical line thickness: == 0.1mm #define LINE_WIDTH (Millimeter2iu( 0.1 )) -static S3D_FILENAME_RESOLVER* resolver; +static FILENAME_RESOLVER* resolver; /** * Function idf_export_outline diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 0a16e8254b..2763619ebe 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -907,7 +907,7 @@ void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event ) void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent ) { - Pgm().ConfigurePaths( this ); + Pgm().ConfigurePaths( this, Prj().Get3DCacheManager()->GetResolver() ); } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index f4898e7510..e4b091a401 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1216,7 +1216,7 @@ bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName ) void PCB_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent ) { - Pgm().ConfigurePaths( this ); + Pgm().ConfigurePaths( this, Prj().Get3DCacheManager()->GetResolver() ); } diff --git a/utils/kicad2step/pcb/3d_resolver.cpp b/utils/kicad2step/pcb/3d_resolver.cpp index 864ab38b5c..d3468514ab 100644 --- a/utils/kicad2step/pcb/3d_resolver.cpp +++ b/utils/kicad2step/pcb/3d_resolver.cpp @@ -136,7 +136,7 @@ bool S3D_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgChanged ) if( m_Paths.empty() ) { - S3D_ALIAS al; + SEARCH_PATH al; al.m_alias = "${KIPRJMOD}"; al.m_pathvar = "${KIPRJMOD}"; al.m_pathexp = m_curProjDir; @@ -195,7 +195,7 @@ bool S3D_RESOLVER::createPathList( void ) // we cannot set a sensible default so we use an empty string. // the user may change this later with a call to SetProjectDir() - S3D_ALIAS lpath; + SEARCH_PATH lpath; lpath.m_alias = "${KIPRJMOD}"; lpath.m_pathvar = "${KIPRJMOD}"; lpath.m_pathexp = m_curProjDir; @@ -294,8 +294,8 @@ bool S3D_RESOLVER::createPathList( void ) #ifdef DEBUG wxLogTrace( MASK_3D_RESOLVER, " * [3D model] search paths:\n" ); - std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end(); while( sPL != ePL ) { @@ -308,7 +308,7 @@ bool S3D_RESOLVER::createPathList( void ) } -bool S3D_RESOLVER::UpdatePathList( std::vector< S3D_ALIAS >& aPathList ) +bool S3D_RESOLVER::UpdatePathList( std::vector< SEARCH_PATH >& aPathList ) { wxUniChar envMarker( '$' ); @@ -408,8 +408,8 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName ) // a. an aliased shortened name or // b. cannot be determined - std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end(); // check the path relative to the current project directory; // note: this is not necessarily the same as the current working @@ -519,14 +519,14 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName ) } -bool S3D_RESOLVER::addPath( const S3D_ALIAS& aPath ) +bool S3D_RESOLVER::addPath( const SEARCH_PATH& aPath ) { if( aPath.m_alias.empty() || aPath.m_pathvar.empty() ) return false; wxCriticalSectionLocker lock( lock3D_resolver ); - S3D_ALIAS tpath = aPath; + SEARCH_PATH tpath = aPath; #ifdef _WIN32 while( tpath.m_pathvar.EndsWith( "\\" ) ) @@ -566,8 +566,8 @@ bool S3D_RESOLVER::addPath( const S3D_ALIAS& aPath ) } wxString pname = path.GetPath(); - std::list< S3D_ALIAS >::iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::iterator ePL = m_Paths.end(); while( sPL != ePL ) { @@ -639,7 +639,7 @@ bool S3D_RESOLVER::readPathList( void ) } int lineno = 0; - S3D_ALIAS al; + SEARCH_PATH al; size_t idx; int vnum = 0; // version number @@ -715,8 +715,8 @@ bool S3D_RESOLVER::writePathList( void ) } // skip all ${ENV_VAR} alias names - std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end(); while( sPL != ePL && ( sPL->m_alias.StartsWith( "${" ) || sPL->m_alias.StartsWith( "$(" ) ) ) @@ -818,8 +818,8 @@ void S3D_RESOLVER::checkEnvVarPath( const wxString& aPath ) // check if the alias exists; if not then add it to the end of the // env var section of the path list - std::list< S3D_ALIAS >::iterator sPL = m_Paths.begin(); - std::list< S3D_ALIAS >::iterator ePL = m_Paths.end(); + std::list< SEARCH_PATH >::iterator sPL = m_Paths.begin(); + std::list< SEARCH_PATH >::iterator ePL = m_Paths.end(); while( sPL != ePL ) { @@ -832,7 +832,7 @@ void S3D_RESOLVER::checkEnvVarPath( const wxString& aPath ) ++sPL; } - S3D_ALIAS lpath; + SEARCH_PATH lpath; lpath.m_alias = envar; lpath.m_pathvar = lpath.m_alias; wxFileName tmpFN( lpath.m_alias, "" ); @@ -896,8 +896,8 @@ wxString S3D_RESOLVER::ShortenPath( const wxString& aFullPathName ) createPathList(); wxCriticalSectionLocker lock( lock3D_resolver ); - std::list< S3D_ALIAS >::const_iterator sL = m_Paths.begin(); - std::list< S3D_ALIAS >::const_iterator eL = m_Paths.end(); + std::list< SEARCH_PATH >::const_iterator sL = m_Paths.begin(); + std::list< SEARCH_PATH >::const_iterator eL = m_Paths.end(); size_t idx; while( sL != eL ) @@ -960,7 +960,7 @@ wxString S3D_RESOLVER::ShortenPath( const wxString& aFullPathName ) -const std::list< S3D_ALIAS >* S3D_RESOLVER::GetPaths( void ) +const std::list< SEARCH_PATH >* S3D_RESOLVER::GetPaths( void ) { return &m_Paths; } diff --git a/utils/kicad2step/pcb/3d_resolver.h b/utils/kicad2step/pcb/3d_resolver.h index 8959396e8e..e9ec2d1825 100644 --- a/utils/kicad2step/pcb/3d_resolver.h +++ b/utils/kicad2step/pcb/3d_resolver.h @@ -91,7 +91,7 @@ namespace S3D class KICADPCB; -struct S3D_ALIAS +struct SEARCH_PATH { wxString m_alias; // alias to the base path wxString m_pathvar; // base path as stored in the config file @@ -103,7 +103,7 @@ class S3D_RESOLVER { private: wxString m_ConfigDir; // 3D configuration directory - std::list< S3D_ALIAS > m_Paths; // list of base paths to search from + std::list< SEARCH_PATH > m_Paths; // list of base paths to search from // mapping of (short) file names to resolved names std::map< wxString, wxString, S3D::rsort_wxString > m_NameMap; int m_errflags; @@ -129,7 +129,7 @@ private: * @param aPath is the alias set to be checked and added * @return true if aPath is valid */ - bool addPath( const S3D_ALIAS& aPath ); + bool addPath( const SEARCH_PATH& aPath ); /** * Function readPathList @@ -189,7 +189,7 @@ public: * clears the current path list and substitutes the given path * list, updating the path configuration file on success. */ - bool UpdatePathList( std::vector< S3D_ALIAS >& aPathList ); + bool UpdatePathList( std::vector< SEARCH_PATH >& aPathList ); /** * Function ResolvePath @@ -221,7 +221,7 @@ public: * * @return pointer to the internal path list */ - const std::list< S3D_ALIAS >* GetPaths( void ); + const std::list< SEARCH_PATH >* GetPaths( void ); /** * Function SplitAlias