2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file ioascii.cpp
|
2011-09-30 18:15:37 +00:00
|
|
|
* @brief Routines for reading and saving of structures in ASCII file common to Pcbnew and CvPcb.
|
2011-09-23 13:57:12 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <build_version.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <richio.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <pcbcommon.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @todo Fix having to recompile the same file with a different defintion. This is
|
|
|
|
* what C++ derivation was designed to solve.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifdef PCBNEW
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <zones.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CVPCB
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <cvpcb.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_pcb_text.h>
|
|
|
|
#include <class_zone.h>
|
|
|
|
#include <class_dimension.h>
|
|
|
|
#include <class_drawsegment.h>
|
|
|
|
#include <class_mire.h>
|
2010-01-05 08:48:49 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <autorout.h>
|
|
|
|
#include <pcb_plot_params.h>
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* ASCII format of structures:
|
|
|
|
*
|
|
|
|
* Structure PAD:
|
|
|
|
*
|
|
|
|
* $PAD
|
|
|
|
* Sh "name" form DIMVA dimH dV dH East: general form dV, dH = delta size
|
|
|
|
* Dr. diam dV dH: drill: diameter drilling offsets
|
|
|
|
* At Type S / N layers: standard, cms, conn, hole, meca.,
|
|
|
|
* Stack / Normal, 32-bit hexadecimal: occupation layers
|
|
|
|
* Nm net_code netname
|
|
|
|
* Po posrefX posrefy: reFX position, Y (0 = east position / anchor)
|
|
|
|
* $EndPAD
|
|
|
|
*
|
|
|
|
* Module Structure
|
|
|
|
*
|
|
|
|
* $MODULE namelib
|
|
|
|
* Po ax ay east layer masquelayer m_TimeCode
|
|
|
|
* ax ay ord = anchor (position module)
|
|
|
|
* east = east to 0.1 degree
|
|
|
|
* layer = layer number
|
|
|
|
* masquelayer = silkscreen layer for
|
|
|
|
* m_TimeCode internal use (groups)
|
|
|
|
* Li <namelib>
|
|
|
|
*
|
|
|
|
* Cd <text> description of the component (Component Doc)
|
|
|
|
* Kw <text> List of key words
|
|
|
|
*
|
|
|
|
* Sc schematic timestamp, reference schematic
|
|
|
|
*
|
|
|
|
* Op rot90 rot180 placement Options Auto (court rot 90, 180)
|
|
|
|
* rot90 is about 2x4-bit:
|
|
|
|
* lsb = cost rot 90, rot court msb = -90;
|
|
|
|
*
|
|
|
|
* Tn px py DIMVA dimh East thickness mirror visible "text"
|
|
|
|
* n = type (0 = ref, val = 1,> 1 = qcq
|
|
|
|
* Texts POS x, y / anchor and orient module 0
|
|
|
|
* DIMVA dimh East
|
|
|
|
* mirror thickness (Normal / Mirror)
|
|
|
|
* Visible V / I
|
|
|
|
* DS ox oy fx fy w
|
|
|
|
* Edge: coord segment ox, oy has fx, fy, on
|
|
|
|
* was the anchor and orient 0
|
|
|
|
* thickness w
|
|
|
|
* DC ox oy fx fy w descr circle (center, 1 point, thickness)
|
|
|
|
* $PAD
|
|
|
|
* $EndPAD section pads if available
|
|
|
|
* $Endmodule
|
|
|
|
*/
|
2008-12-05 16:03:05 +00:00
|
|
|
|
2012-01-05 16:30:58 +00:00
|
|
|
/// Get the length of a string constant, at compile time
|
|
|
|
#define SZ( x ) (sizeof(x)-1)
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
static int NbDraw, NbTrack, NbZone, NbMod, NbNets;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
static const char delims[] = " =\n\r";
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-12-03 06:54:19 +00:00
|
|
|
/** Read a list of segments (Tracks, zones)
|
|
|
|
* @return items count or - count if no end block ($End...) found.
|
2007-08-06 02:02:39 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
int PCB_BASE_FRAME::ReadListeSegmentDescr( LINE_READER* aReader,
|
|
|
|
TRACK* insertBeforeMe,
|
|
|
|
int StructType,
|
|
|
|
int NumSegm )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
int shape, width, drill, layer, type, flags, net_code;
|
2011-01-14 17:43:30 +00:00
|
|
|
int tempStartX, tempStartY;
|
|
|
|
int tempEndX, tempEndY;
|
2009-11-14 22:15:22 +00:00
|
|
|
int ii = 0;
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
TRACK* newTrack;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
while( aReader->ReadLine() )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
char* line = aReader->Line();
|
|
|
|
int makeType;
|
|
|
|
unsigned long timeStamp;
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
if( line[0] == '$' )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
return ii; // end of segmentlist: OK
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
int arg_count = sscanf( line + 2, " %d %d %d %d %d %d %d", &shape,
|
|
|
|
&tempStartX, &tempStartY,
|
|
|
|
&tempEndX, &tempEndY, &width,
|
|
|
|
&drill );
|
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// Read the 2nd line to determine the exact type, one of:
|
2011-10-01 19:24:27 +00:00
|
|
|
// PCB_TRACE_T, PCB_VIA_T, or PCB_ZONE_T. The type field in 2nd line
|
|
|
|
// differentiates between PCB_TRACE_T and PCB_VIA_T. With virtual
|
|
|
|
// functions in use, it is critical to instantiate the PCB_VIA_T
|
2009-11-14 22:15:22 +00:00
|
|
|
// exactly.
|
2011-01-14 17:43:30 +00:00
|
|
|
if( !aReader->ReadLine() )
|
2007-08-30 22:20:52 +00:00
|
|
|
break;
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
line = aReader->Line();
|
|
|
|
|
|
|
|
if( line[0] == '$' )
|
2007-08-30 22:20:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// parse the 2nd line first to determine the type of object
|
2011-01-14 17:43:30 +00:00
|
|
|
sscanf( line + 2, " %d %d %d %lX %X", &layer, &type, &net_code,
|
2007-08-30 22:20:52 +00:00
|
|
|
&timeStamp, &flags );
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( StructType==PCB_TRACE_T && type==1 )
|
|
|
|
makeType = PCB_VIA_T;
|
2007-08-30 22:20:52 +00:00
|
|
|
else
|
|
|
|
makeType = StructType;
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
switch( makeType )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
default:
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
2009-01-05 05:21:35 +00:00
|
|
|
newTrack = new TRACK( GetBoard() );
|
|
|
|
GetBoard()->m_Track.Insert( newTrack, insertBeforeMe );
|
2007-08-06 02:02:39 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_VIA_T:
|
2009-01-05 05:21:35 +00:00
|
|
|
newTrack = new SEGVIA( GetBoard() );
|
|
|
|
GetBoard()->m_Track.Insert( newTrack, insertBeforeMe );
|
2007-08-06 02:02:39 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
case PCB_ZONE_T: // this is now deprecated, but exist in old boards
|
2009-01-05 05:21:35 +00:00
|
|
|
newTrack = new SEGZONE( GetBoard() );
|
2011-09-07 19:41:04 +00:00
|
|
|
GetBoard()->m_Zone.Insert( (SEGZONE*) newTrack, (SEGZONE*) insertBeforeMe );
|
2007-08-06 02:02:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
newTrack->SetTimeStamp( timeStamp );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
newTrack->m_Start.x = tempStartX;
|
|
|
|
newTrack->m_Start.y = tempStartY;
|
|
|
|
newTrack->m_End.x = tempEndX;
|
|
|
|
newTrack->m_End.y = tempEndY;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_Width = width;
|
|
|
|
newTrack->m_Shape = shape;
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
if( arg_count < 7 || drill <= 0 )
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->SetDrillDefault();
|
2008-03-01 13:15:41 +00:00
|
|
|
else
|
2011-12-14 04:29:25 +00:00
|
|
|
newTrack->SetDrill( drill );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->SetLayer( layer );
|
2009-05-21 12:45:21 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( makeType == PCB_VIA_T ) // Ensure layers are OK when possible:
|
2009-11-14 22:15:22 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
if( newTrack->GetShape() == VIA_THROUGH )
|
2011-09-07 19:41:04 +00:00
|
|
|
( (SEGVIA*) newTrack )->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK );
|
2009-05-21 12:45:21 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->SetNet( net_code );
|
|
|
|
newTrack->SetState( flags, ON );
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayError( this, _( "Error: Unexpected end of file !" ) );
|
|
|
|
return -ii;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
int PCB_BASE_FRAME::ReadGeneralDescrPcb( LINE_READER* aReader )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
while( aReader->ReadLine() )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
char* line = aReader->Line();
|
|
|
|
char* data = strtok( line, delims );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
if( strnicmp( data, "$EndGENERAL", 10 ) == 0 )
|
|
|
|
break;
|
|
|
|
|
2009-10-10 01:25:53 +00:00
|
|
|
if( stricmp( data, "EnabledLayers" ) == 0 )
|
|
|
|
{
|
2012-02-06 07:14:51 +00:00
|
|
|
int enabledLayers = 0;
|
2011-10-20 14:46:06 +00:00
|
|
|
|
|
|
|
data = strtok( NULL, delims );
|
2012-02-06 07:14:51 +00:00
|
|
|
sscanf( data, "%X", &enabledLayers );
|
2009-10-10 01:25:53 +00:00
|
|
|
|
|
|
|
// Setup layer visibility
|
2012-02-06 07:14:51 +00:00
|
|
|
GetBoard()->SetEnabledLayers( enabledLayers );
|
|
|
|
GetBoard()->SetVisibleLayers( enabledLayers );
|
2009-10-10 01:25:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
if( strncmp( data, "Ly", 2 ) == 0 ) // Old format for Layer count
|
|
|
|
{
|
|
|
|
int Masque_Layer = 1, ii;
|
2011-10-20 14:46:06 +00:00
|
|
|
|
|
|
|
data = strtok( NULL, delims );
|
2007-08-06 02:02:39 +00:00
|
|
|
sscanf( data, "%X", &Masque_Layer );
|
|
|
|
|
|
|
|
// Setup layer count
|
2009-10-28 11:48:47 +00:00
|
|
|
int layer_count = 0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
for( ii = 0; ii < NB_COPPER_LAYERS; ii++ )
|
|
|
|
{
|
|
|
|
if( Masque_Layer & 1 )
|
2009-10-28 11:48:47 +00:00
|
|
|
layer_count++;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
Masque_Layer >>= 1;
|
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
GetBoard()->SetCopperLayerCount( layer_count );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( stricmp( data, "BoardThickness" ) == 0 )
|
2009-06-19 20:13:22 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
GetBoard()->GetDesignSettings().m_BoardThickness = atoi( data );
|
2009-06-19 20:13:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
if( strnicmp( data, "Links", 5 ) == 0 )
|
|
|
|
{
|
2009-05-28 08:42:24 +00:00
|
|
|
// Info only, do nothing
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( data, "NoConn", 6 ) == 0 )
|
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_NbNoconnect = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( data, "Di", 2 ) == 0 )
|
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
int x1 = atoi( data );
|
2011-10-20 14:46:06 +00:00
|
|
|
|
|
|
|
data = strtok( NULL, delims );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
int y1 = atoi( data );
|
2011-10-20 14:46:06 +00:00
|
|
|
|
|
|
|
data = strtok( NULL, delims );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
int x2 = atoi( data );
|
2011-10-20 14:46:06 +00:00
|
|
|
|
|
|
|
data = strtok( NULL, delims );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
int y2 = atoi( data );
|
|
|
|
|
2011-12-05 17:22:19 +00:00
|
|
|
EDA_RECT bbbox( wxPoint( x1, y1 ), wxSize( x2-x1, y2-y1 ) );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
|
|
|
GetBoard()->SetBoundingBox( bbbox );
|
2011-10-20 14:46:06 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
// Read the number of segments of type DRAW, TRACK, ZONE
|
2007-08-06 02:02:39 +00:00
|
|
|
if( stricmp( data, "Ndraw" ) == 0 )
|
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2011-03-03 19:08:13 +00:00
|
|
|
NbDraw = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( data, "Ntrack" ) == 0 )
|
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2007-08-06 02:02:39 +00:00
|
|
|
NbTrack = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( data, "Nzone" ) == 0 )
|
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2007-08-06 02:02:39 +00:00
|
|
|
NbZone = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( data, "Nmodule" ) == 0 )
|
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2007-08-06 02:02:39 +00:00
|
|
|
NbMod = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( stricmp( data, "Nnets" ) == 0 )
|
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2007-08-06 02:02:39 +00:00
|
|
|
NbNets = atoi( data );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
char* data;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
NETCLASS* netclass_default = GetBoard()->m_NetClasses.GetDefault();
|
2012-02-06 05:44:19 +00:00
|
|
|
ZONE_SETTINGS zoneInfo = GetBoard()->GetZoneSettings();
|
2012-02-19 04:02:19 +00:00
|
|
|
BOARD_DESIGN_SETTINGS bds = GetBoard()->GetDesignSettings();
|
2009-10-21 19:16:25 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
while( aReader->ReadLine() )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
char* line = aReader->Line();
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "PcbPlotParams", 13 ) == 0 )
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
PCB_PLOT_PARAMS_PARSER parser( &line[13], aReader->GetSource() );
|
2011-01-28 22:54:16 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
g_PcbPlotOptions.Parse( &parser );
|
|
|
|
}
|
|
|
|
catch( IO_ERROR& e )
|
|
|
|
{
|
|
|
|
wxString msg;
|
2011-02-27 05:43:19 +00:00
|
|
|
msg.Printf( _( "Error reading PcbPlotParams from %s:\n%s" ),
|
2011-01-28 22:54:16 +00:00
|
|
|
aReader->GetSource().GetData(),
|
|
|
|
e.errorText.GetData() );
|
2011-12-22 08:07:50 +00:00
|
|
|
wxMessageBox( msg, _( "Open Board File" ), wxOK | wxICON_ERROR );
|
2011-01-28 22:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
strtok( line, delims );
|
|
|
|
data = strtok( NULL, delims );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "$EndSETUP" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
// Until such time as the *.brd file does not have the
|
|
|
|
// global parameters:
|
|
|
|
// "TrackWidth", "TrackMinWidth", "ViaSize", "ViaDrill",
|
|
|
|
// "ViaMinSize", and "TrackClearence", put those same global
|
|
|
|
// values into the default NETCLASS until later board load
|
|
|
|
// code should override them. *.brd files which have been
|
|
|
|
// saved with knowledge of NETCLASSes will override these
|
|
|
|
// defaults, old boards will not.
|
|
|
|
//
|
2009-09-10 15:22:26 +00:00
|
|
|
// @todo: I expect that at some point we can remove said global
|
2009-11-14 22:15:22 +00:00
|
|
|
// parameters from the *.brd file since the ones in the
|
|
|
|
// default netclass serve the same purpose. If needed
|
|
|
|
// at all, the global defaults should go into a preferences
|
|
|
|
// file instead so they are there to start new board
|
|
|
|
// projects.
|
2009-09-10 15:22:26 +00:00
|
|
|
GetBoard()->m_NetClasses.GetDefault()->SetParams();
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
GetBoard()->SetZoneSettings( zoneInfo );
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "AuxiliaryAxisOrg" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
int gx = 0, gy = 0;
|
|
|
|
gx = atoi( data );
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
if( data )
|
|
|
|
gy = atoi( data );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
SetOriginAxisPosition( wxPoint( gx, gy ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifdef PCBNEW
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "Layers" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
int tmp;
|
|
|
|
sscanf( data, "%d", &tmp );
|
2010-01-31 20:01:46 +00:00
|
|
|
GetBoard()->SetCopperLayerCount( tmp );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
const int LAYERKEYZ = sizeof("Layer[") - 1;
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strncmp( line, "Layer[", LAYERKEYZ ) == 0 )
|
2008-03-01 13:15:41 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
// parse:
|
2008-03-04 14:27:48 +00:00
|
|
|
// Layer[n] <a_Layer_name_with_no_spaces> <LAYER_T>
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
char* cp = line + LAYERKEYZ;
|
2009-11-14 22:15:22 +00:00
|
|
|
int layer = atoi( cp );
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
if( data )
|
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
wxString layerName = FROM_UTF8( data );
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->SetLayerName( layer, layerName );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-01-27 14:33:48 +00:00
|
|
|
data = strtok( NULL, " \n\r" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
if( data )
|
|
|
|
{
|
|
|
|
LAYER_T type = LAYER::ParseType( data );
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->SetLayerType( layer, type );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-01 13:15:41 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "TrackWidth" ) == 0 ) // no more used
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "TrackWidthList" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-11-24 17:32:51 +00:00
|
|
|
int tmp = atoi( data );
|
|
|
|
GetBoard()->m_TrackWidthList.push_back( tmp );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "TrackClearence" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-11-24 17:32:51 +00:00
|
|
|
netclass_default->SetClearance( atoi( data ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "TrackMinWidth" ) == 0 )
|
2009-06-18 13:30:52 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_TrackMinWidth = atoi( data );
|
2009-06-18 13:30:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "ZoneClearence" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-06 05:44:19 +00:00
|
|
|
zoneInfo.m_ZoneClearance = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "DrawSegmWidth" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_DrawSegmentWidth = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "EdgeSegmWidth" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_EdgeSegmentWidth = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "ViaSize" ) == 0 ) // no more used
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "ViaMinSize" ) == 0 )
|
2009-06-18 13:30:52 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_ViasMinSize = atoi( data );
|
2009-06-18 13:30:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-07-18 11:44:19 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "MicroViaSize" ) == 0 ) // Not used
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "MicroViaMinSize" ) == 0 )
|
2009-06-18 13:30:52 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_MicroViasMinSize = atoi( data );
|
2009-06-18 13:30:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "ViaSizeList" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-11-24 17:32:51 +00:00
|
|
|
int tmp = atoi( data );
|
2009-10-30 17:58:15 +00:00
|
|
|
VIA_DIMENSION via_dim;
|
2011-11-24 17:32:51 +00:00
|
|
|
via_dim.m_Diameter = tmp;
|
2009-10-30 17:58:15 +00:00
|
|
|
data = strtok( NULL, " \n\r" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
if( data )
|
|
|
|
{
|
2011-11-24 17:32:51 +00:00
|
|
|
tmp = atoi( data );
|
|
|
|
via_dim.m_Drill = tmp > 0 ? tmp : 0;
|
2009-10-30 17:58:15 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
GetBoard()->m_ViasDimensionsList.push_back( via_dim );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "ViaDrill" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-11-24 17:32:51 +00:00
|
|
|
int diameter = atoi( data );
|
|
|
|
netclass_default->SetViaDrill( diameter );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "ViaMinDrill" ) == 0 )
|
2009-10-21 19:16:25 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_ViasMinDrill = atoi( data );
|
2009-10-21 19:16:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "MicroViaDrill" ) == 0 )
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2011-11-24 17:32:51 +00:00
|
|
|
int diameter = atoi( data );
|
|
|
|
netclass_default->SetuViaDrill( diameter );
|
2009-10-21 19:16:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "MicroViaMinDrill" ) == 0 )
|
2009-10-21 19:16:25 +00:00
|
|
|
{
|
2011-11-24 17:32:51 +00:00
|
|
|
int diameter = atoi( data );
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_MicroViasMinDrill = diameter;
|
2008-01-12 20:31:56 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "MicroViasAllowed" ) == 0 )
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_MicroViasAllowed = atoi( data );
|
2008-01-12 20:31:56 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "TextPcbWidth" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_PcbTextWidth = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "TextPcbSize" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_PcbTextSize.x = atoi( data );
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_PcbTextSize.y = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "EdgeModWidth" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_ModuleSegmentWidth = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "TextModWidth" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_ModuleTextWidth = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "TextModSize" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_ModuleTextSize.x = atoi( data );
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_ModuleTextSize.y = atoi( data );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "PadSize" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
int x = atoi( data );
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2012-02-19 04:02:19 +00:00
|
|
|
int y = atoi( data );
|
|
|
|
bds.m_Pad_Master.SetSize( wxSize( x, y ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "PadDrill" ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
int sz = atoi( data );
|
|
|
|
bds.m_Pad_Master.SetSize( wxSize( sz, sz ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "Pad2MaskClearance" ) == 0 )
|
2009-10-06 13:19:40 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_SolderMaskMargin = atoi( data );
|
2009-10-06 13:19:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "Pad2PasteClearance" ) == 0 )
|
2009-11-04 19:08:08 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_SolderPasteMargin = atoi( data );
|
2009-11-04 19:08:08 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "Pad2PasteClearanceRatio" ) == 0 )
|
2009-11-04 19:08:08 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_SolderPasteMarginRatio = atof( data );
|
2009-11-04 19:08:08 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( stricmp( line, "GridOrigin" ) == 0 )
|
2011-01-14 07:49:16 +00:00
|
|
|
{
|
|
|
|
int Ox = 0;
|
|
|
|
int Oy = 0;
|
|
|
|
|
|
|
|
Ox = atoi( data );
|
2011-10-20 14:46:06 +00:00
|
|
|
data = strtok( NULL, delims );
|
2011-01-14 07:49:16 +00:00
|
|
|
|
|
|
|
if ( data )
|
|
|
|
Oy = atoi( data );
|
|
|
|
|
|
|
|
GetScreen()->m_GridOrigin.x = Ox;
|
|
|
|
GetScreen()->m_GridOrigin.y = Oy;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 13:19:40 +00:00
|
|
|
/* Ensure tracks and vias sizes lists are ok:
|
|
|
|
* Sort lists by by increasing value and remove duplicates
|
|
|
|
* (the first value is not tested, because it is the netclass value
|
2009-11-14 22:15:22 +00:00
|
|
|
*/
|
2011-09-07 19:41:04 +00:00
|
|
|
sort( GetBoard()->m_ViasDimensionsList.begin() + 1, GetBoard()->m_ViasDimensionsList.end() );
|
|
|
|
sort( GetBoard()->m_TrackWidthList.begin() + 1, GetBoard()->m_TrackWidthList.end() );
|
|
|
|
|
|
|
|
for( unsigned ii = 1; ii < GetBoard()->m_ViasDimensionsList.size() - 1; ii++ )
|
2009-10-06 13:19:40 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
if( GetBoard()->m_ViasDimensionsList[ii] == GetBoard()->m_ViasDimensionsList[ii + 1] )
|
2009-10-06 13:19:40 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
GetBoard()->m_ViasDimensionsList.erase( GetBoard()->m_ViasDimensionsList.begin() + ii );
|
2009-10-06 13:19:40 +00:00
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 1; ii < GetBoard()->m_TrackWidthList.size() - 1; ii++ )
|
2009-10-06 13:19:40 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
if( GetBoard()->m_TrackWidthList[ii] == GetBoard()->m_TrackWidthList[ii + 1] )
|
2009-10-06 13:19:40 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
GetBoard()->m_TrackWidthList.erase( GetBoard()->m_TrackWidthList.begin() + ii );
|
2009-10-06 13:19:40 +00:00
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef PCBNEW
|
2011-09-24 18:33:28 +00:00
|
|
|
|
|
|
|
static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
const BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
|
2010-01-31 20:01:46 +00:00
|
|
|
NETCLASS* netclass_default = aBoard->m_NetClasses.GetDefault();
|
2009-11-14 22:15:22 +00:00
|
|
|
char text[1024];
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2008-03-01 13:15:41 +00:00
|
|
|
fprintf( aFile, "$SETUP\n" );
|
2007-08-06 02:02:39 +00:00
|
|
|
sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
|
2009-10-05 04:22:27 +00:00
|
|
|
fprintf( aFile, "%s", text );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2008-03-01 13:15:41 +00:00
|
|
|
fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() );
|
2008-05-01 06:21:07 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
unsigned layerMask = g_TabAllCopperLayerMask[aBoard->GetCopperLayerCount() - 1];
|
2008-05-01 06:21:07 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
for( int layer = 0; layerMask; ++layer, layerMask >>= 1 )
|
2008-03-01 13:15:41 +00:00
|
|
|
{
|
2008-05-01 06:21:07 +00:00
|
|
|
if( layerMask & 1 )
|
|
|
|
{
|
|
|
|
fprintf( aFile, "Layer[%d] %s %s\n", layer,
|
2011-02-28 18:36:19 +00:00
|
|
|
TO_UTF8( aBoard->GetLayerName( layer ) ),
|
2009-11-14 22:15:22 +00:00
|
|
|
LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
|
2008-05-01 06:21:07 +00:00
|
|
|
}
|
2008-03-01 13:15:41 +00:00
|
|
|
}
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Save current default track width, for compatibility with older Pcbnew version;
|
2009-10-30 17:58:15 +00:00
|
|
|
fprintf( aFile, "TrackWidth %d\n", aBoard->GetCurrentTrackWidth() );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
// Save custom tracks width list (the first is not saved here: this is the netclass value
|
2009-10-06 13:19:40 +00:00
|
|
|
for( unsigned ii = 1; ii < aBoard->m_TrackWidthList.size(); ii++ )
|
2011-11-24 17:32:51 +00:00
|
|
|
fprintf( aFile, "TrackWidthList %d\n", aBoard->m_TrackWidthList[ii] );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-06-19 20:13:22 +00:00
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() );
|
2012-02-06 05:44:19 +00:00
|
|
|
fprintf( aFile, "ZoneClearence %d\n", aBoard->GetZoneSettings().m_ZoneClearance );
|
2012-02-19 04:02:19 +00:00
|
|
|
fprintf( aFile, "TrackMinWidth %d\n", bds.m_TrackMinWidth );
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
fprintf( aFile, "DrawSegmWidth %d\n", bds.m_DrawSegmentWidth );
|
|
|
|
fprintf( aFile, "EdgeSegmWidth %d\n", bds.m_EdgeSegmentWidth );
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Save current default via size, for compatibility with older Pcbnew version;
|
2011-11-24 17:32:51 +00:00
|
|
|
fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() );
|
|
|
|
fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() );
|
2012-02-19 04:02:19 +00:00
|
|
|
fprintf( aFile, "ViaMinSize %d\n", bds.m_ViasMinSize );
|
|
|
|
fprintf( aFile, "ViaMinDrill %d\n", bds.m_ViasMinDrill );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Save custom vias diameters list (the first is not saved here: this is
|
|
|
|
// the netclass value
|
2009-10-30 17:58:15 +00:00
|
|
|
for( unsigned ii = 1; ii < aBoard->m_ViasDimensionsList.size(); ii++ )
|
2011-11-24 17:32:51 +00:00
|
|
|
fprintf( aFile, "ViaSizeList %d %d\n",
|
|
|
|
aBoard->m_ViasDimensionsList[ii].m_Diameter,
|
|
|
|
aBoard->m_ViasDimensionsList[ii].m_Drill );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
// for old versions compatibility:
|
2011-11-24 17:32:51 +00:00
|
|
|
fprintf( aFile, "MicroViaSize %d\n", netclass_default->GetuViaDiameter() );
|
|
|
|
fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill() );
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile,
|
|
|
|
"MicroViasAllowed %d\n",
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_MicroViasAllowed );
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile,
|
2011-11-24 17:32:51 +00:00
|
|
|
"MicroViaMinSize %d\n",
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_MicroViasMinSize );
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile,
|
2011-11-24 17:32:51 +00:00
|
|
|
"MicroViaMinDrill %d\n",
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_MicroViasMinDrill );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
fprintf( aFile, "TextPcbWidth %d\n", bds.m_PcbTextWidth );
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile,
|
|
|
|
"TextPcbSize %d %d\n",
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_PcbTextSize.x,
|
|
|
|
bds.m_PcbTextSize.y );
|
|
|
|
|
|
|
|
fprintf( aFile, "EdgeModWidth %d\n", bds.m_ModuleSegmentWidth );
|
|
|
|
fprintf( aFile, "TextModSize %d %d\n", bds.m_ModuleTextSize.x, bds.m_ModuleTextSize.y );
|
|
|
|
fprintf( aFile, "TextModWidth %d\n", bds.m_ModuleTextWidth );
|
|
|
|
|
|
|
|
fprintf( aFile, "PadSize %d %d\n", bds.m_Pad_Master.GetSize().x,
|
|
|
|
bds.m_Pad_Master.GetSize().y );
|
|
|
|
|
|
|
|
fprintf( aFile, "PadDrill %d\n", bds.m_Pad_Master.GetDrillSize().x );
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile,
|
|
|
|
"Pad2MaskClearance %d\n",
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_SolderMaskMargin );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( bds.m_SolderPasteMargin != 0 )
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile,
|
|
|
|
"Pad2PasteClearance %d\n",
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_SolderPasteMargin );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( bds.m_SolderPasteMarginRatio != 0 )
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile,
|
|
|
|
"Pad2PasteClearanceRatio %g\n",
|
2012-02-19 04:02:19 +00:00
|
|
|
bds.m_SolderPasteMarginRatio );
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2011-01-14 07:49:16 +00:00
|
|
|
if ( aFrame->GetScreen()->m_GridOrigin != wxPoint( 0, 0 ) )
|
|
|
|
{
|
|
|
|
fprintf( aFile,
|
|
|
|
"GridOrigin %d %d\n",
|
|
|
|
aFrame->GetScreen()->m_GridOrigin.x,
|
|
|
|
aFrame->GetScreen()->m_GridOrigin.y );
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
fprintf( aFile,
|
|
|
|
"AuxiliaryAxisOrg %d %d\n",
|
2011-12-14 20:03:15 +00:00
|
|
|
aFrame->GetOriginAxisPosition().x,
|
|
|
|
aFrame->GetOriginAxisPosition().y );
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
STRING_FORMATTER sf;
|
|
|
|
|
|
|
|
g_PcbPlotOptions.Format( &sf, 0 );
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
wxString record = FROM_UTF8( sf.GetString().c_str() );
|
2011-01-28 22:54:16 +00:00
|
|
|
record.Replace( wxT("\n"), wxT(""), true );
|
|
|
|
record.Replace( wxT(" "), wxT(" "), true);
|
2011-02-28 18:36:19 +00:00
|
|
|
fprintf( aFile, "PcbPlotParams %s\n", TO_UTF8( record ) );
|
2008-03-01 13:15:41 +00:00
|
|
|
fprintf( aFile, "$EndSETUP\n\n" );
|
2007-08-06 02:02:39 +00:00
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* PtStruct = GetBoard()->m_Modules;
|
|
|
|
int NbModules, NbDrawItem, NbLayers;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Write copper layer count
|
2010-01-31 20:01:46 +00:00
|
|
|
NbLayers = GetBoard()->GetCopperLayerCount();
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "$GENERAL\n" );
|
2011-02-28 18:36:19 +00:00
|
|
|
fprintf( File, "encoding utf-8\n");
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "LayerCount %d\n", NbLayers );
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Write old format for Layer count (for compatibility with old versions of
|
|
|
|
// pcbnew
|
|
|
|
fprintf( File,
|
|
|
|
"Ly %8X\n",
|
|
|
|
g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS );
|
2009-10-18 23:22:26 +00:00
|
|
|
fprintf( File, "EnabledLayers %08X\n", GetBoard()->GetEnabledLayers() );
|
2009-05-28 08:42:24 +00:00
|
|
|
fprintf( File, "Links %d\n", GetBoard()->GetRatsnestsCount() );
|
2009-01-05 05:21:35 +00:00
|
|
|
fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Write board's bounding box info
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
EDA_RECT bbbox = GetBoard()->ComputeBoundingBox();
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "Di %d %d %d %d\n",
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
bbbox.GetX(),
|
|
|
|
bbbox.GetY(),
|
|
|
|
bbbox.GetRight(),
|
|
|
|
bbbox.GetBottom() );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Write segment count for footprints, drawings, track and zones
|
|
|
|
// Calculate the footprint count
|
2008-11-24 06:53:43 +00:00
|
|
|
for( NbModules = 0; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
2007-12-03 06:54:19 +00:00
|
|
|
NbModules++;
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
PtStruct = GetBoard()->m_Drawings; NbDrawItem = 0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
2007-08-06 02:02:39 +00:00
|
|
|
NbDrawItem++;
|
|
|
|
|
|
|
|
fprintf( File, "Ndraw %d\n", NbDrawItem );
|
2009-01-05 05:21:35 +00:00
|
|
|
fprintf( File, "Ntrack %d\n", GetBoard()->GetNumSegmTrack() );
|
|
|
|
fprintf( File, "Nzone %d\n", GetBoard()->GetNumSegmZone() );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
fprintf( File, "BoardThickness %d\n", GetBoard()->GetDesignSettings().m_BoardThickness );
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "Nmodule %d\n", NbModules );
|
2011-12-10 05:33:24 +00:00
|
|
|
fprintf( File, "Nnets %d\n", GetBoard()->GetNetCount() );
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "$EndGENERAL\n\n" );
|
2011-09-07 19:41:04 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function WriteSheetDescr
|
2009-11-14 22:15:22 +00:00
|
|
|
* Save the page information (size, texts, date ..)
|
|
|
|
* @param screen BASE_SCREEN to save
|
|
|
|
* @param File = an open FILE to write info
|
|
|
|
*/
|
2012-01-09 08:35:06 +00:00
|
|
|
static bool WriteSheetDescr( const PAGE_INFO& aPageSettings, const TITLE_BLOCK& aTitleBlock, FILE* File )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
fprintf( File, "$SHEETDESCR\n" );
|
2012-01-16 04:11:43 +00:00
|
|
|
fprintf( File, "Sheet %s %d %d%s\n",
|
2011-12-22 21:57:50 +00:00
|
|
|
TO_UTF8( aPageSettings.GetType() ),
|
2012-01-16 05:17:23 +00:00
|
|
|
aPageSettings.GetWidthMils(),
|
|
|
|
aPageSettings.GetHeightMils(),
|
|
|
|
!aPageSettings.IsCustom() && aPageSettings.IsPortrait() ?
|
2012-01-16 04:11:43 +00:00
|
|
|
" portrait" : ""
|
|
|
|
);
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
fprintf( File, "Title %s\n", EscapedUTF8( aTitleBlock.GetTitle() ).c_str() );
|
|
|
|
fprintf( File, "Date %s\n", EscapedUTF8( aTitleBlock.GetDate() ).c_str() );
|
|
|
|
fprintf( File, "Rev %s\n", EscapedUTF8( aTitleBlock.GetRevision() ).c_str() );
|
|
|
|
fprintf( File, "Comp %s\n", EscapedUTF8( aTitleBlock.GetCompany() ).c_str() );
|
|
|
|
fprintf( File, "Comment1 %s\n", EscapedUTF8( aTitleBlock.GetComment1() ).c_str() );
|
|
|
|
fprintf( File, "Comment2 %s\n", EscapedUTF8( aTitleBlock.GetComment2() ).c_str() );
|
|
|
|
fprintf( File, "Comment3 %s\n", EscapedUTF8( aTitleBlock.GetComment3() ).c_str() );
|
|
|
|
fprintf( File, "Comment4 %s\n", EscapedUTF8( aTitleBlock.GetComment4() ).c_str() );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
fprintf( File, "$EndSHEETDESCR\n\n" );
|
2011-09-07 19:41:04 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
#if !defined( USE_NEW_PCBNEW_LOAD )
|
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
static bool ReadSheetDescr( BOARD* aBoard, LINE_READER* aReader )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-01-09 08:35:06 +00:00
|
|
|
char buf[1024];
|
|
|
|
TITLE_BLOCK tb;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
while( aReader->ReadLine() )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
char* line = aReader->Line();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "$End", 4 ) == 0 )
|
2012-01-09 08:35:06 +00:00
|
|
|
{
|
|
|
|
aBoard->SetTitleBlock( tb );
|
2011-09-07 19:41:04 +00:00
|
|
|
return true;
|
2012-01-09 08:35:06 +00:00
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Sheet", 4 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-12-22 21:57:50 +00:00
|
|
|
// e.g. "Sheet A3 16535 11700"
|
|
|
|
// width and height are in 1/1000th of an inch, always
|
|
|
|
|
|
|
|
PAGE_INFO page;
|
|
|
|
char* sname = strtok( line + SZ( "Sheet" ), delims );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
if( sname )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-12-22 21:57:50 +00:00
|
|
|
wxString wname = FROM_UTF8( sname );
|
|
|
|
if( !page.SetType( wname ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2012-01-05 16:30:58 +00:00
|
|
|
/* this entire file is soon to be deleted.
|
2011-12-22 21:57:50 +00:00
|
|
|
m_error.Printf( _( "Unknown sheet type '%s' on line:%d" ),
|
|
|
|
wname.GetData(), m_reader->LineNumber() );
|
|
|
|
THROW_IO_ERROR( m_error );
|
2012-01-05 16:30:58 +00:00
|
|
|
*/
|
2011-12-22 21:57:50 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-01-16 04:11:43 +00:00
|
|
|
char* width = strtok( NULL, delims );
|
|
|
|
char* height = strtok( NULL, delims );
|
|
|
|
char* orient = strtok( NULL, delims );
|
|
|
|
|
|
|
|
// only keep width and height if page size is "User"
|
2012-01-16 05:17:23 +00:00
|
|
|
if( wname == PAGE_INFO::Custom )
|
2011-12-22 21:57:50 +00:00
|
|
|
{
|
|
|
|
if( width && height )
|
|
|
|
{
|
|
|
|
// legacy disk file describes paper in mils
|
|
|
|
// (1/1000th of an inch)
|
2012-01-05 16:30:58 +00:00
|
|
|
int w = atoi( width );
|
|
|
|
int h = atoi( height );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-01-05 16:30:58 +00:00
|
|
|
page.SetWidthMils( w );
|
|
|
|
page.SetHeightMils( h );
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-01-16 04:11:43 +00:00
|
|
|
if( orient && !strcmp( orient, "portrait" ) )
|
|
|
|
{
|
|
|
|
page.SetPortrait( true );
|
|
|
|
}
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
aBoard->SetPageSettings( page );
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Title", 2 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
ReadDelimitedText( buf, line, 256 );
|
2012-01-09 08:35:06 +00:00
|
|
|
tb.SetTitle( FROM_UTF8( buf ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Date", 2 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
ReadDelimitedText( buf, line, 256 );
|
2012-01-09 08:35:06 +00:00
|
|
|
tb.SetDate( FROM_UTF8( buf ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Rev", 2 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
ReadDelimitedText( buf, line, 256 );
|
2012-01-09 08:35:06 +00:00
|
|
|
tb.SetRevision( FROM_UTF8( buf ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Comp", 4 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
ReadDelimitedText( buf, line, 256 );
|
2012-01-09 08:35:06 +00:00
|
|
|
tb.SetCompany( FROM_UTF8( buf ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Comment1", 8 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
ReadDelimitedText( buf, line, 256 );
|
2012-01-09 08:35:06 +00:00
|
|
|
tb.SetComment1( FROM_UTF8( buf ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Comment2", 8 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
ReadDelimitedText( buf, line, 256 );
|
2012-01-09 08:35:06 +00:00
|
|
|
tb.SetComment2( FROM_UTF8( buf ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Comment3", 8 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
ReadDelimitedText( buf, line, 256 );
|
2012-01-09 08:35:06 +00:00
|
|
|
tb.SetComment3( FROM_UTF8( buf ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-10-20 14:46:06 +00:00
|
|
|
if( strnicmp( line, "Comment4", 8 ) == 0 )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
ReadDelimitedText( buf, line, 256 );
|
2012-01-09 08:35:06 +00:00
|
|
|
tb.SetComment4( FROM_UTF8( buf ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
wxBusyCursor dummy;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Switch the locale to standard C (needed to read floating point numbers
|
|
|
|
// like 1.3)
|
2009-08-17 02:59:38 +00:00
|
|
|
SetLocaleTo_C_standard();
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
BOARD* board = GetBoard();
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-08-17 02:59:38 +00:00
|
|
|
board->m_Status_Pcb = 0;
|
|
|
|
board->m_NetClasses.Clear();
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
// Put a dollar sign in front, and test for a specific length of characters
|
2009-11-14 22:15:22 +00:00
|
|
|
// The -1 is to omit the trailing \0 which is included in sizeof() on a
|
|
|
|
// string.
|
2011-10-20 14:46:06 +00:00
|
|
|
#define TESTLINE( x ) (strncmp( line, "$" x, sizeof("$" x) - 1 ) == 0)
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2011-01-14 17:43:30 +00:00
|
|
|
while( aReader->ReadLine() )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
char* line = aReader->Line();
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
// put the more frequent ones at the top
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "MODULE" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
MODULE* module = new MODULE( board );
|
|
|
|
board->Add( module, ADD_APPEND );
|
|
|
|
module->ReadDescr( aReader );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "DRAWSEGMENT" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
DRAWSEGMENT* dseg = new DRAWSEGMENT( board );
|
|
|
|
board->Add( dseg, ADD_APPEND );
|
|
|
|
dseg->ReadDrawSegmentDescr( aReader );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "EQUIPOT" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2009-08-17 02:59:38 +00:00
|
|
|
NETINFO_ITEM* net = new NETINFO_ITEM( board );
|
2011-12-10 05:33:24 +00:00
|
|
|
board->m_NetInfo.AppendNet( net );
|
2011-01-14 17:43:30 +00:00
|
|
|
net->ReadDescr( aReader );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "TEXTPCB" ) )
|
2009-07-18 11:44:19 +00:00
|
|
|
{
|
2009-09-10 15:22:26 +00:00
|
|
|
TEXTE_PCB* pcbtxt = new TEXTE_PCB( board );
|
|
|
|
board->Add( pcbtxt, ADD_APPEND );
|
2011-01-14 17:43:30 +00:00
|
|
|
pcbtxt->ReadTextePcbDescr( aReader );
|
2009-07-18 11:44:19 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "TRACK" ) )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
#ifdef PCBNEW
|
|
|
|
TRACK* insertBeforeMe = Append ? NULL : board->m_Track.GetFirst();
|
2011-10-01 19:24:27 +00:00
|
|
|
ReadListeSegmentDescr( aReader, insertBeforeMe, PCB_TRACE_T, NbTrack );
|
2009-09-10 15:22:26 +00:00
|
|
|
#endif
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2008-02-07 06:49:16 +00:00
|
|
|
continue;
|
2008-03-01 13:15:41 +00:00
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-11-30 21:15:56 +00:00
|
|
|
if( TESTLINE( "NCLASS" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2009-09-10 15:22:26 +00:00
|
|
|
// create an empty NETCLASS without a name.
|
|
|
|
NETCLASS* netclass = new NETCLASS( board, wxEmptyString );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
// fill it from the *.brd file, and establish its name.
|
2011-01-14 17:43:30 +00:00
|
|
|
netclass->ReadDescr( aReader );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( !board->m_NetClasses.Add( netclass ) )
|
|
|
|
{
|
|
|
|
// Must have been a name conflict, this is a bad board file.
|
|
|
|
// User may have done a hand edit to the file.
|
|
|
|
// Delete netclass if board could not take ownership of it.
|
|
|
|
delete netclass;
|
|
|
|
|
|
|
|
// @todo: throw an exception here, this is a bad board file.
|
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "CZONE_OUTLINE" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
ZONE_CONTAINER* zone_descr = new ZONE_CONTAINER( board );
|
2011-01-14 17:43:30 +00:00
|
|
|
zone_descr->ReadDescr( aReader );
|
2009-11-14 22:15:22 +00:00
|
|
|
if( zone_descr->GetNumCorners() > 2 ) // should always occur
|
|
|
|
board->Add( zone_descr );
|
|
|
|
else
|
|
|
|
delete zone_descr;
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "COTATION" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
DIMENSION* dim = new DIMENSION( board );
|
|
|
|
board->Add( dim, ADD_APPEND );
|
|
|
|
dim->ReadDimensionDescr( aReader );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-02-09 15:00:37 +00:00
|
|
|
if( TESTLINE( "PCB_TARGET" ) || TESTLINE( "MIREPCB" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
PCB_TARGET* t = new PCB_TARGET( board );
|
|
|
|
board->Add( t, ADD_APPEND );
|
|
|
|
t->ReadMirePcbDescr( aReader );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "ZONE" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifdef PCBNEW
|
2009-09-10 15:22:26 +00:00
|
|
|
SEGZONE* insertBeforeMe = Append ? NULL : board->m_Zone.GetFirst();
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
ReadListeSegmentDescr( aReader, insertBeforeMe, PCB_ZONE_T, NbZone );
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "GENERAL" ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
ReadGeneralDescrPcb( aReader );
|
2009-09-10 15:22:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "SHEETDESCR" ) )
|
|
|
|
{
|
2012-01-09 08:35:06 +00:00
|
|
|
ReadSheetDescr( board, aReader );
|
2007-08-06 02:02:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
if( TESTLINE( "SETUP" ) )
|
|
|
|
{
|
|
|
|
if( !Append )
|
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
ReadSetup( aReader );
|
2009-09-10 15:22:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
while( aReader->ReadLine() )
|
|
|
|
{
|
2011-10-20 14:46:06 +00:00
|
|
|
line = aReader->Line();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( TESTLINE( "EndSETUP" ) )
|
|
|
|
break;
|
2011-01-14 17:43:30 +00:00
|
|
|
}
|
2009-09-10 15:22:26 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( TESTLINE( "EndPCB" ) )
|
|
|
|
break;
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
SetLocaleTo_Default(); // revert to the current locale
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-10 05:47:13 +00:00
|
|
|
board->m_Status_Pcb = 0;
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2009-10-13 16:29:02 +00:00
|
|
|
// Build the net info list
|
2011-12-10 05:47:13 +00:00
|
|
|
board->BuildListOfNets();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
board->SynchronizeNetsAndNetClasses();
|
2009-10-13 16:29:02 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
SetStatusText( wxEmptyString );
|
2009-10-13 16:29:02 +00:00
|
|
|
BestZoom();
|
2007-08-06 02:02:39 +00:00
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2011-12-07 05:28:49 +00:00
|
|
|
#endif
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifdef PCBNEW
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Save the current PCB in ASCII format
|
|
|
|
* Returns
|
|
|
|
* 1 if OK
|
|
|
|
* 0 if error occurs saving file.
|
2007-08-06 02:02:39 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
bool rc;
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~CONNEXION_OK;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
wxBeginBusyCursor();
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Switch the locale to standard C (needed to print floating point numbers
|
|
|
|
// like 1.3)
|
2011-12-14 07:03:55 +00:00
|
|
|
LOCALE_IO toggle;
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Writing file header.
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", BOARD_FILE_VERSION,
|
2011-11-08 16:37:25 +00:00
|
|
|
TO_UTF8( DateAndTime() ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
fprintf( aFile, "# Created by Pcbnew%s\n\n", TO_UTF8( GetBuildVersion() ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-10-06 13:19:40 +00:00
|
|
|
GetBoard()->SynchronizeNetsAndNetClasses();
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2009-10-13 16:29:02 +00:00
|
|
|
// Select default Netclass before writing file.
|
|
|
|
// Useful to save default values in headers
|
2011-02-21 13:54:29 +00:00
|
|
|
GetBoard()->SetCurrentNetClass( GetBoard()->m_NetClasses.GetDefault()->GetName() );
|
2009-10-06 13:19:40 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
WriteGeneralDescrPcb( aFile );
|
2012-01-09 08:35:06 +00:00
|
|
|
WriteSheetDescr( GetBoard()->GetPageSettings(), GetBoard()->GetTitleBlock(), aFile );
|
2009-01-05 05:21:35 +00:00
|
|
|
WriteSetup( aFile, this, GetBoard() );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
rc = GetBoard()->Save( aFile );
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
wxEndBusyCursor();
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
if( !rc )
|
|
|
|
DisplayError( this, wxT( "Unable to save PCB file" ) );
|
|
|
|
else
|
2011-02-11 20:48:13 +00:00
|
|
|
SetStatusText( wxEmptyString );
|
2008-03-01 13:15:41 +00:00
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
return rc;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
#endif
|