ADDED: CADSTAR Archive project importer
This commit is contained in:
parent
8e7e1ffaaa
commit
72b904a978
|
@ -242,6 +242,12 @@ wxString CadstarSchematicArchiveFileWildcard()
|
|||
}
|
||||
|
||||
|
||||
wxString CadstarArchiveFilesWildcard()
|
||||
{
|
||||
return _( "CADSTAR Archive files" ) + AddFileExtListToFilter( { "csa", "cpa" } );
|
||||
}
|
||||
|
||||
|
||||
wxString EagleSchematicFileWildcard()
|
||||
{
|
||||
return _( "Eagle XML schematic files" ) + AddFileExtListToFilter( { "sch" } );
|
||||
|
|
|
@ -195,6 +195,7 @@ extern wxString PcbFileWildcard();
|
|||
extern wxString EaglePcbFileWildcard();
|
||||
extern wxString AltiumSchematicFileWildcard();
|
||||
extern wxString CadstarSchematicArchiveFileWildcard();
|
||||
extern wxString CadstarArchiveFilesWildcard();
|
||||
extern wxString EagleSchematicFileWildcard();
|
||||
extern wxString EagleFilesWildcard();
|
||||
extern wxString PCadPcbFileWildcard();
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
/**
|
||||
* @file import_project.cpp
|
||||
* @brief routines for importing an eagle project
|
||||
* @brief routines for importing a non-KiCad project
|
||||
*/
|
||||
|
||||
|
||||
|
@ -46,16 +46,16 @@
|
|||
|
||||
#include "kicad_manager_frame.h"
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
||||
|
||||
void KICAD_MANAGER_FRAME::ImportNonKiCadProject( wxString aWindowTitle, wxString aFilesWildcard,
|
||||
wxString aSchFileExtension, wxString aPcbFileExtension, int aSchFileType, int aPcbFileType )
|
||||
{
|
||||
wxString title = _( "Import Eagle Project Files" );
|
||||
int style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
|
||||
int style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
|
||||
wxString default_dir = GetMruPath();
|
||||
|
||||
ClearMsg();
|
||||
|
||||
wxFileDialog schdlg( this, title, default_dir, wxEmptyString,
|
||||
EagleFilesWildcard(), style );
|
||||
wxFileDialog schdlg( this, aWindowTitle, default_dir, wxEmptyString, aFilesWildcard, style );
|
||||
|
||||
if( schdlg.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
@ -63,7 +63,7 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
|||
|
||||
wxFileName sch( schdlg.GetPath() );
|
||||
|
||||
sch.SetExt( LegacySchematicFileExtension );
|
||||
sch.SetExt( aSchFileExtension );
|
||||
|
||||
wxFileName pro = sch;
|
||||
|
||||
|
@ -85,9 +85,10 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
|||
|
||||
if( directory.HasFiles() )
|
||||
{
|
||||
wxString msg = _( "The selected directory is not empty. We recommend you "
|
||||
"create projects in their own clean directory.\n\nDo you "
|
||||
"want to create a new empty directory for the project?" );
|
||||
wxString msg =
|
||||
_( "The selected directory is not empty. We recommend you "
|
||||
"create projects in their own clean directory.\n\nDo you "
|
||||
"want to create a new empty directory for the project?" );
|
||||
|
||||
KIDIALOG dlg( this, msg, _( "Confirmation" ), wxYES_NO | wxICON_WARNING );
|
||||
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
|
||||
|
@ -106,8 +107,9 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
|||
|
||||
wxFileName pcb( sch );
|
||||
std::string packet;
|
||||
|
||||
pro.SetExt( ProjectFileExtension );
|
||||
pcb.SetExt( LegacyPcbFileExtension ); // enforce extension
|
||||
pcb.SetExt( aPcbFileExtension ); // enforce extension
|
||||
|
||||
if( !pro.IsAbsolute() )
|
||||
pro.MakeAbsolute();
|
||||
|
@ -121,7 +123,7 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
|||
{
|
||||
KIWAY_PLAYER* schframe = Kiway().Player( FRAME_SCH, true );
|
||||
|
||||
packet = StrPrintf( "%d\n%s", SCH_IO_MGR::SCH_EAGLE, TO_UTF8( sch.GetFullPath() ) );
|
||||
packet = StrPrintf( "%d\n%s", aSchFileType, TO_UTF8( sch.GetFullPath() ) );
|
||||
schframe->Kiway().ExpressMail( FRAME_SCH, MAIL_IMPORT_FILE, packet, this );
|
||||
|
||||
if( !schframe->IsShown() )
|
||||
|
@ -141,7 +143,7 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
|||
if( !pcbframe->IsVisible() )
|
||||
pcbframe->Show( true );
|
||||
|
||||
packet = StrPrintf( "%d\n%s", IO_MGR::EAGLE, TO_UTF8( pcb.GetFullPath() ) );
|
||||
packet = StrPrintf( "%d\n%s", aPcbFileType, TO_UTF8( pcb.GetFullPath() ) );
|
||||
pcbframe->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_IMPORT_FILE, packet, this );
|
||||
|
||||
// On Windows, Raise() does not bring the window on screen, when iconized
|
||||
|
@ -154,3 +156,19 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
|||
ReCreateTreePrj();
|
||||
m_active_project = true;
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnImportCadstarArchiveFiles( wxCommandEvent& event )
|
||||
{
|
||||
ImportNonKiCadProject( _( "Import CADSTAR Archive Project Files" ),
|
||||
CadstarArchiveFilesWildcard(), "csa", "cpa", SCH_IO_MGR::SCH_CADSTAR_ARCHIVE,
|
||||
IO_MGR::CADSTAR_PCB_ARCHIVE );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
||||
{
|
||||
ImportNonKiCadProject( _( "Import Eagle Project Files" ), EagleFilesWildcard(),
|
||||
LegacySchematicFileExtension, LegacyPcbFileExtension,
|
||||
SCH_IO_MGR::SCH_EAGLE, IO_MGR::EAGLE );
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ enum id_kicad_frm {
|
|||
ID_READ_ZIP_ARCHIVE,
|
||||
ID_INIT_WATCHED_PATHS,
|
||||
ID_IMPORT_EAGLE_PROJECT,
|
||||
ID_IMPORT_CADSTAR_ARCHIVE_PROJECT,
|
||||
|
||||
// Please, verify: the number of items in this list should be
|
||||
// less than ROOM_FOR_KICADMANAGER (see id.h)
|
||||
|
|
|
@ -75,6 +75,7 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
|
|||
EVT_MENU( ID_BROWSE_IN_FILE_EXPLORER, KICAD_MANAGER_FRAME::OnBrowseInFileExplorer )
|
||||
EVT_MENU( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles )
|
||||
EVT_MENU( ID_READ_ZIP_ARCHIVE, KICAD_MANAGER_FRAME::OnUnarchiveFiles )
|
||||
EVT_MENU( ID_IMPORT_CADSTAR_ARCHIVE_PROJECT, KICAD_MANAGER_FRAME::OnImportCadstarArchiveFiles )
|
||||
EVT_MENU( ID_IMPORT_EAGLE_PROJECT, KICAD_MANAGER_FRAME::OnImportEagleFiles )
|
||||
|
||||
// Range menu events
|
||||
|
|
|
@ -108,6 +108,25 @@ public:
|
|||
return GetProjectFileName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Creates a project and imports a non-KiCad Schematic and PCB
|
||||
* @param aWindowTitle to display to the user when opening the files
|
||||
* @param aFilesWildcard that includes both PCB and Schematic files (from wildcards_and_files_ext.h)
|
||||
* @param aSchFileExtension e.g. "sch" or "csa"
|
||||
* @param aPcbFileExtension e.g. "brd" or "cpa"
|
||||
* @param aSchFileType Type of Schematic File to import (from SCH_IO_MGR::SCH_FILE_T)
|
||||
* @param aPcbFileType Type of PCB File to import (from IO_MGR::PCB_FILE_T)
|
||||
*/
|
||||
void ImportNonKiCadProject( wxString aWindowTitle, wxString aFilesWildcard,
|
||||
wxString aSchFileExtension, wxString aPcbFileExtension, int aSchFileType,
|
||||
int aPcbFileType );
|
||||
|
||||
/**
|
||||
* Open dialog to import CADSTAR Schematic and PCB Archive files.
|
||||
*/
|
||||
void OnImportCadstarArchiveFiles( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Open dialog to import Eagle schematic and board files.
|
||||
*/
|
||||
|
|
|
@ -84,10 +84,23 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
|||
fileMenu->Add( ACTIONS::saveAs );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Add( _( "Import EAGLE Project..." ),
|
||||
_( "Import EAGLE CAD XML schematic and board" ),
|
||||
ID_IMPORT_EAGLE_PROJECT,
|
||||
import_project_xpm );
|
||||
|
||||
//Import Sub-menu
|
||||
ACTION_MENU* importMenu = new ACTION_MENU( false, controlTool );
|
||||
importMenu->SetTitle( _( "Import Non-KiCad Project..." ) );
|
||||
importMenu->SetIcon( import_project_xpm );
|
||||
|
||||
importMenu->Add( _( "Import CADSTAR Project..." ),
|
||||
_( "Import CADSTAR Archive Schematic and PCB (*.csa, *.cpa)" ),
|
||||
ID_IMPORT_CADSTAR_ARCHIVE_PROJECT,
|
||||
import_project_xpm );
|
||||
|
||||
importMenu->Add( _( "Import EAGLE Project..." ),
|
||||
_( "Import EAGLE CAD XML schematic and board" ),
|
||||
ID_IMPORT_EAGLE_PROJECT,
|
||||
import_project_xpm );
|
||||
|
||||
fileMenu->Add( importMenu );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Add( _( "&Archive Project..." ),
|
||||
|
|
|
@ -1013,6 +1013,7 @@ bool PCB_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
|||
{
|
||||
switch( (IO_MGR::PCB_FILE_T) aFileType )
|
||||
{
|
||||
case IO_MGR::CADSTAR_PCB_ARCHIVE:
|
||||
case IO_MGR::EAGLE:
|
||||
if( OpenProjectFiles( std::vector<wxString>( 1, aFileName ), KICTL_EAGLE_BRD ) )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue