Fold 3D Search Paths dialog into Configure Paths.
Use in-place editing for both. Fixes: lp:1743823 * https://bugs.launchpad.net/kicad/+bug/1743823 (cherry picked from commit 33622cd)
This commit is contained in:
parent
124c6d9857
commit
8f0aa68ab8
|
@ -43,7 +43,7 @@
|
||||||
#include "3d_cache.h"
|
#include "3d_cache.h"
|
||||||
#include "3d_info.h"
|
#include "3d_info.h"
|
||||||
#include "sg/scenegraph.h"
|
#include "sg/scenegraph.h"
|
||||||
#include "3d_filename_resolver.h"
|
#include "filename_resolver.h"
|
||||||
#include "3d_plugin_manager.h"
|
#include "3d_plugin_manager.h"
|
||||||
#include "plugins/3dapi/ifsg_api.h"
|
#include "plugins/3dapi/ifsg_api.h"
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ const wxString S3D_CACHE_ENTRY::GetCacheBaseName( void )
|
||||||
S3D_CACHE::S3D_CACHE()
|
S3D_CACHE::S3D_CACHE()
|
||||||
{
|
{
|
||||||
m_DirtyCache = false;
|
m_DirtyCache = false;
|
||||||
m_FNResolver = new S3D_FILENAME_RESOLVER;
|
m_FNResolver = new FILENAME_RESOLVER;
|
||||||
m_Plugins = new S3D_PLUGIN_MANAGER;
|
m_Plugins = new S3D_PLUGIN_MANAGER;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -217,7 +217,7 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCach
|
||||||
|
|
||||||
// check cache if file is already loaded
|
// check cache if file is already loaded
|
||||||
wxCriticalSectionLocker lock( lock3D_cache );
|
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 );
|
mi = m_CacheMap.find( full3Dpath );
|
||||||
|
|
||||||
if( mi != m_CacheMap.end() )
|
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;
|
return m_FNResolver;
|
||||||
}
|
}
|
||||||
|
@ -818,7 +818,7 @@ wxString S3D_CACHE::GetModelHash( const wxString& aModelFileName )
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
|
||||||
// check cache if file is already loaded
|
// 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 );
|
mi = m_CacheMap.find( full3Dpath );
|
||||||
|
|
||||||
if( mi != m_CacheMap.end() )
|
if( mi != m_CacheMap.end() )
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include "str_rsort.h"
|
#include "kicad_string.h"
|
||||||
#include "3d_filename_resolver.h"
|
#include "filename_resolver.h"
|
||||||
#include "3d_info.h"
|
#include "3d_info.h"
|
||||||
#include "plugins/3dapi/c3dmodel.h"
|
#include "plugins/3dapi/c3dmodel.h"
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class PGM_BASE;
|
||||||
class S3D_CACHE;
|
class S3D_CACHE;
|
||||||
class S3D_CACHE_ENTRY;
|
class S3D_CACHE_ENTRY;
|
||||||
class SCENEGRAPH;
|
class SCENEGRAPH;
|
||||||
class S3D_FILENAME_RESOLVER;
|
class FILENAME_RESOLVER;
|
||||||
class S3D_PLUGIN_MANAGER;
|
class S3D_PLUGIN_MANAGER;
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,10 +53,10 @@ private:
|
||||||
std::list< S3D_CACHE_ENTRY* > m_CacheList;
|
std::list< S3D_CACHE_ENTRY* > m_CacheList;
|
||||||
|
|
||||||
/// mapping of file names to cache names and data
|
/// 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
|
/// object to resolve file names
|
||||||
S3D_FILENAME_RESOLVER* m_FNResolver;
|
FILENAME_RESOLVER* m_FNResolver;
|
||||||
|
|
||||||
/// plugin manager
|
/// plugin manager
|
||||||
S3D_PLUGIN_MANAGER* m_Plugins;
|
S3D_PLUGIN_MANAGER* m_Plugins;
|
||||||
|
@ -167,7 +167,7 @@ public:
|
||||||
*/
|
*/
|
||||||
SCENEGRAPH* Load( const wxString& aModelFile );
|
SCENEGRAPH* Load( const wxString& aModelFile );
|
||||||
|
|
||||||
S3D_FILENAME_RESOLVER* GetResolver( void );
|
FILENAME_RESOLVER* GetResolver( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetFileFilters
|
* Function GetFileFilters
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "3d_cache.h"
|
#include "3d_cache.h"
|
||||||
#include "plugins/3dapi/ifsg_api.h"
|
#include "plugins/3dapi/ifsg_api.h"
|
||||||
#include "3d_cache_dialogs.h"
|
#include "3d_cache_dialogs.h"
|
||||||
#include "dlg_3d_pathconfig.h"
|
#include "dialog_configure_paths.h"
|
||||||
#include "dlg_select_3dmodel.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() )
|
return( dlg.ShowModal() == wxID_OK );
|
||||||
{
|
|
||||||
delete dp;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete dp;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,14 +27,14 @@
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
class S3D_CACHE;
|
class S3D_CACHE;
|
||||||
class S3D_FILENAME_RESOLVER;
|
class FILENAME_RESOLVER;
|
||||||
|
|
||||||
namespace S3D
|
namespace S3D
|
||||||
{
|
{
|
||||||
bool Select3DModel( wxWindow* aParent, S3D_CACHE* aCache,
|
bool Select3DModel( wxWindow* aParent, S3D_CACHE* aCache,
|
||||||
wxString& prevModelSelectDir, int& prevModelWildcard, MODULE_3D_SETTINGS* aModel );
|
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
|
#endif // CACHE_DIALOGS_3D_H
|
||||||
|
|
|
@ -1,383 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
|
||||||
*
|
|
||||||
* 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 <wx/msgdlg.h>
|
|
||||||
#include <pgm_base.h>
|
|
||||||
#include <html_messagebox.h>
|
|
||||||
#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<S3D_ALIAS> 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.<br>KiCad "
|
|
||||||
"environment variables and their values are shown for "
|
|
||||||
"reference only and cannot be edited." );
|
|
||||||
msg << "<br><br><b>";
|
|
||||||
msg << _( "Alias names may not contain any of the characters " );
|
|
||||||
msg << "{}[]()%~<>\"='`;:.,&?/\\|$";
|
|
||||||
msg << "</b>";
|
|
||||||
|
|
||||||
HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) );
|
|
||||||
dlg.AddHTML_Text( msg );
|
|
||||||
dlg.ShowModal();
|
|
||||||
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
|
||||||
*
|
|
||||||
* 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 <wx/valtext.h>
|
|
||||||
#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
|
|
|
@ -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 );
|
|
||||||
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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 <wx/artprov.h>
|
|
||||||
#include <wx/xrc/xmlres.h>
|
|
||||||
#include <wx/intl.h>
|
|
||||||
#include "dialog_shim.h"
|
|
||||||
#include <wx/colour.h>
|
|
||||||
#include <wx/settings.h>
|
|
||||||
#include <wx/string.h>
|
|
||||||
#include <wx/font.h>
|
|
||||||
#include <wx/grid.h>
|
|
||||||
#include <wx/gdicmn.h>
|
|
||||||
#include <wx/button.h>
|
|
||||||
#include <wx/sizer.h>
|
|
||||||
#include <wx/statline.h>
|
|
||||||
#include <wx/dialog.h>
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// 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__
|
|
|
@ -240,9 +240,9 @@ void DLG_SELECT_3DMODEL::updateDirChoiceList( void )
|
||||||
if( NULL == m_FileTree || NULL == m_resolver || NULL == dirChoices )
|
if( NULL == m_FileTree || NULL == m_resolver || NULL == dirChoices )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::list< S3D_ALIAS > const* md = m_resolver->GetPaths();
|
std::list< SEARCH_PATH > const* md = m_resolver->GetPaths();
|
||||||
std::list< S3D_ALIAS >::const_iterator sL = md->begin();
|
std::list< SEARCH_PATH >::const_iterator sL = md->begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator eL = md->end();
|
std::list< SEARCH_PATH >::const_iterator eL = md->end();
|
||||||
std::set< wxString > cl;
|
std::set< wxString > cl;
|
||||||
wxString prjDir;
|
wxString prjDir;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
class MODULE_3D_SETTINGS;
|
class MODULE_3D_SETTINGS;
|
||||||
class S3D_CACHE;
|
class S3D_CACHE;
|
||||||
class S3D_FILENAME_RESOLVER;
|
class FILENAME_RESOLVER;
|
||||||
class C3D_MODEL_VIEWER;
|
class C3D_MODEL_VIEWER;
|
||||||
|
|
||||||
class DLG_SELECT_3DMODEL : public DIALOG_SHIM
|
class DLG_SELECT_3DMODEL : public DIALOG_SHIM
|
||||||
|
@ -51,7 +51,7 @@ class DLG_SELECT_3DMODEL : public DIALOG_SHIM
|
||||||
private:
|
private:
|
||||||
MODULE_3D_SETTINGS* m_model; // data for the selected model
|
MODULE_3D_SETTINGS* m_model; // data for the selected model
|
||||||
S3D_CACHE* m_cache; // cache manager
|
S3D_CACHE* m_cache; // cache manager
|
||||||
S3D_FILENAME_RESOLVER* m_resolver; // 3D filename resolver
|
FILENAME_RESOLVER* m_resolver; // 3D filename resolver
|
||||||
|
|
||||||
wxString& m_previousDir;
|
wxString& m_previousDir;
|
||||||
int& m_previousFilterIndex;
|
int& m_previousFilterIndex;
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
// Declared classes to create pointers
|
// Declared classes to create pointers
|
||||||
class S3D_CACHE;
|
class S3D_CACHE;
|
||||||
class S3D_FILENAME_RESOLVER;
|
class FILENAME_RESOLVER;
|
||||||
class BOARD;
|
class BOARD;
|
||||||
class CINFO3D_VISU;
|
class CINFO3D_VISU;
|
||||||
class MODULE;
|
class MODULE;
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxString currentModelFile; ///< Used to check if the model file was changed
|
wxString currentModelFile; ///< Used to check if the model file was changed
|
||||||
S3D_FILENAME_RESOLVER *m_resolver; ///< Used to get the full path name
|
FILENAME_RESOLVER *m_resolver; ///< Used to get the full path name
|
||||||
|
|
||||||
/// The 3D canvas
|
/// The 3D canvas
|
||||||
EDA_3D_CANVAS *m_previewPane;
|
EDA_3D_CANVAS *m_previewPane;
|
||||||
|
|
|
@ -1,87 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
|
||||||
*
|
|
||||||
* 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 <wx/string.h>
|
|
||||||
|
|
||||||
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
|
|
|
@ -33,10 +33,7 @@ set(3D-VIEWER_SRCS
|
||||||
3d_cache/3d_cache_wrapper.cpp
|
3d_cache/3d_cache_wrapper.cpp
|
||||||
3d_cache/3d_cache.cpp
|
3d_cache/3d_cache.cpp
|
||||||
3d_cache/3d_plugin_manager.cpp
|
3d_cache/3d_plugin_manager.cpp
|
||||||
3d_cache/3d_filename_resolver.cpp
|
|
||||||
${DIR_DLG}/3d_cache_dialogs.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}/dlg_select_3dmodel.cpp
|
||||||
${DIR_DLG}/panel_prev_3d_base.cpp
|
${DIR_DLG}/panel_prev_3d_base.cpp
|
||||||
${DIR_DLG}/panel_prev_model.cpp
|
${DIR_DLG}/panel_prev_model.cpp
|
||||||
|
|
|
@ -153,9 +153,9 @@ set( COMMON_ABOUT_DLG_SRCS
|
||||||
)
|
)
|
||||||
|
|
||||||
set( COMMON_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_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_exit_base.cpp
|
||||||
dialogs/dialog_file_dir_picker.cpp
|
dialogs/dialog_file_dir_picker.cpp
|
||||||
dialogs/dialog_hotkeys_editor.cpp
|
dialogs/dialog_hotkeys_editor.cpp
|
||||||
|
@ -261,6 +261,7 @@ set( COMMON_SRCS
|
||||||
env_paths.cpp
|
env_paths.cpp
|
||||||
exceptions.cpp
|
exceptions.cpp
|
||||||
executable_names.cpp
|
executable_names.cpp
|
||||||
|
filename_resolver.cpp
|
||||||
filter_reader.cpp
|
filter_reader.cpp
|
||||||
footprint_filter.cpp
|
footprint_filter.cpp
|
||||||
footprint_info.cpp
|
footprint_info.cpp
|
||||||
|
|
|
@ -81,8 +81,8 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( wxString::Format( "No KIWAY_HOLDER in parent chain. Top window is a %s.",
|
// There are a few dialogs, such as Configure Paths, which are called
|
||||||
aParent->GetClassInfo()->GetClassName() ) );
|
// from the top-level wxFrame.
|
||||||
m_units = MILLIMETRES;
|
m_units = MILLIMETRES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,565 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
|
* 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 <dialog_configure_paths.h>
|
||||||
|
|
||||||
|
#include <confirm.h>
|
||||||
|
#include <menus_helpers.h>
|
||||||
|
#include <validators.h>
|
||||||
|
#include <html_messagebox.h>
|
||||||
|
#include <filename_resolver.h>
|
||||||
|
|
||||||
|
|
||||||
|
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<SEARCH_PATH>* 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<SEARCH_PATH> 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<wxGrid*>( 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<wxGrid*>( 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<wxGrid*>( 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( "<br><br><b>" );
|
||||||
|
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( "</b><br><br>" );
|
||||||
|
msg << _( "<b>KICAD_SYMBOL_DIR</b> is the base path of the locally installed symbol libraries." );
|
||||||
|
msg << wxT( "<br><br>" );
|
||||||
|
msg << _( "<b>KIGITHUB</b> is used by KiCad to define the URL of the repository "
|
||||||
|
"of the official KiCad footprint libraries." );
|
||||||
|
msg << wxT( "<br><br>" );
|
||||||
|
msg << _( "<b>KISYS3DMOD</b> is the base path of system footprint 3D "
|
||||||
|
"shapes (.3Dshapes folders)." );
|
||||||
|
msg << wxT( "<br><br>" );
|
||||||
|
msg << _( "<b>KISYSMOD</b> is the base path of locally installed system "
|
||||||
|
"footprint libraries (.pretty folders)." );
|
||||||
|
msg << wxT( "<br><br>" );
|
||||||
|
msg << _( "<b>KIPRJMOD</b> 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( "<br><br>" );
|
||||||
|
msg << _( "<b>KICAD_PTEMPLATES</b> 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;
|
||||||
|
}
|
|
@ -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 );
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -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 <wx/artprov.h>
|
||||||
|
#include <wx/xrc/xmlres.h>
|
||||||
|
#include <wx/intl.h>
|
||||||
|
#include "dialog_shim.h"
|
||||||
|
#include <wx/colour.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/font.h>
|
||||||
|
#include <wx/grid.h>
|
||||||
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/bitmap.h>
|
||||||
|
#include <wx/image.h>
|
||||||
|
#include <wx/icon.h>
|
||||||
|
#include <wx/bmpbuttn.h>
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/statbox.h>
|
||||||
|
#include <wx/dialog.h>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// 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__
|
|
@ -1,511 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
|
||||||
* 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 <dialog_env_var_config.h>
|
|
||||||
|
|
||||||
#include <confirm.h>
|
|
||||||
|
|
||||||
#include <validators.h>
|
|
||||||
#include <html_messagebox.h>
|
|
||||||
|
|
||||||
#include <wx/regex.h>
|
|
||||||
|
|
||||||
/** 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( "<br><br><b>" );
|
|
||||||
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( "</b><br><br>" );
|
|
||||||
msg << _( "<b>KICAD_SYMBOL_DIR</b> is the base path of the locally installed symbol "
|
|
||||||
"libraries." );
|
|
||||||
msg << wxT( "<br><br>" );
|
|
||||||
msg << _( "<b>KIGITHUB</b> 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( "<br><br>" );
|
|
||||||
msg << _( "<b>KISYS3DMOD</b> is the base path of system footprint 3D "
|
|
||||||
"shapes (.3Dshapes folders)." );
|
|
||||||
msg << wxT( "<br><br>" );
|
|
||||||
msg << _( "<b>KISYSMOD</b> is the base path of locally installed system "
|
|
||||||
"footprint libraries (.pretty folders)." );
|
|
||||||
msg << wxT( "<br><br>" );
|
|
||||||
msg << _( "<b>KIPRJMOD</b> 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( "<br><br>" );
|
|
||||||
msg << _( "<b>KICAD_TEMPLATE_DIR</b> is required and is the path containing the project "
|
|
||||||
"templates installed with KiCad." );
|
|
||||||
msg << wxT( "<br><br>" );
|
|
||||||
msg << _( "<b>KICAD_USER_TEMPLATE_DIR</b> 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.<br>"
|
|
||||||
"Environment variables are primarily used for paths to make KiCad portable "
|
|
||||||
"between platforms.<br><br>"
|
|
||||||
"If an environment variable is defined as <b>MYLIBPATH</b> with a "
|
|
||||||
"value <b>e:/kicad_libs</b>, then a library name "
|
|
||||||
"<b>${MYLIBPATH}/mylib.lib</b> gets expanded to "
|
|
||||||
"<b>e:/kicad_libs/mylib.lib</b>"
|
|
||||||
"<br><br>"
|
|
||||||
"<b>Note:</b><br>"
|
|
||||||
"Only characters <b>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_</b> 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();
|
|
||||||
}
|
|
|
@ -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 );
|
|
||||||
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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 <wx/artprov.h>
|
|
||||||
#include <wx/xrc/xmlres.h>
|
|
||||||
#include <wx/intl.h>
|
|
||||||
class DIALOG_SHIM;
|
|
||||||
|
|
||||||
#include "dialog_shim.h"
|
|
||||||
#include <wx/listctrl.h>
|
|
||||||
#include <wx/gdicmn.h>
|
|
||||||
#include <wx/font.h>
|
|
||||||
#include <wx/colour.h>
|
|
||||||
#include <wx/settings.h>
|
|
||||||
#include <wx/string.h>
|
|
||||||
#include <wx/button.h>
|
|
||||||
#include <wx/sizer.h>
|
|
||||||
#include <wx/statline.h>
|
|
||||||
#include <wx/dialog.h>
|
|
||||||
#include <wx/stattext.h>
|
|
||||||
#include <wx/textctrl.h>
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#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__
|
|
|
@ -22,7 +22,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstring>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
@ -32,11 +31,11 @@
|
||||||
#include <trace_helpers.h>
|
#include <trace_helpers.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "3d_filename_resolver.h"
|
#include "filename_resolver.h"
|
||||||
|
|
||||||
// configuration file version
|
// configuration file version
|
||||||
#define CFGFILE_VERSION 1
|
#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
|
// flag bits used to track different one-off messages to users
|
||||||
#define ERRFLG_ALIAS (1)
|
#define ERRFLG_ALIAS (1)
|
||||||
|
@ -45,19 +44,19 @@
|
||||||
|
|
||||||
#define MASK_3D_RESOLVER "3D_RESOLVER"
|
#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 );
|
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_errflags = 0;
|
||||||
m_pgm = NULL;
|
m_pgm = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool S3D_FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir )
|
bool FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir )
|
||||||
{
|
{
|
||||||
if( aConfigDir.empty() )
|
if( aConfigDir.empty() )
|
||||||
return false;
|
return false;
|
||||||
|
@ -71,7 +70,7 @@ bool S3D_FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir )
|
||||||
|
|
||||||
cfgdir.Normalize();
|
cfgdir.Normalize();
|
||||||
|
|
||||||
if( false == cfgdir.DirExists() )
|
if( !cfgdir.DirExists() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_ConfigDir = cfgdir.GetPath();
|
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() )
|
if( aProjDir.empty() )
|
||||||
return false;
|
return false;
|
||||||
|
@ -95,7 +94,7 @@ bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgCh
|
||||||
|
|
||||||
projdir.Normalize();
|
projdir.Normalize();
|
||||||
|
|
||||||
if( false == projdir.DirExists() )
|
if( !projdir.DirExists() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_curProjDir = projdir.GetPath();
|
m_curProjDir = projdir.GetPath();
|
||||||
|
@ -105,7 +104,7 @@ bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgCh
|
||||||
|
|
||||||
if( m_Paths.empty() )
|
if( m_Paths.empty() )
|
||||||
{
|
{
|
||||||
S3D_ALIAS al;
|
SEARCH_PATH al;
|
||||||
al.m_alias = "${KIPRJMOD}";
|
al.m_alias = "${KIPRJMOD}";
|
||||||
al.m_pathvar = "${KIPRJMOD}";
|
al.m_pathvar = "${KIPRJMOD}";
|
||||||
al.m_pathexp = m_curProjDir;
|
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;
|
return m_curProjDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void S3D_FILENAME_RESOLVER::SetProgramBase( PGM_BASE* aBase )
|
void FILENAME_RESOLVER::SetProgramBase( PGM_BASE* aBase )
|
||||||
{
|
{
|
||||||
m_pgm = aBase;
|
m_pgm = aBase;
|
||||||
|
|
||||||
if( NULL == m_pgm || m_Paths.empty() )
|
if( !m_pgm || m_Paths.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// recreate the path list
|
// recreate the path list
|
||||||
m_Paths.clear();
|
m_Paths.clear();
|
||||||
createPathList();
|
createPathList();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool S3D_FILENAME_RESOLVER::createPathList( void )
|
bool FILENAME_RESOLVER::createPathList()
|
||||||
{
|
{
|
||||||
if( !m_Paths.empty() )
|
if( !m_Paths.empty() )
|
||||||
return true;
|
return true;
|
||||||
|
@ -177,7 +174,7 @@ bool S3D_FILENAME_RESOLVER::createPathList( void )
|
||||||
// we cannot set a sensible default so we use an empty string.
|
// we cannot set a sensible default so we use an empty string.
|
||||||
// the user may change this later with a call to SetProjectDir()
|
// the user may change this later with a call to SetProjectDir()
|
||||||
|
|
||||||
S3D_ALIAS lpath;
|
SEARCH_PATH lpath;
|
||||||
lpath.m_alias = "${KIPRJMOD}";
|
lpath.m_alias = "${KIPRJMOD}";
|
||||||
lpath.m_pathvar = "${KIPRJMOD}";
|
lpath.m_pathvar = "${KIPRJMOD}";
|
||||||
lpath.m_pathexp = m_curProjDir;
|
lpath.m_pathexp = m_curProjDir;
|
||||||
|
@ -221,8 +218,8 @@ bool S3D_FILENAME_RESOLVER::createPathList( void )
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
wxLogTrace( MASK_3D_RESOLVER, " * [3D model] search paths:\n" );
|
wxLogTrace( MASK_3D_RESOLVER, " * [3D model] search paths:\n" );
|
||||||
std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
while( sPL != ePL )
|
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( '$' );
|
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() )
|
if( aFileName.empty() )
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
@ -329,8 +326,8 @@ wxString S3D_FILENAME_RESOLVER::ResolvePath( const wxString& aFileName )
|
||||||
// a. an aliased shortened name or
|
// a. an aliased shortened name or
|
||||||
// b. cannot be determined
|
// b. cannot be determined
|
||||||
|
|
||||||
std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
// check the path relative to the current project directory;
|
// check the path relative to the current project directory;
|
||||||
// note: this is not necessarily the same as the current working
|
// 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() )
|
if( aPath.m_alias.empty() || aPath.m_pathvar.empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxCriticalSectionLocker lock( lock3D_resolver );
|
wxCriticalSectionLocker lock( lock_resolver );
|
||||||
|
|
||||||
S3D_ALIAS tpath = aPath;
|
SEARCH_PATH tpath = aPath;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
while( tpath.m_pathvar.EndsWith( wxT( "\\" ) ) )
|
while( tpath.m_pathvar.EndsWith( wxT( "\\" ) ) )
|
||||||
|
@ -492,8 +489,8 @@ bool S3D_FILENAME_RESOLVER::addPath( const S3D_ALIAS& aPath )
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString pname = path.GetPath();
|
wxString pname = path.GetPath();
|
||||||
std::list< S3D_ALIAS >::iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
while( sPL != ePL )
|
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() )
|
if( m_ConfigDir.empty() )
|
||||||
{
|
{
|
||||||
|
@ -532,7 +529,7 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileName cfgpath( m_ConfigDir, S3D_RESOLVER_CONFIG );
|
wxFileName cfgpath( m_ConfigDir, RESOLVER_CONFIG );
|
||||||
cfgpath.Normalize();
|
cfgpath.Normalize();
|
||||||
wxString cfgname = cfgpath.GetFullPath();
|
wxString cfgname = cfgpath.GetFullPath();
|
||||||
|
|
||||||
|
@ -565,7 +562,7 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
int lineno = 0;
|
int lineno = 0;
|
||||||
S3D_ALIAS al;
|
SEARCH_PATH al;
|
||||||
size_t idx;
|
size_t idx;
|
||||||
int vnum = 0; // version number
|
int vnum = 0; // version number
|
||||||
|
|
||||||
|
@ -619,14 +616,11 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
|
||||||
if( vnum < CFGFILE_VERSION )
|
if( vnum < CFGFILE_VERSION )
|
||||||
writePathList();
|
writePathList();
|
||||||
|
|
||||||
if( m_Paths.size() != nitems )
|
return( m_Paths.size() != nitems );
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool S3D_FILENAME_RESOLVER::writePathList( void )
|
bool FILENAME_RESOLVER::writePathList()
|
||||||
{
|
{
|
||||||
if( m_ConfigDir.empty() )
|
if( m_ConfigDir.empty() )
|
||||||
{
|
{
|
||||||
|
@ -641,13 +635,13 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip all ${ENV_VAR} alias names
|
// skip all ${ENV_VAR} alias names
|
||||||
std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
while( sPL != ePL && ( sPL->m_alias.StartsWith( "${" ) || sPL->m_alias.StartsWith( "$(" ) ) )
|
while( sPL != ePL && ( sPL->m_alias.StartsWith( "${" ) || sPL->m_alias.StartsWith( "$(" ) ) )
|
||||||
++sPL;
|
++sPL;
|
||||||
|
|
||||||
wxFileName cfgpath( m_ConfigDir, S3D_RESOLVER_CONFIG );
|
wxFileName cfgpath( m_ConfigDir, RESOLVER_CONFIG );
|
||||||
wxString cfgname = cfgpath.GetFullPath();
|
wxString cfgname = cfgpath.GetFullPath();
|
||||||
std::ofstream cfgFile;
|
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;
|
bool useParen = false;
|
||||||
|
|
||||||
|
@ -731,7 +725,7 @@ void S3D_FILENAME_RESOLVER::checkEnvVarPath( const wxString& aPath )
|
||||||
++sPL;
|
++sPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
S3D_ALIAS lpath;
|
SEARCH_PATH lpath;
|
||||||
lpath.m_alias = envar;
|
lpath.m_alias = envar;
|
||||||
lpath.m_pathvar = lpath.m_alias;
|
lpath.m_pathvar = lpath.m_alias;
|
||||||
wxFileName tmpFN;
|
wxFileName tmpFN;
|
||||||
|
@ -756,20 +750,19 @@ void S3D_FILENAME_RESOLVER::checkEnvVarPath( const wxString& aPath )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_Paths.insert( sPL, lpath );
|
m_Paths.insert( sPL, lpath );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString S3D_FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName )
|
wxString FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName )
|
||||||
{
|
{
|
||||||
wxString fname = aFullPathName;
|
wxString fname = aFullPathName;
|
||||||
|
|
||||||
if( m_Paths.empty() )
|
if( m_Paths.empty() )
|
||||||
createPathList();
|
createPathList();
|
||||||
|
|
||||||
wxCriticalSectionLocker lock( lock3D_resolver );
|
wxCriticalSectionLocker lock( lock_resolver );
|
||||||
std::list< S3D_ALIAS >::const_iterator sL = m_Paths.begin();
|
std::list< SEARCH_PATH >::const_iterator sL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator eL = m_Paths.end();
|
std::list< SEARCH_PATH >::const_iterator eL = m_Paths.end();
|
||||||
size_t idx;
|
size_t idx;
|
||||||
|
|
||||||
while( sL != eL )
|
while( sL != eL )
|
||||||
|
@ -807,7 +800,7 @@ wxString S3D_FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName )
|
||||||
|
|
||||||
idx = fname.find( fps );
|
idx = fname.find( fps );
|
||||||
|
|
||||||
if( std::string::npos != idx && 0 == idx )
|
if( idx == 0 )
|
||||||
{
|
{
|
||||||
fname = fname.substr( fps.size() );
|
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;
|
return &m_Paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool S3D_FILENAME_RESOLVER::SplitAlias( const wxString& aFileName,
|
bool FILENAME_RESOLVER::SplitAlias( const wxString& aFileName,
|
||||||
wxString& anAlias, wxString& aRelPath )
|
wxString& anAlias, wxString& aRelPath )
|
||||||
{
|
{
|
||||||
anAlias.clear();
|
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:
|
// Rules:
|
||||||
// 1. The generic form of an aliased 3D relative path is:
|
// 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();
|
paths.clear();
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#include <gestfich.h>
|
#include <gestfich.h>
|
||||||
#include <menus_helpers.h>
|
#include <menus_helpers.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <dialog_env_var_config.h>
|
#include <dialog_configure_paths.h>
|
||||||
#include <lockfile.h>
|
#include <lockfile.h>
|
||||||
#include <systemdirsappend.h>
|
#include <systemdirsappend.h>
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ bool PGM_BASE::InitPgm()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmpFileName.AppendDir( wxT( "packages3d" ) );
|
tmpFileName.AppendDir( wxT( "packages3d" ) );
|
||||||
envVarItem.SetDefinedExternally( false );
|
envVarItem.SetDefinedExternally( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
envVarItem.SetValue( tmpFileName.GetFullPath() );
|
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() );
|
DIALOG_CONFIGURE_PATHS dlg( aParent, aResolver );
|
||||||
|
|
||||||
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();
|
dlg.ShowModal();
|
||||||
m_show_env_var_dialog = !dlg.IsCheckBoxChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
SetLocalEnvVariables( dlg_envvars.GetEnvVarMap() );
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <netlist_reader.h>
|
#include <netlist_reader.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <widgets/progress_reporter.h>
|
#include <widgets/progress_reporter.h>
|
||||||
|
#include <3d_cache/3d_cache.h>
|
||||||
|
|
||||||
#include <cvpcb_mainframe.h>
|
#include <cvpcb_mainframe.h>
|
||||||
#include <cvpcb.h>
|
#include <cvpcb.h>
|
||||||
|
@ -974,7 +975,7 @@ void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
|
||||||
|
|
||||||
void CVPCB_MAINFRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
void CVPCB_MAINFRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
Pgm().ConfigurePaths( this );
|
Pgm().ConfigurePaths( this, Prj().Get3DCacheManager()->GetResolver() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ void SCH_BASE_FRAME::UpdateStatusBar()
|
||||||
|
|
||||||
void SCH_BASE_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
void SCH_BASE_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
Pgm().ConfigurePaths( this );
|
Pgm().ConfigurePaths( this, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
|
* 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 <wx/valtext.h>
|
||||||
|
#include <pgm_base.h>
|
||||||
|
|
||||||
|
|
||||||
|
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_
|
|
@ -1,102 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
|
|
||||||
* 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 <pgm_base.h>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file 3d_filename_resolver.h
|
* @file filename_resolver.h
|
||||||
* provides an extensible class to resolve 3D model paths. Initially
|
* provides an extensible class to resolve 3D model paths. Initially
|
||||||
* the legacy behavior will be implemented and an incomplete path
|
* the legacy behavior will be implemented and an incomplete path
|
||||||
* would be checked against the project directory or the KISYS3DMOD
|
* would be checked against the project directory or the KISYS3DMOD
|
||||||
|
@ -30,18 +30,17 @@
|
||||||
* paths may be specified.
|
* paths may be specified.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FILENAME_RESOLVER_3D_H
|
#ifndef FILENAME_RESOLVER_H
|
||||||
#define FILENAME_RESOLVER_3D_H
|
#define FILENAME_RESOLVER_H
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include "str_rsort.h"
|
|
||||||
|
|
||||||
class PGM_BASE;
|
class PGM_BASE;
|
||||||
|
|
||||||
struct S3D_ALIAS
|
struct SEARCH_PATH
|
||||||
{
|
{
|
||||||
wxString m_alias; // alias to the base path
|
wxString m_alias; // alias to the base path
|
||||||
wxString m_pathvar; // base path as stored in the config file
|
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
|
wxString m_description; // description of the aliased path
|
||||||
};
|
};
|
||||||
|
|
||||||
class S3D_FILENAME_RESOLVER
|
class FILENAME_RESOLVER
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
wxString m_ConfigDir; // 3D configuration directory
|
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;
|
int m_errflags;
|
||||||
PGM_BASE* m_pgm;
|
PGM_BASE* m_pgm;
|
||||||
wxString m_curProjDir;
|
wxString m_curProjDir;
|
||||||
|
@ -76,7 +75,7 @@ private:
|
||||||
* @param aPath is the alias set to be checked and added
|
* @param aPath is the alias set to be checked and added
|
||||||
* @return true if aPath is valid
|
* @return true if aPath is valid
|
||||||
*/
|
*/
|
||||||
bool addPath( const S3D_ALIAS& aPath );
|
bool addPath( const SEARCH_PATH& aPath );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function readPathList
|
* Function readPathList
|
||||||
|
@ -105,7 +104,7 @@ private:
|
||||||
void checkEnvVarPath( const wxString& aPath );
|
void checkEnvVarPath( const wxString& aPath );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
S3D_FILENAME_RESOLVER();
|
FILENAME_RESOLVER();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Set3DConfigDir
|
* Function Set3DConfigDir
|
||||||
|
@ -143,7 +142,7 @@ public:
|
||||||
* clears the current path list and substitutes the given path
|
* clears the current path list and substitutes the given path
|
||||||
* list, updating the path configuration file on success.
|
* list, updating the path configuration file on success.
|
||||||
*/
|
*/
|
||||||
bool UpdatePathList( std::vector< S3D_ALIAS >& aPathList );
|
bool UpdatePathList( std::vector< SEARCH_PATH >& aPathList );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ResolvePath
|
* Function ResolvePath
|
||||||
|
@ -175,7 +174,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return pointer to the internal path list
|
* @return pointer to the internal path list
|
||||||
*/
|
*/
|
||||||
const std::list< S3D_ALIAS >* GetPaths( void );
|
const std::list< SEARCH_PATH >* GetPaths( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SplitAlias
|
* Function SplitAlias
|
||||||
|
@ -201,4 +200,4 @@ public:
|
||||||
bool GetKicadPaths( std::list< wxString >& paths );
|
bool GetKicadPaths( std::list< wxString >& paths );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILENAME_RESOLVER_3D_H
|
#endif // FILENAME_RESOLVER_H
|
|
@ -189,4 +189,52 @@ bool ReplaceIllegalFileNameChars( wxString& aName, int aReplaceChar = 0 );
|
||||||
extern "C" char* strtok_r( char* str, const char* delim, char** nextp );
|
extern "C" char* strtok_r( char* str, const char* delim, char** nextp );
|
||||||
#endif
|
#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_
|
#endif // KICAD_STRING_H_
|
||||||
|
|
|
@ -43,6 +43,8 @@ class wxApp;
|
||||||
class wxMenu;
|
class wxMenu;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
|
|
||||||
|
class FILENAME_RESOLVER;
|
||||||
|
|
||||||
|
|
||||||
// inter program module calling
|
// inter program module calling
|
||||||
#define VTBL_ENTRY virtual
|
#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
|
* 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
|
* it will eventually find use for in schematic I/O design so it needs to accessible by
|
||||||
* almost every KiCad application.
|
* 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
|
* Function App
|
||||||
|
|
|
@ -588,5 +588,5 @@ void KICAD_MANAGER_FRAME::Process_Config( wxCommandEvent& event )
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
void KICAD_MANAGER_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
Pgm().ConfigurePaths( this );
|
Pgm().ConfigurePaths( this, nullptr );
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,13 +49,13 @@
|
||||||
#include <class_text_mod.h>
|
#include <class_text_mod.h>
|
||||||
#include <validators.h>
|
#include <validators.h>
|
||||||
#include <widgets/text_ctrl_eval.h>
|
#include <widgets/text_ctrl_eval.h>
|
||||||
|
#include <filename_resolver.h>
|
||||||
|
|
||||||
#include <dialog_edit_footprint_for_BoardEditor.h>
|
#include <dialog_edit_footprint_for_BoardEditor.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include "3d_cache/dialogs/panel_prev_model.h"
|
#include "3d_cache/dialogs/panel_prev_model.h"
|
||||||
#include "3d_cache/dialogs/3d_cache_dialogs.h"
|
#include "3d_cache/dialogs/3d_cache_dialogs.h"
|
||||||
#include "3d_cache/3d_cache.h"
|
#include "3d_cache/3d_cache.h"
|
||||||
#include "3d_cache/3d_filename_resolver.h"
|
|
||||||
|
|
||||||
#include <dialog_edit_footprint_text.h>
|
#include <dialog_edit_footprint_text.h>
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::InitModeditProperties()
|
||||||
wxString origPath;
|
wxString origPath;
|
||||||
wxString alias;
|
wxString alias;
|
||||||
wxString shortPath;
|
wxString shortPath;
|
||||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||||
|
|
||||||
while( sM != eM )
|
while( sM != eM )
|
||||||
{
|
{
|
||||||
|
@ -498,7 +498,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::Edit3DShapeFileName()
|
||||||
WX_TEXT_ENTRY_DIALOG dlg( this, wxEmptyString, wxEmptyString, filename );
|
WX_TEXT_ENTRY_DIALOG dlg( this, wxEmptyString, wxEmptyString, filename );
|
||||||
|
|
||||||
bool hasAlias;
|
bool hasAlias;
|
||||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return;
|
return;
|
||||||
|
@ -573,7 +573,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::BrowseAndAdd3DShapeFile()
|
||||||
prj.SetRString( PROJECT::VIEWER_3D_PATH, initialpath );
|
prj.SetRString( PROJECT::VIEWER_3D_PATH, initialpath );
|
||||||
sidx = wxString::Format( wxT( "%i" ), filter );
|
sidx = wxString::Format( wxT( "%i" ), filter );
|
||||||
prj.SetRString( PROJECT::VIEWER_3D_FILTER_INDEX, sidx );
|
prj.SetRString( PROJECT::VIEWER_3D_FILTER_INDEX, sidx );
|
||||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||||
wxString alias;
|
wxString alias;
|
||||||
wxString shortPath;
|
wxString shortPath;
|
||||||
wxString filename = model.m_Filename;
|
wxString filename = model.m_Filename;
|
||||||
|
|
|
@ -53,11 +53,11 @@
|
||||||
#include <footprint_edit_frame.h>
|
#include <footprint_edit_frame.h>
|
||||||
#include <dialog_edit_footprint_for_fp_editor.h>
|
#include <dialog_edit_footprint_for_fp_editor.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
|
#include "filename_resolver.h"
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include "3d_cache/dialogs/panel_prev_model.h"
|
#include "3d_cache/dialogs/panel_prev_model.h"
|
||||||
#include "3d_cache/dialogs/3d_cache_dialogs.h"
|
#include "3d_cache/dialogs/3d_cache_dialogs.h"
|
||||||
#include "3d_cache/3d_cache.h"
|
#include "3d_cache/3d_cache.h"
|
||||||
#include "3d_cache/3d_filename_resolver.h"
|
|
||||||
|
|
||||||
#include <dialog_edit_footprint_text.h>
|
#include <dialog_edit_footprint_text.h>
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::initModeditProperties()
|
||||||
wxString origPath;
|
wxString origPath;
|
||||||
wxString alias;
|
wxString alias;
|
||||||
wxString shortPath;
|
wxString shortPath;
|
||||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||||
|
|
||||||
while( sM != eM )
|
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 );
|
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filepath:" ), _( "Edit 3D Shape Name" ), filename );
|
||||||
|
|
||||||
bool hasAlias;
|
bool hasAlias;
|
||||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return;
|
return;
|
||||||
|
@ -449,7 +449,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::BrowseAndAdd3DShapeFile()
|
||||||
wxString origPath = model.m_Filename;
|
wxString origPath = model.m_Filename;
|
||||||
wxString alias;
|
wxString alias;
|
||||||
wxString shortPath;
|
wxString shortPath;
|
||||||
S3D_FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
FILENAME_RESOLVER* res = Prj().Get3DCacheManager()->GetResolver();
|
||||||
|
|
||||||
if( res && res->SplitAlias( origPath, alias, shortPath ) )
|
if( res && res->SplitAlias( origPath, alias, shortPath ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "kiway.h"
|
#include "kiway.h"
|
||||||
#include "3d_cache/3d_cache.h"
|
#include "3d_cache/3d_cache.h"
|
||||||
#include "3d_cache/3d_filename_resolver.h"
|
#include "filename_resolver.h"
|
||||||
|
|
||||||
#ifndef PCBNEW
|
#ifndef PCBNEW
|
||||||
#define PCBNEW // needed to define the right value of Millimeter2iu(x)
|
#define PCBNEW // needed to define the right value of Millimeter2iu(x)
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
// assumed default graphical line thickness: == 0.1mm
|
// assumed default graphical line thickness: == 0.1mm
|
||||||
#define LINE_WIDTH (Millimeter2iu( 0.1 ))
|
#define LINE_WIDTH (Millimeter2iu( 0.1 ))
|
||||||
|
|
||||||
static S3D_FILENAME_RESOLVER* resolver;
|
static FILENAME_RESOLVER* resolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function idf_export_outline
|
* Function idf_export_outline
|
||||||
|
|
|
@ -907,7 +907,7 @@ void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event )
|
||||||
|
|
||||||
void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
Pgm().ConfigurePaths( this );
|
Pgm().ConfigurePaths( this, Prj().Get3DCacheManager()->GetResolver() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1216,7 +1216,7 @@ bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName )
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
void PCB_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
Pgm().ConfigurePaths( this );
|
Pgm().ConfigurePaths( this, Prj().Get3DCacheManager()->GetResolver() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool S3D_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgChanged )
|
||||||
|
|
||||||
if( m_Paths.empty() )
|
if( m_Paths.empty() )
|
||||||
{
|
{
|
||||||
S3D_ALIAS al;
|
SEARCH_PATH al;
|
||||||
al.m_alias = "${KIPRJMOD}";
|
al.m_alias = "${KIPRJMOD}";
|
||||||
al.m_pathvar = "${KIPRJMOD}";
|
al.m_pathvar = "${KIPRJMOD}";
|
||||||
al.m_pathexp = m_curProjDir;
|
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.
|
// we cannot set a sensible default so we use an empty string.
|
||||||
// the user may change this later with a call to SetProjectDir()
|
// the user may change this later with a call to SetProjectDir()
|
||||||
|
|
||||||
S3D_ALIAS lpath;
|
SEARCH_PATH lpath;
|
||||||
lpath.m_alias = "${KIPRJMOD}";
|
lpath.m_alias = "${KIPRJMOD}";
|
||||||
lpath.m_pathvar = "${KIPRJMOD}";
|
lpath.m_pathvar = "${KIPRJMOD}";
|
||||||
lpath.m_pathexp = m_curProjDir;
|
lpath.m_pathexp = m_curProjDir;
|
||||||
|
@ -294,8 +294,8 @@ bool S3D_RESOLVER::createPathList( void )
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
wxLogTrace( MASK_3D_RESOLVER, " * [3D model] search paths:\n" );
|
wxLogTrace( MASK_3D_RESOLVER, " * [3D model] search paths:\n" );
|
||||||
std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
while( sPL != ePL )
|
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( '$' );
|
wxUniChar envMarker( '$' );
|
||||||
|
|
||||||
|
@ -408,8 +408,8 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
|
||||||
// a. an aliased shortened name or
|
// a. an aliased shortened name or
|
||||||
// b. cannot be determined
|
// b. cannot be determined
|
||||||
|
|
||||||
std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
// check the path relative to the current project directory;
|
// check the path relative to the current project directory;
|
||||||
// note: this is not necessarily the same as the current working
|
// 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() )
|
if( aPath.m_alias.empty() || aPath.m_pathvar.empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxCriticalSectionLocker lock( lock3D_resolver );
|
wxCriticalSectionLocker lock( lock3D_resolver );
|
||||||
|
|
||||||
S3D_ALIAS tpath = aPath;
|
SEARCH_PATH tpath = aPath;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
while( tpath.m_pathvar.EndsWith( "\\" ) )
|
while( tpath.m_pathvar.EndsWith( "\\" ) )
|
||||||
|
@ -566,8 +566,8 @@ bool S3D_RESOLVER::addPath( const S3D_ALIAS& aPath )
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString pname = path.GetPath();
|
wxString pname = path.GetPath();
|
||||||
std::list< S3D_ALIAS >::iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
while( sPL != ePL )
|
while( sPL != ePL )
|
||||||
{
|
{
|
||||||
|
@ -639,7 +639,7 @@ bool S3D_RESOLVER::readPathList( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
int lineno = 0;
|
int lineno = 0;
|
||||||
S3D_ALIAS al;
|
SEARCH_PATH al;
|
||||||
size_t idx;
|
size_t idx;
|
||||||
int vnum = 0; // version number
|
int vnum = 0; // version number
|
||||||
|
|
||||||
|
@ -715,8 +715,8 @@ bool S3D_RESOLVER::writePathList( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip all ${ENV_VAR} alias names
|
// skip all ${ENV_VAR} alias names
|
||||||
std::list< S3D_ALIAS >::const_iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::const_iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::const_iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
while( sPL != ePL && ( sPL->m_alias.StartsWith( "${" )
|
while( sPL != ePL && ( sPL->m_alias.StartsWith( "${" )
|
||||||
|| 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
|
// check if the alias exists; if not then add it to the end of the
|
||||||
// env var section of the path list
|
// env var section of the path list
|
||||||
std::list< S3D_ALIAS >::iterator sPL = m_Paths.begin();
|
std::list< SEARCH_PATH >::iterator sPL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::iterator ePL = m_Paths.end();
|
std::list< SEARCH_PATH >::iterator ePL = m_Paths.end();
|
||||||
|
|
||||||
while( sPL != ePL )
|
while( sPL != ePL )
|
||||||
{
|
{
|
||||||
|
@ -832,7 +832,7 @@ void S3D_RESOLVER::checkEnvVarPath( const wxString& aPath )
|
||||||
++sPL;
|
++sPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
S3D_ALIAS lpath;
|
SEARCH_PATH lpath;
|
||||||
lpath.m_alias = envar;
|
lpath.m_alias = envar;
|
||||||
lpath.m_pathvar = lpath.m_alias;
|
lpath.m_pathvar = lpath.m_alias;
|
||||||
wxFileName tmpFN( lpath.m_alias, "" );
|
wxFileName tmpFN( lpath.m_alias, "" );
|
||||||
|
@ -896,8 +896,8 @@ wxString S3D_RESOLVER::ShortenPath( const wxString& aFullPathName )
|
||||||
createPathList();
|
createPathList();
|
||||||
|
|
||||||
wxCriticalSectionLocker lock( lock3D_resolver );
|
wxCriticalSectionLocker lock( lock3D_resolver );
|
||||||
std::list< S3D_ALIAS >::const_iterator sL = m_Paths.begin();
|
std::list< SEARCH_PATH >::const_iterator sL = m_Paths.begin();
|
||||||
std::list< S3D_ALIAS >::const_iterator eL = m_Paths.end();
|
std::list< SEARCH_PATH >::const_iterator eL = m_Paths.end();
|
||||||
size_t idx;
|
size_t idx;
|
||||||
|
|
||||||
while( sL != eL )
|
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;
|
return &m_Paths;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace S3D
|
||||||
|
|
||||||
class KICADPCB;
|
class KICADPCB;
|
||||||
|
|
||||||
struct S3D_ALIAS
|
struct SEARCH_PATH
|
||||||
{
|
{
|
||||||
wxString m_alias; // alias to the base path
|
wxString m_alias; // alias to the base path
|
||||||
wxString m_pathvar; // base path as stored in the config file
|
wxString m_pathvar; // base path as stored in the config file
|
||||||
|
@ -103,7 +103,7 @@ class S3D_RESOLVER
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
wxString m_ConfigDir; // 3D configuration directory
|
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
|
// mapping of (short) file names to resolved names
|
||||||
std::map< wxString, wxString, S3D::rsort_wxString > m_NameMap;
|
std::map< wxString, wxString, S3D::rsort_wxString > m_NameMap;
|
||||||
int m_errflags;
|
int m_errflags;
|
||||||
|
@ -129,7 +129,7 @@ private:
|
||||||
* @param aPath is the alias set to be checked and added
|
* @param aPath is the alias set to be checked and added
|
||||||
* @return true if aPath is valid
|
* @return true if aPath is valid
|
||||||
*/
|
*/
|
||||||
bool addPath( const S3D_ALIAS& aPath );
|
bool addPath( const SEARCH_PATH& aPath );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function readPathList
|
* Function readPathList
|
||||||
|
@ -189,7 +189,7 @@ public:
|
||||||
* clears the current path list and substitutes the given path
|
* clears the current path list and substitutes the given path
|
||||||
* list, updating the path configuration file on success.
|
* list, updating the path configuration file on success.
|
||||||
*/
|
*/
|
||||||
bool UpdatePathList( std::vector< S3D_ALIAS >& aPathList );
|
bool UpdatePathList( std::vector< SEARCH_PATH >& aPathList );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ResolvePath
|
* Function ResolvePath
|
||||||
|
@ -221,7 +221,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return pointer to the internal path list
|
* @return pointer to the internal path list
|
||||||
*/
|
*/
|
||||||
const std::list< S3D_ALIAS >* GetPaths( void );
|
const std::list< SEARCH_PATH >* GetPaths( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SplitAlias
|
* Function SplitAlias
|
||||||
|
|
Loading…
Reference in New Issue