Commit 97232952 authored by jean-pierre charras's avatar jean-pierre charras

Cvpcb: fix issues relatives to .equ files management:

* Add dialog to edit the list of active equ files.
* allows use of our environment variables in .equ file names.
parent 0cb7c3dc
......@@ -490,6 +490,7 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
id_lib << indexlib;
indexlib++;
libname = aConfig->Read( id_lib, wxT( "" ) );
if( libname.IsEmpty() )
break;
// file names are stored using Unix notation
......
......@@ -331,8 +331,14 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aGroupNam
m_pro_date_and_time = timestamp;
// We do not want expansion of env var values when reading our project config file
bool state = cfg.get()->IsExpandingEnvVars();
cfg.get()->SetExpandEnvVars( false );
wxConfigLoadParams( cfg.get(), aParams, aGroupName );
cfg.get()->SetExpandEnvVars( state );
return true;
}
......
......@@ -31,6 +31,8 @@ set( CVPCB_DIALOGS
dialogs/fp_conflict_assignment_selector.cpp
dialogs/dialog_display_options.cpp
dialogs/dialog_display_options_base.cpp
dialogs/dialog_config_equfiles_base.cpp
dialogs/dialog_config_equfiles.cpp
../pcbnew/dialogs/dialog_fp_lib_table.cpp
../pcbnew/dialogs/dialog_fp_lib_table_base.cpp
../pcbnew/dialogs/dialog_fp_plugin_options.cpp
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-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
......@@ -31,7 +31,6 @@
#include <common.h>
#include <kiface_i.h>
#include <project.h>
#include <confirm.h>
#include <gestfich.h>
#include <pgm_base.h>
#include <kicad_string.h>
......@@ -99,25 +98,18 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
return;
// Find equivalents in all available files.
for( ii = 0; ii < m_AliasLibNames.GetCount(); ii++ )
for( ii = 0; ii < m_EquFilesNames.GetCount(); ii++ )
{
fn = m_AliasLibNames[ii];
if( !fn.HasExt() )
{
fn.SetExt( FootprintAliasFileExtension );
// above fails if filename has more than one point
}
if( m_EquFilesNames[ii].StartsWith( wxT("${") ) )
fn = wxExpandEnvVars( m_EquFilesNames[ii] );
else
{
fn.SetExt( fn.GetExt() + wxT( "." ) + FootprintAliasFileExtension );
}
fn = m_EquFilesNames[ii];
tmp = search.FindValidPath( fn.GetFullPath() );
if( !tmp )
{
msg.Printf( _( "Footprint alias library file '%s' could not be found in the "
msg.Printf( _( "Footprint equ file '%s' could not be found in the "
"default search paths." ),
GetChars( fn.GetFullName() ) );
wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR );
......@@ -128,7 +120,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
if( file == NULL )
{
msg.Printf( _( "Error opening alias library '%s'." ), GetChars( tmp ) );
msg.Printf( _( "Error opening equ file '%s'." ), GetChars( tmp ) );
wxMessageBox( msg, FMT_TITLE_LIB_LOAD_ERROR, wxOK | wxICON_ERROR );
continue;
}
......@@ -160,7 +152,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
}
// Display the number of footprint aliases.
msg.Printf( _( "%d footprint aliases found." ), aliases.size() );
msg.Printf( _( "%d footprint/cmp equivalences found." ), aliases.size() );
SetStatusText( msg, 0 );
m_skipComponentSelect = true;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jean-pierre.charras
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -50,7 +50,7 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUP_PCB_LIBS, PARAM_COMMAND_ERASE ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST(
wxT( "EquName" ), &m_AliasLibNames, GROUP_CVP_EQU ) );
wxT( "EquName" ), &m_EquFilesNames, GROUP_CVP_EQU ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING(
wxT( "NetIExt" ), &m_NetlistFileExtension ) );
......@@ -64,9 +64,8 @@ void CVPCB_MAINFRAME::LoadProjectFile()
PROJECT& prj = Prj();
m_ModuleLibNames.Clear();
m_AliasLibNames.Clear();
m_EquFilesNames.Clear();
// was: Pgm().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
prj.ConfigLoad( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters() );
if( m_NetlistFileExtension.IsEmpty() )
......@@ -77,26 +76,14 @@ void CVPCB_MAINFRAME::LoadProjectFile()
void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
{
PROJECT& prj = Prj();
wxFileName fn = prj.AbsolutePath( m_NetlistFileName.GetFullPath() );
fn.SetExt( ProjectFileExtension );
if( aEvent.GetId() == ID_SAVE_PROJECT_AS || !m_NetlistFileName.IsOk() )
{
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
wxEmptyString, ProjectFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
fn = dlg.GetPath();
if( !fn.HasExt() )
fn.SetExt( ProjectFileExtension );
}
SetTitle( wxString::Format( _( "Project file: '%s'" ), GetChars( prj.GetProjectFullName() ) ) );
wxFileName fn = prj.GetProjectFullName();
if( !IsWritable( fn ) )
{
wxMessageBox( _( "Project file '%s' is not writable" ), fn.GetFullPath() );
return;
}
wxString pro_name = fn.GetFullPath();
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
......@@ -69,8 +69,8 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout )
EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::SaveProjectFile )
EVT_MENU( ID_SAVE_PROJECT_AS, CVPCB_MAINFRAME::SaveProjectFile )
EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave )
EVT_MENU( ID_CVPCB_EQUFILES_LIST_EDIT, CVPCB_MAINFRAME::OnEditEquFilesList )
// Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
......@@ -160,6 +160,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_auimgr.SetManagedWindow( this );
UpdateTitle();
EDA_PANEINFO horiz;
horiz.HorizontalToolbarPane();
......@@ -369,10 +370,12 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& aEvent )
{
if( aEvent.GetId() == wxID_SAVEAS )
m_NetlistFileName.Clear();
wxString fullFilename;
if( aEvent.GetId() != wxID_SAVEAS )
fullFilename = m_NetlistFileName.GetFullPath();
if( SaveCmpLinkFile( m_NetlistFileName.GetFullPath() ) > 0 )
if( SaveCmpLinkFile( fullFilename ) > 0 )
{
m_modified = false;
......@@ -744,18 +747,21 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
void CVPCB_MAINFRAME::UpdateTitle()
{
wxString title = wxString::Format( wxT( "Cvpcb %s " ), GetChars( GetBuildVersion() ) );
PROJECT& prj = Prj();
wxFileName fn = prj.GetProjectFullName();
if( m_NetlistFileName.IsOk() && m_NetlistFileName.FileExists() )
if( fn.IsOk() && fn.FileExists() )
{
title += m_NetlistFileName.GetFullPath();
title += wxString::Format( _("Project: '%s' (netlist: '%s')"),
GetChars( fn.GetFullPath() ),
GetChars( m_NetlistFileName.GetFullName() )
);
if( !m_NetlistFileName.IsFileWritable() )
if( !fn.IsFileWritable() )
title += _( " [Read Only]" );
}
else
{
title += _( "[no file]" );
}
title += _( "[no project]" );
SetTitle( title );
}
......
......@@ -51,10 +51,10 @@
COLORS_DESIGN_SETTINGS g_ColorsSettings;
// Constant string definitions for CvPcb
const wxString FootprintAliasFileExtension( wxT( "equ" ) );
const wxString EquFileExtension( wxT( "equ" ) );
// Wildcard for schematic retroannotation (import footprint names in schematic):
const wxString FootprintAliasFileWildcard( _( "KiCad footprint alias files (*.equ)|*.equ" ) );
const wxString EquFilesWildcard( _( "Component/footprint equ files (*.equ)|*.equ" ) );
#if 0 // add this logic to OpenProjectFiles()
......
......@@ -36,8 +36,8 @@
#define LISTB_STYLE ( wxSUNKEN_BORDER | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL | \
wxLC_SINGLE_SEL | wxVSCROLL | wxHSCROLL )
extern const wxString FootprintAliasFileExtension;
extern const wxString FootprintAliasFileWildcard;
extern const wxString EquFileExtension;
extern const wxString EquFilesWildcard;
#endif /* __CVPCB_H__ */
......@@ -56,5 +56,6 @@ enum id_cvpcb_frm
ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST,
ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
ID_CVPCB_LIBRARY_LIST,
ID_CVPCB_EQUFILES_LIST_EDIT,
ID_CVPCB_LIB_TABLE_EDIT
};
......@@ -66,7 +66,7 @@ public:
wxAuiToolBar* m_mainToolBar;
wxFileName m_NetlistFileName;
wxArrayString m_ModuleLibNames;
wxArrayString m_AliasLibNames;
wxArrayString m_EquFilesNames;
wxString m_NetlistFileExtension;
wxString m_DocModulesFileName;
FOOTPRINT_LIST m_footprints;
......@@ -137,10 +137,16 @@ public:
/**
* Function OnEditLibraryTable
* envokes the footpirnt library table edit dialog.
* envokes the footprint library table edit dialog.
*/
void OnEditFootprintLibraryTable( wxCommandEvent& aEvent );
/**
* Function OnEditEquFilesList
* envokes the equ files list edit dialog.
*/
void OnEditEquFilesList( wxCommandEvent& aEvent );
void OnKeepOpenOnSave( wxCommandEvent& event );
void DisplayModule( wxCommandEvent& event );
......
/**
* @file dialog_config_equfiles.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-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
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <common.h>
#include <confirm.h>
#include <gestfich.h>
#include <id.h>
#include <project.h> // For PROJECT_VAR_NAME definition
#include <fp_lib_table.h> // For KISYSMOD definition
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <dialog_config_equfiles.h>
#include <wildcards_and_files_ext.h>
DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* aParent ) :
DIALOG_CONFIG_EQUFILES_BASE( aParent )
{
m_Parent = aParent;
m_Config = Pgm().CommonSettings();
PROJECT& prj = Prj();
SetTitle( wxString::Format( _( "Project file: '%s'" ), GetChars( prj.GetProjectFullName() ) ) );
Init( );
GetSizer()->SetSizeHints( this );
Center();
}
void CVPCB_MAINFRAME::OnEditEquFilesList( wxCommandEvent& aEvent )
{
DIALOG_CONFIG_EQUFILES dlg( this );
dlg.ShowModal();
}
void DIALOG_CONFIG_EQUFILES::Init()
{
m_sdbSizerOK->SetDefault();
m_ListChanged = false;
m_ListEquiv->InsertItems( m_Parent->m_EquFilesNames, 0 );
if( getEnvVarCount() < 2 )
m_gridEnvVars->AppendRows(2 - getEnvVarCount() );
wxString evValue;
int row = 0;
m_gridEnvVars->SetCellValue( row++, 0, PROJECT_VAR_NAME );
m_gridEnvVars->SetCellValue( row, 0, FP_LIB_TABLE::GlobalPathEnvVariableName() );
for( row = 0; row < getEnvVarCount(); row++ )
{
if( wxGetEnv( m_gridEnvVars->GetCellValue( row, 0 ), &evValue ) )
m_gridEnvVars->SetCellValue( row, 1, evValue );
}
m_gridEnvVars->AutoSizeColumns();
}
void DIALOG_CONFIG_EQUFILES::OnCancelClick( wxCommandEvent& event )
{
EndModal( wxID_CANCEL );
}
void DIALOG_CONFIG_EQUFILES::OnOkClick( wxCommandEvent& event )
{
// Save new equ file list if the files list was modified
if( m_ListChanged )
{
// Recreate equ list
m_Parent->m_EquFilesNames.Clear();
for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ )
m_Parent->m_EquFilesNames.Add( m_ListEquiv->GetString( ii ) );
wxCommandEvent evt( ID_SAVE_PROJECT );
m_Parent->SaveProjectFile( evt );
}
EndModal( wxID_OK );
}
void DIALOG_CONFIG_EQUFILES::OnCloseWindow( wxCloseEvent& event )
{
EndModal( wxID_CANCEL );
}
/********************************************************************/
void DIALOG_CONFIG_EQUFILES::OnButtonMoveUp( wxCommandEvent& event )
/********************************************************************/
{
wxListBox * list = m_ListEquiv;
wxArrayInt selections;
list->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection.
return;
if( selections[0] == 0 ) // The first lib is selected. cannot move up it
return;
wxArrayString libnames = list->GetStrings();
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1] );
}
list->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
list->SetSelection( jj-1 );
}
m_ListChanged = true;
}
/*********************************************************************/
void DIALOG_CONFIG_EQUFILES::OnButtonMoveDown( wxCommandEvent& event )
/*********************************************************************/
{
wxArrayInt selections;
m_ListEquiv->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection.
return;
// The last lib is selected. cannot move down it
if( selections.Last() == int( m_ListEquiv->GetCount()-1 ) )
return;
wxArrayString libnames = m_ListEquiv->GetStrings();
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj+1]);
}
m_ListEquiv->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
m_ListEquiv->SetSelection(jj+1);
}
m_ListChanged = true;
}
/* Remove a library to the library list.
* The real list (g_LibName_List) is not changed, so the change can be canceled
*/
void DIALOG_CONFIG_EQUFILES::OnRemoveFiles( wxCommandEvent& event )
{
wxArrayInt selections;
m_ListEquiv->GetSelections( selections );
std::sort( selections.begin(), selections.end() );
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
m_ListEquiv->Delete(selections[ii] );
m_ListChanged = true;
}
}
/* Insert or add a library to the library list:
* The new library is put in list before (insert button) the selection,
* or added (add button) to end of list
*/
void DIALOG_CONFIG_EQUFILES::OnAddFiles( wxCommandEvent& event )
{
wxString equFilename, wildcard;
wxFileName fn;
wildcard = EquFilesWildcard;
wxListBox* list = m_ListEquiv;
// Get a default path to open the file dialog:
wxString libpath;
wxArrayInt selectedRows = m_gridEnvVars->GetSelectedRows();
int row = selectedRows.GetCount() ? selectedRows[0] :
m_gridEnvVars->GetGridCursorRow();
libpath = m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );
wxFileDialog FilesDialog( this, _( "Equ files:" ), libpath,
wxEmptyString, wildcard,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
if( FilesDialog.ShowModal() != wxID_OK )
return;
wxArrayString Filenames;
FilesDialog.GetPaths( Filenames );
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{
fn = Filenames[jj];
equFilename.Empty();
if( isPathRelativeAllowed() ) // try to use relative path
{
for( row = 0; row < getEnvVarCount(); row++ )
{
libpath = m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );
if( fn.MakeRelativeTo( libpath ) )
{
equFilename.Printf( wxT("${%s}%c%s"),
GetChars( m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 0 ) ) ),
fn.GetPathSeparator(),
GetChars( fn.GetFullPath() ) );
break;
}
}
}
if( equFilename.IsEmpty() )
equFilename = Filenames[jj];
// Add or insert new library name, if not already in list
if( list->FindString( equFilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
{
m_ListChanged = true;
equFilename.Replace( wxT("\\"), wxT("/") ); // Use unix separators only.
list->Append( equFilename );
}
else
{
wxString msg;
msg.Printf( _( "File '%s'already in list" ), equFilename.GetData() );
DisplayError( this, msg );
}
}
}
/**
* @file dialog_config_equfiles.h
*/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2010-2015 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2015 Kicad Developers, see CHANGELOG.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_CONFIG_EQUFILES_H_
#define _DIALOG_CONFIG_EQUFILES_H_
#include <dialog_config_equfiles_base.h>
class DIALOG_CONFIG_EQUFILES : public DIALOG_CONFIG_EQUFILES_BASE
{
private:
CVPCB_MAINFRAME* m_Parent;
wxConfigBase* m_Config;
wxString m_UserLibDirBufferImg;
bool m_ListChanged;
private:
void Init();
// Virtual event handlers
void OnCloseWindow( wxCloseEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnAddFiles( wxCommandEvent& event );
void OnRemoveFiles( wxCommandEvent& event );
void OnButtonMoveUp( wxCommandEvent& event );
void OnButtonMoveDown( wxCommandEvent& event );
int getEnvVarCount() // Get the number of rows in env var table
{
return m_gridEnvVars->GetTable()->GetRowsCount();
}
bool isPathRelativeAllowed()
{
return m_rbPathOptionChoice->GetSelection() == 1;
}
public:
DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* parent );
~DIALOG_CONFIG_EQUFILES() {};
};
#endif // _DIALOG_CONFIG_EQUFILES_H_
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_config_equfiles_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_CONFIG_EQUFILES_BASE::DIALOG_CONFIG_EQUFILES_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* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbEquivChoiceSizer;
sbEquivChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint alias files (.equ files)") ), wxHORIZONTAL );
wxBoxSizer* bSizerFlist;
bSizerFlist = new wxBoxSizer( wxVERTICAL );
m_ListEquiv = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListEquiv->SetMinSize( wxSize( 350,-1 ) );
bSizerFlist->Add( m_ListEquiv, 1, wxRIGHT|wxLEFT|wxEXPAND, 5 );
sbEquivChoiceSizer->Add( bSizerFlist, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxVERTICAL );
m_buttonAddEqu = new wxButton( this, ID_ADD_EQU, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonAddEqu, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_buttonRemoveEqu = new wxButton( this, ID_REMOVE_EQU, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemoveEqu->SetToolTip( _("Unload the selected library") );
bSizerButtons->Add( m_buttonRemoveEqu, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_buttonMoveUp = new wxButton( this, ID_EQU_UP, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonMoveUp, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_buttonMoveDown = new wxButton( this, ID_EQU_DOWN, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonMoveDown, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbEquivChoiceSizer->Add( bSizerButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( sbEquivChoiceSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerLower;
bSizerLower = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerEnvVar;
bSizerEnvVar = new wxBoxSizer( wxVERTICAL );
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Available environment variables for relative paths:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
bSizerEnvVar->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_gridEnvVars = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_gridEnvVars->CreateGrid( 2, 2 );
m_gridEnvVars->EnableEditing( true );
m_gridEnvVars->EnableGridLines( true );
m_gridEnvVars->EnableDragGridSize( false );
m_gridEnvVars->SetMargins( 0, 0 );
// Columns
m_gridEnvVars->EnableDragColMove( false );
m_gridEnvVars->EnableDragColSize( true );
m_gridEnvVars->SetColLabelSize( 30 );
m_gridEnvVars->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_gridEnvVars->AutoSizeRows();
m_gridEnvVars->EnableDragRowSize( true );
m_gridEnvVars->SetRowLabelSize( 30 );
m_gridEnvVars->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_gridEnvVars->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
bSizerEnvVar->Add( m_gridEnvVars, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerLower->Add( bSizerEnvVar, 1, wxEXPAND, 5 );
wxString m_rbPathOptionChoiceChoices[] = { _("Absolute path"), _("Relative path") };
int m_rbPathOptionChoiceNChoices = sizeof( m_rbPathOptionChoiceChoices ) / sizeof( wxString );
m_rbPathOptionChoice = new wxRadioBox( this, wxID_ANY, _("Path option:"), wxDefaultPosition, wxDefaultSize, m_rbPathOptionChoiceNChoices, m_rbPathOptionChoiceChoices, 1, wxRA_SPECIFY_COLS );
m_rbPathOptionChoice->SetSelection( 1 );
bSizerLower->Add( m_rbPathOptionChoice, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( bSizerLower, 0, wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline2, 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_sdbSizer->Realize();
bMainSizer->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCloseWindow ) );
m_buttonAddEqu->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnAddFiles ), NULL, this );
m_buttonRemoveEqu->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnRemoveFiles ), NULL, this );
m_buttonMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveUp ), NULL, this );
m_buttonMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveDown ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnOkClick ), NULL, this );
}
DIALOG_CONFIG_EQUFILES_BASE::~DIALOG_CONFIG_EQUFILES_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCloseWindow ) );
m_buttonAddEqu->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnAddFiles ), NULL, this );
m_buttonRemoveEqu->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnRemoveFiles ), NULL, this );
m_buttonMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveUp ), NULL, this );
m_buttonMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnButtonMoveDown ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIG_EQUFILES_BASE::OnOkClick ), NULL, this );
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_CONFIG_EQUFILES_BASE_H__
#define __DIALOG_CONFIG_EQUFILES_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/listbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/grid.h>
#include <wx/radiobox.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_CONFIG_EQUFILES_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_CONFIG_EQUFILES_BASE : public DIALOG_SHIM
{
private:
protected:
enum
{
ID_ADD_EQU = 1000,
ID_REMOVE_EQU,
ID_EQU_UP,
ID_EQU_DOWN
};
wxListBox* m_ListEquiv;
wxButton* m_buttonAddEqu;
wxButton* m_buttonRemoveEqu;
wxButton* m_buttonMoveUp;
wxButton* m_buttonMoveDown;
wxStaticText* m_staticText2;
wxGrid* m_gridEnvVars;
wxRadioBox* m_rbPathOptionChoice;
wxStaticLine* m_staticline2;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnAddFiles( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveFiles( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonMoveUp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonMoveDown( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_CONFIG_EQUFILES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 454,284 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_CONFIG_EQUFILES_BASE();
};
#endif //__DIALOG_CONFIG_EQUFILES_BASE_H__
This diff is collapsed.
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_display_options.h
// Author: jean-pierre Charras
// Licence: GPL
/////////////////////////////////////////////////////////////////////////////
#ifndef _DIALOG_CVPCB_CONFIG_H_
#define _DIALOG_CVPCB_CONFIG_H_
#include <dialog_cvpcb_config_fbp.h>
class DIALOG_CVPCB_CONFIG : public DIALOG_CVPCB_CONFIG_FBP
{
private:
CVPCB_MAINFRAME* m_Parent;
wxConfigBase* m_Config;
wxString m_UserLibDirBufferImg;
bool m_LibListChanged;
bool m_LibPathChanged;
private:
void Init();
// Virtual event handlers
void OnCloseWindow( wxCloseEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnAddOrInsertLibClick( wxCommandEvent& event );
void OnRemoveLibClick( wxCommandEvent& event );
void OnBrowseModDocFile( wxCommandEvent& event );
void OnAddOrInsertPath( wxCommandEvent& event );
void OnRemoveUserPath( wxCommandEvent& event );
void OnButtonUpClick( wxCommandEvent& event );
void OnButtonDownClick( wxCommandEvent& event );
public:
DIALOG_CVPCB_CONFIG( CVPCB_MAINFRAME* parent );
~DIALOG_CVPCB_CONFIG() {};
};
#endif
// _DIALOG_CVPCB_CONFIG_H_
This diff is collapsed.
......@@ -95,11 +95,11 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Save the .cmp file
AddMenuItem( filesMenu, wxID_SAVE,
_( "&Save\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) );
_( "&Save Cmp File\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) );
// Save as the .cmp file
AddMenuItem( filesMenu, wxID_SAVEAS,
_( "Save &As...\tCtrl+Shift+S" ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) );
_( "Save Cmp File &As...\tCtrl+Shift+S" ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) );
// Separator
filesMenu->AppendSeparator();
......@@ -116,6 +116,12 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
_( "Edit Li&brary Table" ), _( "Setup footprint libraries" ),
KiBitmap( library_table_xpm ) );
AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT,
_( "Edit &Equ Files List" ),
_( "Setup equ files list (.equ files)\n"
"They are files which give the footprint name from the component value"),
KiBitmap( library_table_xpm ) );
// Language submenu
Pgm().AddMenuLanguageList( preferencesMenu );
......@@ -134,11 +140,6 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
_( "Save changes to the project configuration file" ),
KiBitmap( save_setup_xpm ) );
AddMenuItem( preferencesMenu, ID_SAVE_PROJECT_AS,
_( "&Save Project File As" ),
_( "Save changes to a new project configuration file" ),
KiBitmap( save_setup_xpm ) );
// Menu Help:
wxMenu* helpMenu = new wxMenu;
......
......@@ -5,7 +5,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
......@@ -385,8 +385,9 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
}
else
{
wxFileDialog dlg( this, _( "Save Component Footprint Link File" ), wxEmptyString,
_( "Unnamed file" ), ComponentFileWildcard, wxFD_SAVE );
wxFileDialog dlg( this, _( "Save Component Footprint Link File" ),
Prj().GetProjectPath(),
wxT( "noname" ), ComponentFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return -1;
......@@ -395,47 +396,13 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
if( !fn.HasExt() )
fn.SetExt( ComponentFileExtension );
#if 0 // RHH 6-Jul-14: We did not auto generate the
// footprint table. And the dialog which does suppport editing does the saving.
// Besides, this is not the place to do this, it belies the name of this
// function.
// Save the project specific footprint library table.
if( !Prj().PcbFootprintLibs()->IsEmpty( false ) )
{
wxString fp_lib_tbl = Prj().FootprintLibTblName();
if( wxFileName::FileExists( fp_lib_tbl )
&& IsOK( this, _( "A footprint library table already exists in this path.\n\nDo "
"you want to overwrite it?" ) ) )
{
try
{
Prj().PcbFootprintLibs()->Save( fp_lib_tbl );
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _(
"An error occurred attempting to save the "
"footprint library table '%s'\n\n%s" ),
GetChars( fp_lib_tbl ),
GetChars( ioe.errorText )
);
DisplayError( this, msg );
}
}
}
#endif
}
if( !IsWritable( fn.GetFullPath() ) )
return 0;
if( WriteComponentLinkFile( fn.GetFullPath() ) == 0 )
if( !IsWritable( fn.GetFullPath() ) || WriteComponentLinkFile( fn.GetFullPath() ) == 0 )
{
DisplayError( this, _( "Unable to create component footprint link file (.cmp)" ) );
DisplayError( this,
wxString::Format( _( "Unable to create component footprint link file '%s'" ),
fn.GetFullPath() ) );
return 0;
}
......
......@@ -69,10 +69,6 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
KiBitmap( show_footprint_xpm ),
_( "View selected footprint" ) );
m_mainToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
KiBitmap( auto_associe_xpm ),
_( "Perform automatic footprint association" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString,
KiBitmap( left_xpm ),
......@@ -83,6 +79,10 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
_( "Select next unlinked component" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
KiBitmap( auto_associe_xpm ),
_( "Perform automatic footprint association" ) );
m_mainToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString,
KiBitmap( delete_association_xpm ),
_( "Delete all associations (links)" ) );
......@@ -92,7 +92,6 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
KiBitmap( datasheet_xpm ),
_( "Display footprint documentation" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
KiBitmap( module_filtered_list_xpm ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment