Added a ImportSpecctraSession overload that doesn't require a PCB_EDIT_FRAME
This commit is contained in:
parent
d620cb8a6e
commit
5cf244dd90
|
@ -359,7 +359,7 @@ bool ExportSpecctraDSN( BOARD* aBoard, wxString& aFullFilename )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ExportBoardToSpecctraFile( aBoard, aFullFilename );
|
DSN::ExportBoardToSpecctraFile( aBoard, aFullFilename );
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{
|
{
|
||||||
|
@ -399,6 +399,20 @@ bool ImportSpecctraSES( wxString& aFullFilename )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImportSpecctraSES( BOARD* aBoard, wxString& aFullFilename )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DSN::ImportSpecctraSession( aBoard, aFullFilename );
|
||||||
|
}
|
||||||
|
catch( ... )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName, wxString* aLibPath )
|
bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName, wxString* aLibPath )
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,6 +137,17 @@ bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool aExpo
|
||||||
*/
|
*/
|
||||||
bool ImportSpecctraSES( wxString& aFullFilename );
|
bool ImportSpecctraSES( wxString& aFullFilename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import a specctra *.ses file and use it to relocate MODULEs and to replace all vias and
|
||||||
|
* Unlike first overload doesn't need a valid PCB_EDIT_FRAME set and can be used
|
||||||
|
* in a standalone python script.
|
||||||
|
*
|
||||||
|
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the specification.
|
||||||
|
*
|
||||||
|
* @return true if OK
|
||||||
|
*/
|
||||||
|
bool ImportSpecctraSES( BOARD* aBoard, wxString& aFullFilename );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save footprints in a library:
|
* Save footprints in a library:
|
||||||
*
|
*
|
||||||
|
|
|
@ -48,15 +48,6 @@ class SHAPE_POLY_SET;
|
||||||
typedef DSN::T DSN_T;
|
typedef DSN::T DSN_T;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Helper method to export board to DSN file
|
|
||||||
*
|
|
||||||
* @param aBoard board object
|
|
||||||
* @param aFullFilename specctra file name
|
|
||||||
*/
|
|
||||||
void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This source file implements export and import capabilities to the
|
* This source file implements export and import capabilities to the
|
||||||
* specctra dsn file format. The grammar for that file format is documented
|
* specctra dsn file format. The grammar for that file format is documented
|
||||||
|
@ -85,6 +76,14 @@ namespace DSN {
|
||||||
class SPECCTRA_DB;
|
class SPECCTRA_DB;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Helper method to export board to DSN file
|
||||||
|
* @param aBoard board object
|
||||||
|
* @param aFullFilename specctra file name
|
||||||
|
*/
|
||||||
|
void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
|
* The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
|
||||||
*
|
*
|
||||||
|
@ -4003,6 +4002,14 @@ private:
|
||||||
int m_bot_via_layer;
|
int m_bot_via_layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Helper method to import SES file to a board
|
||||||
|
*
|
||||||
|
* @param aBoard board object
|
||||||
|
* @param aFullFilename specctra file name
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName );
|
||||||
|
|
||||||
} // namespace DSN
|
} // namespace DSN
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ExportBoardToSpecctraFile( GetBoard(), aFullFilename );
|
DSN::ExportBoardToSpecctraFile( GetBoard(), aFullFilename );
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
|
@ -102,6 +102,9 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace DSN
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename )
|
void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename )
|
||||||
{
|
{
|
||||||
|
@ -138,8 +141,6 @@ void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace DSN {
|
|
||||||
|
|
||||||
// "specctra reported units" are what we tell the external router that our exported lengths are in
|
// "specctra reported units" are what we tell the external router that our exported lengths are in
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,28 +50,23 @@
|
||||||
|
|
||||||
using namespace DSN;
|
using namespace DSN;
|
||||||
|
|
||||||
|
|
||||||
bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
|
bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
|
||||||
{
|
{
|
||||||
// To avoid issues with undo/redo lists (dangling pointers) clear the lists
|
// To avoid issues with undo/redo lists (dangling pointers) clear the lists
|
||||||
// todo: use undo/redo feature
|
// todo: use undo/redo feature
|
||||||
ClearUndoRedoList();
|
ClearUndoRedoList();
|
||||||
|
|
||||||
// Remove existing tracks from view. They will be readded later after loading new tracks.
|
|
||||||
if( GetCanvas() ) // clear view:
|
if( GetCanvas() ) // clear view:
|
||||||
{
|
{
|
||||||
for( PCB_TRACK* track : GetBoard()->Tracks() )
|
for( PCB_TRACK* track : GetBoard()->Tracks() )
|
||||||
GetCanvas()->GetView()->Remove( track );
|
GetCanvas()->GetView()->Remove( track );
|
||||||
}
|
}
|
||||||
|
|
||||||
SPECCTRA_DB db;
|
|
||||||
LOCALE_IO toggle;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
db.LoadSESSION( fullFileName );
|
DSN::ImportSpecctraSession( GetBoard(), fullFileName );
|
||||||
db.FromSESSION( GetBoard() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxString msg = _( "Board may be corrupted, do not save it.\n Fix problem and try again" );
|
wxString msg = _( "Board may be corrupted, do not save it.\n Fix problem and try again" );
|
||||||
|
@ -82,15 +77,11 @@ bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetBoard()->GetConnectivity()->ClearRatsnest();
|
|
||||||
GetBoard()->BuildConnectivity();
|
|
||||||
|
|
||||||
OnModify();
|
OnModify();
|
||||||
|
|
||||||
if( GetCanvas() ) // Update view:
|
if( GetCanvas() ) // Update view:
|
||||||
{
|
{
|
||||||
// Update footprint positions
|
// Update footprint positions
|
||||||
GetCanvas()->GetView()->RecacheAllItems();
|
|
||||||
|
|
||||||
// add imported tracks (previous tracks are removed, therefore all are new)
|
// add imported tracks (previous tracks are removed, therefore all are new)
|
||||||
for( auto track : GetBoard()->Tracks() )
|
for( auto track : GetBoard()->Tracks() )
|
||||||
|
@ -545,4 +536,17 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName )
|
||||||
|
{
|
||||||
|
SPECCTRA_DB db;
|
||||||
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
|
db.LoadSESSION( fullFileName );
|
||||||
|
db.FromSESSION( aBoard );
|
||||||
|
|
||||||
|
aBoard->GetConnectivity()->ClearRatsnest();
|
||||||
|
aBoard->BuildConnectivity();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} // namespace DSN
|
} // namespace DSN
|
||||||
|
|
Loading…
Reference in New Issue