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

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
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+6 −0
Original line number Diff line number Diff line
@@ -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;
}

+2 −0
Original line number Diff line number Diff line
@@ -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
+8 −16
Original line number Diff line number Diff line
/*
 * 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;
+8 −21
Original line number Diff line number Diff line
/*
 * 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,27 +76,15 @@ void CVPCB_MAINFRAME::LoadProjectFile()
void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
{
    PROJECT&    prj = Prj();
    wxFileName  fn = prj.AbsolutePath( m_NetlistFileName.GetFullPath() );
    SetTitle( wxString::Format( _( "Project file: '%s'" ), GetChars( prj.GetProjectFullName() ) ) );
    wxFileName  fn = prj.GetProjectFullName();

    fn.SetExt( ProjectFileExtension );

    if( aEvent.GetId() == ID_SAVE_PROJECT_AS || !m_NetlistFileName.IsOk() )
    if( !IsWritable( fn ) )
    {
        wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
                          wxEmptyString, ProjectFileWildcard, wxFD_SAVE );

        if( dlg.ShowModal() == wxID_CANCEL )
        wxMessageBox( _( "Project file '%s' is not writable" ), fn.GetFullPath() );
        return;

        fn = dlg.GetPath();

        if( !fn.HasExt() )
            fn.SetExt( ProjectFileExtension );
    }

    if( !IsWritable( fn ) )
        return;

    wxString pro_name = fn.GetFullPath();

    prj.ConfigSave( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters(), pro_name );
Loading