Browse Source
Kicad: Add Project import function. -- add menu entry -- add ImportFile kiway function -- expose functions for creating/reading netlist -- add example eagle boad file as well
pull/5/merge
Kicad: Add Project import function. -- add menu entry -- add ImportFile kiway function -- expose functions for creating/reading netlist -- add example eagle boad file as well
pull/5/merge
committed by
Maciej Suminski
14 changed files with 3238 additions and 19 deletions
-
1common/wildcards_and_files_ext.cpp
-
59eeschema/files-io.cpp
-
2859eeschema/qa/data/eagle_schematics/eagle-import-testfile.brd
-
6eeschema/qa/data/eagle_schematics/eagle-import-testfile.sch
-
26eeschema/sch_eagle_plugin.cpp
-
3eeschema/schframe.h
-
41include/kiway_player.h
-
1include/wildcards_and_files_ext.h
-
3kicad/CMakeLists.txt
-
201kicad/import_project.cpp
-
3kicad/kicad.h
-
17kicad/menubar.cpp
-
21pcbnew/files.cpp
-
16pcbnew/wxPcbStruct.h
2859
eeschema/qa/data/eagle_schematics/eagle-import-testfile.brd
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,201 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 2004-2017 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 eagle_project.cpp |
|||
* @brief routines for importing an eagle project |
|||
*/ |
|||
|
|||
|
|||
#include <wx/filename.h>
|
|||
#include <wx/dir.h>
|
|||
#include <wx/log.h>
|
|||
#include <wx/stdpaths.h>
|
|||
#include <wx/string.h>
|
|||
|
|||
#include <common.h>
|
|||
#include <confirm.h>
|
|||
#include <hotkeys_basic.h>
|
|||
#include <kiway.h>
|
|||
#include <richio.h>
|
|||
#include <wildcards_and_files_ext.h>
|
|||
#include <systemdirsappend.h>
|
|||
#include <kiway_player.h>
|
|||
#include <stdexcept>
|
|||
#include "pgm_kicad.h"
|
|||
|
|||
#include <wxPcbStruct.h>
|
|||
#include <schframe.h>
|
|||
#include <netlist.h>
|
|||
|
|||
class PCB_EDIT_FRAME; |
|||
|
|||
#include "kicad.h"
|
|||
|
|||
void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event ) |
|||
{ |
|||
// Close other windows.
|
|||
if( !Kiway.PlayersClose( false ) ) |
|||
return; |
|||
|
|||
|
|||
wxString title = _( "Import Eagle Project Files" ); |
|||
int style = wxFD_OPEN | wxFD_FILE_MUST_EXIST; |
|||
wxString default_dir = GetMruPath(); |
|||
|
|||
ClearMsg(); |
|||
|
|||
wxFileDialog schdlg( this, title, default_dir, wxEmptyString, |
|||
EagleSchematicFileWildcard, style ); |
|||
|
|||
if( schdlg.ShowModal() == wxID_CANCEL ) |
|||
return; |
|||
|
|||
|
|||
wxFileName sch( schdlg.GetPath() ); |
|||
|
|||
wxString protitle = _( "Kicad Project Destination" ); |
|||
|
|||
wxFileDialog prodlg( this, protitle, default_dir, wxEmptyString, |
|||
ProjectFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); |
|||
|
|||
if( prodlg.ShowModal() == wxID_CANCEL ) |
|||
return; |
|||
|
|||
wxFileName pro( prodlg.GetPath() ); |
|||
// Check if the project directory is empty
|
|||
wxDir directory( pro.GetPath() ); |
|||
|
|||
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?" ); |
|||
|
|||
if( IsOK( this, msg ) ) |
|||
{ |
|||
// Append a new directory with the same name of the project file
|
|||
// and try to create it
|
|||
pro.AppendDir( pro.GetName() ); |
|||
|
|||
if( !wxMkdir( pro.GetPath() ) ) |
|||
// There was a problem, undo
|
|||
pro.RemoveLastDir(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
wxFileName pcb( sch ); |
|||
wxFileName netlist( pro ); |
|||
pro.SetExt( ProjectFileExtension ); // enforce extension
|
|||
pcb.SetExt( LegacyPcbFileExtension ); // enforce extension
|
|||
netlist.SetExt( NetlistFileExtension ); |
|||
|
|||
if( !pro.IsAbsolute() ) |
|||
pro.MakeAbsolute(); |
|||
|
|||
SetProjectFileName( pro.GetFullPath() ); |
|||
|
|||
wxString prj_filename = GetProjectFileName(); |
|||
|
|||
wxString sch_filename = sch.GetFullPath(); |
|||
|
|||
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, false ); |
|||
|
|||
if( !schframe ) |
|||
{ |
|||
try |
|||
{ |
|||
schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, true ); |
|||
} |
|||
catch( IO_ERROR err ) |
|||
{ |
|||
wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(), |
|||
_( "KiCad Error" ), wxOK | wxICON_ERROR, this ); |
|||
return; |
|||
} |
|||
} |
|||
|
|||
schframe->ImportFile( sch_filename ); |
|||
|
|||
if( !schframe->IsShown() ) // the frame exists, (created by the dialog field editor)
|
|||
// but no project loaded.
|
|||
{ |
|||
schframe->Show( true ); |
|||
} |
|||
|
|||
if( schframe->IsIconized() ) |
|||
schframe->Iconize( false ); |
|||
|
|||
schframe->Raise(); |
|||
|
|||
|
|||
// Calculate the netlist filename
|
|||
wxString nestlistFileFullpath = netlist.GetFullPath(); |
|||
schframe->CreateNetlist( NET_TYPE_PCBNEW, nestlistFileFullpath, 0 ); |
|||
|
|||
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, false ); |
|||
|
|||
if( !pcbframe ) |
|||
{ |
|||
try |
|||
{ |
|||
pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, true ); |
|||
} |
|||
catch( IO_ERROR err ) |
|||
{ |
|||
wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ), |
|||
wxOK | wxICON_ERROR, this ); |
|||
return; |
|||
} |
|||
} |
|||
|
|||
// a pcb frame can be already existing, but not yet used.
|
|||
// this is the case when running the footprint editor, or the footprint viewer first
|
|||
// if the frame is not visible, the board is not yet loaded
|
|||
if( !pcbframe->IsVisible() ) |
|||
{ |
|||
pcbframe->ImportFile( pcb.GetFullPath() ); |
|||
pcbframe->Show( true ); |
|||
} |
|||
|
|||
// On Windows, Raise() does not bring the window on screen, when iconized
|
|||
if( pcbframe->IsIconized() ) |
|||
pcbframe->Iconize( false ); |
|||
|
|||
pcbframe->Raise(); |
|||
|
|||
pcbframe->ReadPcbNetlist( nestlistFileFullpath, |
|||
wxEmptyString, |
|||
NULL, |
|||
false, |
|||
false, |
|||
false, |
|||
false, |
|||
false, |
|||
false ); |
|||
|
|||
ReCreateTreePrj(); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue