specctra import work

This commit is contained in:
dickelbeck 2008-02-07 06:49:16 +00:00
parent cf460637b2
commit c8584436b4
5 changed files with 112 additions and 11 deletions

View File

@ -844,6 +844,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(m_Pcb);
zone_descr->ReadDescr( File, &LineNum );
m_Pcb->Add(zone_descr);
continue;
}
if( strnicmp( Line, "$MODULE", 7 ) == 0 )

View File

@ -1782,6 +1782,7 @@ public:
i->Format( out, nestLevel );
}
};
typedef boost::ptr_vector<COMPONENT> COMPONENTS;
class PLACEMENT : public ELEM
@ -1792,7 +1793,6 @@ class PLACEMENT : public ELEM
DSN_T flip_style;
typedef boost::ptr_vector<COMPONENT> COMPONENTS;
COMPONENTS components;
public:
@ -3814,6 +3814,17 @@ public:
void FromBOARD( BOARD* aBoard );
/**
* Function FromSESSION
* adds the entire SESSION info to a BOARD but does not write it out. The
* the BOARD given to this function will have all its tracks and via's replaced,
* and all its components are subject to being moved.
*
* @param aBoard The BOARD to merge the SESSION information into.
*/
void FromSESSION( BOARD* aBoard ) throw( IOError );
/**
* Function ExportSESSION
* writes the internal SESSION instance out as a SPECTRA DSN format file.

View File

@ -63,13 +63,6 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
if( fullFileName == wxEmptyString )
return;
// prepare the EQUIPOTs
if( !( m_Pcb->m_Status_Pcb & NET_CODES_OK ) )
{
//m_Pcb->m_Status_Pcb &= ~(LISTE_PAD_OK);
recalcule_pad_net_code();
}
SPECCTRA_DB db;
bool ok = true;
wxString errorText;
@ -172,8 +165,8 @@ static POINT mapPt( const wxPoint& pt )
/**
* Function findPOINT
* searches the list of POINT_PAIRS for a matching end to the given POINT.
* @return int - 0 if no match, or + one based index of a POINT_PAIR with a matching ".start",
* or a - one based index of a POINT_PAIR with a matching ".end".
* @return int - 0 if no match, or positive one based index of a POINT_PAIR with a matching ".start",
* or a negated one based index of a POINT_PAIR with a matching ".end".
*/
static int findPOINT( const POINT& pt, const POINT_PAIR source[], int count )
{

View File

@ -34,17 +34,113 @@
#include "specctra.h"
#include "common.h" // IsOK() & EDA_FileSelector()
using namespace DSN;
void WinEDA_PcbFrame::ImportSpecctraDesign( wxCommandEvent& event )
{
if( !Clear_Pcb( true ) )
return;
}
void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
{
if( GetScreen()->IsModify() )
{
if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
return;
}
wxString sessionExt( wxT( ".ses" ) );
wxString fileName = GetScreen()->m_FileName;
wxString mask = wxT( "*" ) + sessionExt;
ChangeFileNameExt( fileName, sessionExt );
fileName = EDA_FileSelector( _( "Merge Specctra Session file:" ),
wxEmptyString,
fileName,
sessionExt,
mask,
this,
wxFD_OPEN,
FALSE );
if( fileName == wxEmptyString )
return;
SPECCTRA_DB db;
try
{
db.LoadSESSION( fileName );
db.FromSESSION( m_Pcb );
}
catch( IOError ioe )
{
DisplayError( this, ioe.errorText );
return;
}
m_SelTrackWidthBox_Changed = TRUE;
m_SelViaSizeBox_Changed = TRUE;
GetScreen()->SetModify();
m_Pcb->m_Status_Pcb = 0;
Affiche_Message( wxString( _("Session file imported and merged OK.")) );
DrawPanel->Refresh( TRUE );
}
namespace DSN {
// no UI code in this function, throw exception to report problems to the
// UI handler: void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
{
wxASSERT( session );
// delete all the old tracks and vias
aBoard->m_Track->DeleteStructList();
aBoard->m_Track = NULL;
aBoard->m_NbSegmTrack = 0;
aBoard->DeleteMARKERs();
if( !session->placement )
ThrowIOError( _("Session file is missing the \"placement\" section") );
if( !session->route )
ThrowIOError( _("Session file is missing the \"routes\" section") );
if( !session->route->library )
ThrowIOError( _("Session file is missing the \"library_out\" section") );
// Walk the PLACEMENT object's components list.
COMPONENTS& components = session->placement->components;
for( COMPONENTS::iterator i=components.begin(); i!=components.end(); ++i )
{
// reposition and re-orient each component and put on correct side of the board.
}
// Walk the NET_OUTs and create tracks and vias anew.
NET_OUTS& net_outs = session->route->net_outs;
for( NET_OUTS::iterator i=net_outs.begin(); i!=net_outs.end(); ++i )
{
// create a track or via and position it.
}
}
} // namespace DSN