Commit b6dcf9b7 authored by Dick Hollenbeck's avatar Dick Hollenbeck

Collect all the PCBNew Save() and ReadDesc...() functions into new file item_io.cpp,

which should eventually go away in favor of kicad_plugin.cpp.
Add CMake options USE_NEW_PCBNEW_LOAD and USE_NEW_PCBNEW_SAVE, which should not be
used yet, and both default to OFF accordingly.
parents 539f4e1e c4979318
...@@ -22,6 +22,9 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) ...@@ -22,6 +22,9 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
option(USE_PNG_BITMAPS "use PNG bitmaps instead of XPM (default ON)" ON) option(USE_PNG_BITMAPS "use PNG bitmaps instead of XPM (default ON)" ON)
option(USE_NEW_PCBNEW_LOAD "use new plugin support for legacy file format (default OFF)" OFF)
option(USE_NEW_PCBNEW_SAVE "use new plugin support for legacy file format (default OFF)" OFF)
# Russian GOST patch # Russian GOST patch
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)") option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
option(KICAD_GOST "enable/disable building using GOST notation for multiple gates per package (default OFF)") option(KICAD_GOST "enable/disable building using GOST notation for multiple gates per package (default OFF)")
......
...@@ -54,4 +54,7 @@ ...@@ -54,4 +54,7 @@
#cmakedefine USE_PNG_BITMAPS 1 #cmakedefine USE_PNG_BITMAPS 1
#cmakedefine USE_NEW_PCBNEW_LOAD
#cmakedefine USE_NEW_PCBNEW_SAVE
#endif /* __CONFIG_H__ */ #endif /* __CONFIG_H__ */
...@@ -107,6 +107,14 @@ set(PCB_COMMON_SRCS ...@@ -107,6 +107,14 @@ set(PCB_COMMON_SRCS
../pcbnew/sel_layer.cpp ../pcbnew/sel_layer.cpp
) )
if ( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp ../pcbnew/io_mgr.cpp ../pcbnew/kicad_plugin.cpp )
else()
set( PCB_COMMON_SRCS ${PCB_COMMON_SRCS} ../pcbnew/item_io.cpp )
endif()
add_library(pcbcommon ${PCB_COMMON_SRCS}) add_library(pcbcommon ${PCB_COMMON_SRCS})
# auto-generate netlist_lexer.h and netlist_keywords.cpp # auto-generate netlist_lexer.h and netlist_keywords.cpp
......
...@@ -39,7 +39,8 @@ set(CVPCB_SRCS ...@@ -39,7 +39,8 @@ set(CVPCB_SRCS
savecmp.cpp savecmp.cpp
setvisu.cpp setvisu.cpp
tool_cvpcb.cpp tool_cvpcb.cpp
writenetlistpcbnew.cpp) writenetlistpcbnew.cpp
)
### ###
# Windows resource file # Windows resource file
......
...@@ -126,9 +126,7 @@ set(PCBNEW_SRCS ...@@ -126,9 +126,7 @@ set(PCBNEW_SRCS
hotkeys_board_editor.cpp hotkeys_board_editor.cpp
hotkeys_module_editor.cpp hotkeys_module_editor.cpp
initpcb.cpp initpcb.cpp
io_mgr.cpp
ioascii.cpp ioascii.cpp
kicad_plugin.cpp
layer_widget.cpp layer_widget.cpp
librairi.cpp librairi.cpp
loadcmp.cpp loadcmp.cpp
......
...@@ -1394,89 +1394,6 @@ int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCoun ...@@ -1394,89 +1394,6 @@ int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCoun
} }
bool BOARD::Save( FILE* aFile ) const
{
bool rc = false;
BOARD_ITEM* item;
// save the nets
for( unsigned ii = 0; ii < m_NetInfo->GetCount(); ii++ )
if( !m_NetInfo->GetNetItem( ii )->Save( aFile ) )
goto out;
// Saved nets do not include netclass names, so save netclasses after nets.
m_NetClasses.Save( aFile );
// save the modules
for( item = m_Modules; item; item = item->Next() )
if( !item->Save( aFile ) )
goto out;
for( item = m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_TEXT_T:
case PCB_LINE_T:
case PCB_TARGET_T:
case PCB_DIMENSION_T:
if( !item->Save( aFile ) )
goto out;
break;
default:
// future: throw exception here
#if defined(DEBUG)
printf( "BOARD::Save() ignoring m_Drawings type %d\n", item->Type() );
#endif
break;
}
}
// do not save MARKER_PCBs, they can be regenerated easily
// save the tracks & vias
fprintf( aFile, "$TRACK\n" );
for( item = m_Track; item; item = item->Next() )
{
if( !item->Save( aFile ) )
goto out;
}
fprintf( aFile, "$EndTRACK\n" );
// save the zones
fprintf( aFile, "$ZONE\n" );
for( item = m_Zone; item; item = item->Next() )
{
if( !item->Save( aFile ) )
goto out;
}
fprintf( aFile, "$EndZONE\n" );
// save the zone edges
for( unsigned ii = 0; ii < m_ZoneDescriptorList.size(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_ZoneDescriptorList[ii];
edge_zone->Save( aFile );
}
if( fprintf( aFile, "$EndBOARD\n" ) != sizeof("$EndBOARD\n") - 1 )
goto out;
rc = true; // wrote all OK
out:
return rc;
}
void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer ) void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer )
{ {
if( !aDC ) if( !aDC )
......
...@@ -105,137 +105,6 @@ void DIMENSION::Copy( DIMENSION* source ) ...@@ -105,137 +105,6 @@ void DIMENSION::Copy( DIMENSION* source )
} }
bool DIMENSION::ReadDimensionDescr( LINE_READER* aReader )
{
char* Line;
char Text[2048];
while( aReader->ReadLine() )
{
Line = aReader->Line();
if( strnicmp( Line, "$EndDIMENSION", 4 ) == 0 )
return true;
if( Line[0] == 'V' )
{
sscanf( Line + 2, " %d", &m_Value );
continue;
}
if( Line[0] == 'G' )
{
int layer;
sscanf( Line + 2, " %d %d %lX", &m_Shape, &layer, &m_TimeStamp );
if( layer < FIRST_NO_COPPER_LAYER )
layer = FIRST_NO_COPPER_LAYER;
if( layer > LAST_NO_COPPER_LAYER )
layer = LAST_NO_COPPER_LAYER;
SetLayer( layer );
m_Text->SetLayer( layer );
continue;
}
if( Line[0] == 'T' )
{
ReadDelimitedText( Text, Line + 2, sizeof(Text) );
m_Text->m_Text = FROM_UTF8( Text );
continue;
}
if( Line[0] == 'P' )
{
int normal_display = 1;
int orientation;
int thickness;
sscanf( Line + 2, " %d %d %d %d %d %d %d",
&m_Text->m_Pos.x, &m_Text->m_Pos.y,
&m_Text->m_Size.x, &m_Text->m_Size.y,
&thickness, &orientation,
&normal_display );
m_Text->m_Mirror = normal_display ? false : true;
m_Pos = m_Text->m_Pos;
m_Text->SetOrientation( orientation );
m_Text->SetThickness( thickness );
continue;
}
if( Line[0] == 'S' )
{
switch( Line[1] )
{
int Dummy;
case 'b':
sscanf( Line + 2, " %d %d %d %d %d %d",
&Dummy,
&m_crossBarOx, &m_crossBarOy,
&m_crossBarFx, &m_crossBarFy,
&m_Width );
break;
case 'd':
sscanf( Line + 2, " %d %d %d %d %d %d",
&Dummy,
&m_featureLineDOx, &m_featureLineDOy,
&m_featureLineDFx, &m_featureLineDFy,
&Dummy );
break;
case 'g':
sscanf( Line + 2, " %d %d %d %d %d %d",
&Dummy,
&m_featureLineGOx, &m_featureLineGOy,
&m_featureLineGFx, &m_featureLineGFy,
&Dummy );
break;
case '1':
sscanf( Line + 2, " %d %d %d %d %d %d",
&Dummy,
&m_arrowD1Ox, &m_arrowD1Oy,
&m_arrowD1Fx, &m_arrowD1Fy,
&Dummy );
break;
case '2':
sscanf( Line + 2, " %d %d %d %d %d %d",
&Dummy,
&m_arrowD2Ox, &m_arrowD2Oy,
&m_arrowD2Fx, &m_arrowD2Fy,
&Dummy );
break;
case '3':
sscanf( Line + 2, " %d %d %d %d %d %d\n",
&Dummy,
&m_arrowG1Ox, &m_arrowG1Oy,
&m_arrowG1Fx, &m_arrowG1Fy,
&Dummy );
break;
case '4':
sscanf( Line + 2, " %d %d %d %d %d %d",
&Dummy,
&m_arrowG2Ox, &m_arrowG2Oy,
&m_arrowG2Fx, &m_arrowG2Fy,
&Dummy );
break;
}
continue;
}
}
return false;
}
void DIMENSION::Move(const wxPoint& offset) void DIMENSION::Move(const wxPoint& offset)
{ {
m_Pos += offset; m_Pos += offset;
...@@ -344,72 +213,6 @@ void DIMENSION::Mirror(const wxPoint& axis_pos) ...@@ -344,72 +213,6 @@ void DIMENSION::Mirror(const wxPoint& axis_pos)
} }
bool DIMENSION::Save( FILE* aFile ) const
{
bool rc = false;
// note: COTATION was the previous name of DIMENSION
// this old keyword is used here for compatibility
const char keyWordLine[] = "$COTATION\n";
const char keyWordLineEnd[] = "$endCOTATION\n";
if( fputs( keyWordLine, aFile ) == EOF )
goto out;
fprintf( aFile, "Ge %d %d %lX\n", m_Shape, m_Layer, m_TimeStamp );
fprintf( aFile, "Va %d\n", m_Value );
if( !m_Text->m_Text.IsEmpty() )
fprintf( aFile, "Te %s\n", EscapedUTF8( m_Text->m_Text ).c_str() );
else
fprintf( aFile, "Te \"?\"\n" );
fprintf( aFile, "Po %d %d %d %d %d %d %d\n",
m_Text->m_Pos.x, m_Text->m_Pos.y,
m_Text->m_Size.x, m_Text->m_Size.y,
m_Text->GetThickness(), m_Text->GetOrientation(),
m_Text->m_Mirror ? 0 : 1 );
fprintf( aFile, "Sb %d %d %d %d %d %d\n", S_SEGMENT,
m_crossBarOx, m_crossBarOy,
m_crossBarFx, m_crossBarFy, m_Width );
fprintf( aFile, "Sd %d %d %d %d %d %d\n", S_SEGMENT,
m_featureLineDOx, m_featureLineDOy,
m_featureLineDFx, m_featureLineDFy, m_Width );
fprintf( aFile, "Sg %d %d %d %d %d %d\n", S_SEGMENT,
m_featureLineGOx, m_featureLineGOy,
m_featureLineGFx, m_featureLineGFy, m_Width );
fprintf( aFile, "S1 %d %d %d %d %d %d\n", S_SEGMENT,
m_arrowD1Ox, m_arrowD1Oy,
m_arrowD1Fx, m_arrowD1Fy, m_Width );
fprintf( aFile, "S2 %d %d %d %d %d %d\n", S_SEGMENT,
m_arrowD2Ox, m_arrowD2Oy,
m_arrowD2Fx, m_arrowD2Fy, m_Width );
fprintf( aFile, "S3 %d %d %d %d %d %d\n", S_SEGMENT,
m_arrowG1Ox, m_arrowG1Oy,
m_arrowG1Fx, m_arrowG1Fy, m_Width );
fprintf( aFile, "S4 %d %d %d %d %d %d\n", S_SEGMENT,
m_arrowG2Ox, m_arrowG2Oy,
m_arrowG2Fx, m_arrowG2Fy, m_Width );
if( fputs( keyWordLineEnd, aFile ) == EOF )
goto out;
rc = true;
out:
return rc;
}
void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
{ {
#define ARROW_SIZE 500 //size of arrows #define ARROW_SIZE 500 //size of arrows
......
...@@ -74,117 +74,6 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre ) ...@@ -74,117 +74,6 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre )
} }
bool DRAWSEGMENT::Save( FILE* aFile ) const
{
if( fprintf( aFile, "$DRAWSEGMENT\n" ) != sizeof("$DRAWSEGMENT\n") - 1 )
return false;
fprintf( aFile, "Po %d %d %d %d %d %d\n",
m_Shape,
m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Width );
if( m_Type != S_CURVE )
{
fprintf( aFile, "De %d %d %d %lX %X\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus() );
}
else
{
fprintf( aFile, "De %d %d %d %lX %X %d %d %d %d\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus(),
m_BezierC1.x,m_BezierC1.y,
m_BezierC2.x,m_BezierC2.y);
}
if( fprintf( aFile, "$EndDRAWSEGMENT\n" ) != sizeof("$EndDRAWSEGMENT\n") - 1 )
return false;
return true;
}
bool DRAWSEGMENT::ReadDrawSegmentDescr( LINE_READER* aReader )
{
char* Line;
while( aReader->ReadLine() )
{
Line = aReader->Line();
if( strnicmp( Line, "$End", 4 ) == 0 )
return true; /* End of description */
if( Line[0] == 'P' )
{
sscanf( Line + 2, " %d %d %d %d %d %d",
&m_Shape, &m_Start.x, &m_Start.y,
&m_End.x, &m_End.y, &m_Width );
if( m_Width < 0 )
m_Width = 0;
}
if( Line[0] == 'D' )
{
int status;
char* token = 0;
token = strtok( Line," " );
for( int i = 0; (token = strtok( NULL," " )) != NULL; i++ )
{
switch( i )
{
case 0:
sscanf( token,"%d",&m_Layer );
break;
case 1:
sscanf( token,"%d",&m_Type );
break;
case 2:
sscanf( token,"%d",&m_Angle );
break;
case 3:
sscanf( token,"%lX",&m_TimeStamp );
break;
case 4:
sscanf( token,"%X",&status );
break;
/* Bezier Control Points*/
case 5:
sscanf( token,"%d",&m_BezierC1.x );
break;
case 6:
sscanf( token,"%d",&m_BezierC1.y );
break;
case 7:
sscanf( token,"%d",&m_BezierC2.x );
break;
case 8:
sscanf( token,"%d",&m_BezierC2.y );
break;
default:
break;
}
}
if( m_Layer < FIRST_NO_COPPER_LAYER )
m_Layer = FIRST_NO_COPPER_LAYER;
if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER;
SetState( status, ON );
}
}
return false;
}
wxPoint DRAWSEGMENT::GetStart() const wxPoint DRAWSEGMENT::GetStart() const
{ {
switch( m_Shape ) switch( m_Shape )
......
...@@ -16,16 +16,11 @@ ...@@ -16,16 +16,11 @@
#include "wxBasePcbFrame.h" #include "wxBasePcbFrame.h"
#include "pcbcommon.h" #include "pcbcommon.h"
#include "pcbnew.h"
#include "class_board.h" #include "class_board.h"
#include "class_module.h" #include "class_module.h"
#include "class_edge_mod.h" #include "class_edge_mod.h"
#define MAX_WIDTH 10000 /* Thickness (in 1 / 10000 ") of maximum reasonable features, text... */
/*********************/ /*********************/
/* class EDGE_MODULE */ /* class EDGE_MODULE */
/*********************/ /*********************/
...@@ -238,185 +233,6 @@ void EDGE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -238,185 +233,6 @@ void EDGE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
} }
bool EDGE_MODULE::Save( FILE* aFile ) const
{
int ret = -1;
switch( m_Shape )
{
case S_SEGMENT:
ret = fprintf( aFile, "DS %d %d %d %d %d %d\n",
m_Start0.x, m_Start0.y,
m_End0.x, m_End0.y,
m_Width, m_Layer );
break;
case S_CIRCLE:
ret = fprintf( aFile, "DC %d %d %d %d %d %d\n",
m_Start0.x, m_Start0.y,
m_End0.x, m_End0.y,
m_Width, m_Layer );
break;
case S_ARC:
ret = fprintf( aFile, "DA %d %d %d %d %d %d %d\n",
m_Start0.x, m_Start0.y,
m_End0.x, m_End0.y,
m_Angle,
m_Width, m_Layer );
break;
case S_POLYGON:
ret = fprintf( aFile, "DP %d %d %d %d %d %d %d\n",
m_Start0.x, m_Start0.y,
m_End0.x, m_End0.y,
(int) m_PolyPoints.size(),
m_Width, m_Layer );
for( unsigned i = 0; i<m_PolyPoints.size(); ++i )
fprintf( aFile, "Dl %d %d\n", m_PolyPoints[i].x, m_PolyPoints[i].y );
break;
default:
// future: throw an exception here
#if defined(DEBUG)
printf( "EDGE_MODULE::Save(): unexpected m_Shape: %d\n", m_Shape );
#endif
break;
}
return ret > 5;
}
/* Read a description line like:
* DS 2600 0 2600 -600 120 21
* this description line is in Line
* EDGE_MODULE type can be:
* - Circle,
* - Segment (line)
* - Arc
* - Polygon
*
*/
int EDGE_MODULE::ReadDescr( LINE_READER* aReader )
{
int ii;
int error = 0;
char* Buf;
char* Line;
Line = aReader->Line();
switch( Line[1] )
{
case 'S':
m_Shape = S_SEGMENT;
break;
case 'C':
m_Shape = S_CIRCLE;
break;
case 'A':
m_Shape = S_ARC;
break;
case 'P':
m_Shape = S_POLYGON;
break;
default:
wxString msg;
msg.Printf( wxT( "Unknown EDGE_MODULE type <%s>" ), Line );
DisplayError( NULL, msg );
error = 1;
break;
}
switch( m_Shape )
{
case S_ARC:
sscanf( Line + 3, "%d %d %d %d %d %d %d",
&m_Start0.x, &m_Start0.y,
&m_End0.x, &m_End0.y,
&m_Angle, &m_Width, &m_Layer );
NORMALIZE_ANGLE_360( m_Angle );
break;
case S_SEGMENT:
case S_CIRCLE:
sscanf( Line + 3, "%d %d %d %d %d %d",
&m_Start0.x, &m_Start0.y,
&m_End0.x, &m_End0.y,
&m_Width, &m_Layer );
break;
case S_POLYGON:
int pointCount;
sscanf( Line + 3, "%d %d %d %d %d %d %d",
&m_Start0.x, &m_Start0.y,
&m_End0.x, &m_End0.y,
&pointCount, &m_Width, &m_Layer );
m_PolyPoints.clear();
m_PolyPoints.reserve( pointCount );
for( ii = 0; ii<pointCount; ii++ )
{
if( aReader->ReadLine() )
{
Buf = aReader->Line();
if( strncmp( Buf, "Dl", 2 ) != 0 )
{
error = 1;
break;
}
int x;
int y;
sscanf( Buf + 3, "%d %d\n", &x, &y );
m_PolyPoints.push_back( wxPoint( x, y ) );
}
else
{
error = 1;
break;
}
}
break;
default:
sscanf( Line + 3, "%d %d %d %d %d %d",
&m_Start0.x, &m_Start0.y,
&m_End0.x, &m_End0.y,
&m_Width, &m_Layer );
break;
}
// Check for a reasonable width:
if( m_Width <= 1 )
m_Width = 1;
if( m_Width > MAX_WIDTH )
m_Width = MAX_WIDTH;
// Check for a reasonable layer:
// m_Layer must be >= FIRST_NON_COPPER_LAYER, but because microwave footprints
// can use the copper layers m_Layer < FIRST_NON_COPPER_LAYER is allowed.
// @todo: changes use of EDGE_MODULE these footprints and allows only
// m_Layer >= FIRST_NON_COPPER_LAYER
if( (m_Layer < 0) || (m_Layer > LAST_NON_COPPER_LAYER) )
m_Layer = SILKSCREEN_N_FRONT;
return error;
}
wxString EDGE_MODULE::GetSelectMenuText() const wxString EDGE_MODULE::GetSelectMenuText() const
{ {
......
...@@ -54,62 +54,6 @@ void PCB_TARGET::Copy( PCB_TARGET* source ) ...@@ -54,62 +54,6 @@ void PCB_TARGET::Copy( PCB_TARGET* source )
} }
/* Read the description from the PCB file.
*/
bool PCB_TARGET::ReadMirePcbDescr( LINE_READER* aReader )
{
char* Line;
while( aReader->ReadLine() )
{
Line = aReader->Line();
if( strnicmp( Line, "$End", 4 ) == 0 )
return true;
if( Line[0] == 'P' )
{
sscanf( Line + 2, " %X %d %d %d %d %d %lX",
&m_Shape, &m_Layer,
&m_Pos.x, &m_Pos.y,
&m_Size, &m_Width, &m_TimeStamp );
if( m_Layer < FIRST_NO_COPPER_LAYER )
m_Layer = FIRST_NO_COPPER_LAYER;
if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER;
}
}
return false;
}
bool PCB_TARGET::Save( FILE* aFile ) const
{
bool rc = false;
if( fprintf( aFile, "$PCB_TARGET\n" ) != sizeof("$PCB_TARGET\n")-1 )
goto out;
fprintf( aFile, "Po %X %d %d %d %d %d %8.8lX\n",
m_Shape, m_Layer,
m_Pos.x, m_Pos.y,
m_Size, m_Width, m_TimeStamp );
if( fprintf( aFile, "$EndPCB_TARGET\n" ) != sizeof("$EndPCB_TARGET\n")-1 )
goto out;
rc = true;
out:
return rc;
}
/* Draw PCB_TARGET object: 2 segments + 1 circle /* Draw PCB_TARGET object: 2 segments + 1 circle
* The circle radius is half the radius of the target * The circle radius is half the radius of the target
* 2 lines have length the diameter of the target * 2 lines have length the diameter of the target
......
This diff is collapsed.
...@@ -259,59 +259,6 @@ void BOARD::SynchronizeNetsAndNetClasses() ...@@ -259,59 +259,6 @@ void BOARD::SynchronizeNetsAndNetClasses()
} }
bool NETCLASSES::Save( FILE* aFile ) const
{
bool result;
// save the default first.
result = m_Default.Save( aFile );
if( result )
{
// the rest will be alphabetical in the *.brd file.
for( const_iterator i = begin(); i!=end(); ++i )
{
NETCLASS* netclass = i->second;
result = netclass->Save( aFile );
if( !result )
break;
}
}
return result;
}
bool NETCLASS::Save( FILE* aFile ) const
{
bool result = true;
fprintf( aFile, "$NCLASS\n" );
fprintf( aFile, "Name %s\n", EscapedUTF8( m_Name ).c_str() );
fprintf( aFile, "Desc %s\n", EscapedUTF8( GetDescription() ).c_str() );
// Write parameters
fprintf( aFile, "Clearance %d\n", GetClearance() );
fprintf( aFile, "TrackWidth %d\n", GetTrackWidth() );
fprintf( aFile, "ViaDia %d\n", GetViaDiameter() );
fprintf( aFile, "ViaDrill %d\n", GetViaDrill() );
fprintf( aFile, "uViaDia %d\n", GetuViaDiameter() );
fprintf( aFile, "uViaDrill %d\n", GetuViaDrill() );
// Write members:
for( const_iterator i = begin(); i!=end(); ++i )
fprintf( aFile, "AddNet %s\n", EscapedUTF8( *i ).c_str() );
fprintf( aFile, "$EndNCLASS\n" );
return result;
}
#if defined(DEBUG) #if defined(DEBUG)
void NETCLASS::Show( int nestLevel, std::ostream& os ) void NETCLASS::Show( int nestLevel, std::ostream& os )
...@@ -333,80 +280,6 @@ void NETCLASS::Show( int nestLevel, std::ostream& os ) ...@@ -333,80 +280,6 @@ void NETCLASS::Show( int nestLevel, std::ostream& os )
#endif #endif
bool NETCLASS::ReadDescr( LINE_READER* aReader )
{
bool result = false;
char* line;
char buf[1024];
wxString netname;
while( aReader->ReadLine() )
{
line = aReader->Line();
if( strnicmp( line, "AddNet", 6 ) == 0 )
{
ReadDelimitedText( buf, line + 6, sizeof(buf) );
netname = FROM_UTF8( buf );
Add( netname );
continue;
}
if( strnicmp( line, "$endNCLASS", sizeof( "$endNCLASS" ) - 1 ) == 0 )
{
result = true;
break;
}
if( strnicmp( line, "Clearance", 9 ) == 0 )
{
SetClearance( atoi( line + 9 ) );
continue;
}
if( strnicmp( line, "TrackWidth", 10 ) == 0 )
{
SetTrackWidth( atoi( line + 10 ) );
continue;
}
if( strnicmp( line, "ViaDia", 6 ) == 0 )
{
SetViaDiameter( atoi( line + 6 ) );
continue;
}
if( strnicmp( line, "ViaDrill", 8 ) == 0 )
{
SetViaDrill( atoi( line + 8 ) );
continue;
}
if( strnicmp( line, "uViaDia", 7 ) == 0 )
{
SetuViaDiameter( atoi( line + 7 ) );
continue;
}
if( strnicmp( line, "uViaDrill", 9 ) == 0 )
{
SetuViaDrill( atoi( line + 9 ) );
continue;
}
if( strnicmp( line, "Name", 4 ) == 0 )
{
ReadDelimitedText( buf, line + 4, sizeof(buf) );
m_Name = FROM_UTF8( buf );
continue;
}
if( strnicmp( line, "Desc", 4 ) == 0 )
{
ReadDelimitedText( buf, line + 4, sizeof(buf) );
SetDescription( FROM_UTF8( buf ) );
continue;
}
}
return result;
}
int NETCLASS::GetTrackMinWidth() const int NETCLASS::GetTrackMinWidth() const
{ {
return m_Parent->GetDesignSettings().m_TrackMinWidth; return m_Parent->GetDesignSettings().m_TrackMinWidth;
......
...@@ -45,59 +45,6 @@ NETINFO_ITEM::~NETINFO_ITEM() ...@@ -45,59 +45,6 @@ NETINFO_ITEM::~NETINFO_ITEM()
} }
/* Read NETINFO_ITEM from file.
* Returns 0 if OK
* 1 if incomplete reading
*/
int NETINFO_ITEM::ReadDescr( LINE_READER* aReader )
{
char* Line;
char Ltmp[1024];
int tmp;
while( aReader->ReadLine() )
{
Line = aReader->Line();
if( strnicmp( Line, "$End", 4 ) == 0 )
return 0;
if( strncmp( Line, "Na", 2 ) == 0 )
{
sscanf( Line + 2, " %d", &tmp );
SetNet( tmp );
ReadDelimitedText( Ltmp, Line + 2, sizeof(Ltmp) );
m_Netname = FROM_UTF8( Ltmp );
continue;
}
}
return 1;
}
/** Note: the old name of class NETINFO_ITEM was EQUIPOT
* so in Save (and read) functions, for compatibility, we use EQUIPOT as
* keyword
*/
bool NETINFO_ITEM::Save( FILE* aFile ) const
{
bool success = false;
fprintf( aFile, "$EQUIPOT\n" );
fprintf( aFile, "Na %d %s\n", GetNet(), EscapedUTF8( m_Netname ).c_str() );
fprintf( aFile, "St %s\n", "~" );
if( fprintf( aFile, "$EndEQUIPOT\n" ) != sizeof("$EndEQUIPOT\n") - 1 )
goto out;
success = true;
out:
return success;
}
/** /**
* Function SetNetname * Function SetNetname
* @param aNetname : the new netname * @param aNetname : the new netname
......
...@@ -370,259 +370,6 @@ wxSize D_PAD::GetSolderPasteMargin() ...@@ -370,259 +370,6 @@ wxSize D_PAD::GetSolderPasteMargin()
} }
/* Read pad from file.
* The 1st line of descr ($PAD) is assumed to be already read
* Syntax:
* $PAD
* Sh "N1" C 550 550 0 0 1800
* Dr 310 0 0
* At STD N 00C0FFFF
* Do 3 "netname"
* Po 6000 -6000
* $EndPAD
*/
int D_PAD::ReadDescr( LINE_READER* aReader )
{
char* Line;
char BufLine[1024], BufCar[256];
char* PtLine;
int nn, ll, dx, dy;
while( aReader->ReadLine() )
{
Line = aReader->Line();
if( Line[0] == '$' )
return 0;
PtLine = Line + 3;
/* Decode the first code and read the corresponding data
*/
switch( Line[0] )
{
case 'S': // = Sh
/* Read pad name */
nn = 0;
while( (*PtLine != '"') && *PtLine )
PtLine++;
if( *PtLine )
PtLine++;
memset( m_Padname, 0, sizeof(m_Padname) );
while( (*PtLine != '"') && *PtLine )
{
if( nn < (int) sizeof(m_Padname) )
{
if( *PtLine > ' ' )
{
m_Padname[nn] = *PtLine; nn++;
}
}
PtLine++;
}
if( *PtLine == '"' )
PtLine++;
nn = sscanf( PtLine, " %s %d %d %d %d %d",
BufCar, &m_Size.x, &m_Size.y,
&m_DeltaSize.x, &m_DeltaSize.y,
&m_Orient );
ll = 0xFF & BufCar[0];
/* Read pad shape */
m_PadShape = PAD_CIRCLE;
switch( ll )
{
case 'C':
m_PadShape = PAD_CIRCLE; break;
case 'R':
m_PadShape = PAD_RECT; break;
case 'O':
m_PadShape = PAD_OVAL; break;
case 'T':
m_PadShape = PAD_TRAPEZOID; break;
}
ComputeShapeMaxRadius();
break;
case 'D':
BufCar[0] = 0;
nn = sscanf( PtLine, "%d %d %d %s %d %d", &m_Drill.x,
&m_Offset.x, &m_Offset.y, BufCar, &dx, &dy );
m_Drill.y = m_Drill.x;
m_DrillShape = PAD_CIRCLE;
if( nn >= 6 ) // Drill shape = OVAL ?
{
if( BufCar[0] == 'O' )
{
m_Drill.x = dx; m_Drill.y = dy;
m_DrillShape = PAD_OVAL;
}
}
break;
case 'A':
nn = sscanf( PtLine, "%s %s %X", BufLine, BufCar,
&m_layerMask );
/* BufCar is not used now update attributes */
m_Attribut = PAD_STANDARD;
if( strncmp( BufLine, "SMD", 3 ) == 0 )
m_Attribut = PAD_SMD;
if( strncmp( BufLine, "CONN", 4 ) == 0 )
m_Attribut = PAD_CONN;
if( strncmp( BufLine, "HOLE", 4 ) == 0 )
m_Attribut = PAD_HOLE_NOT_PLATED;
break;
case 'N': /* Read Netname */
int netcode;
nn = sscanf( PtLine, "%d", &netcode );
SetNet( netcode );
/* read Netname */
ReadDelimitedText( BufLine, PtLine, sizeof(BufLine) );
SetNetname( FROM_UTF8( StrPurge( BufLine ) ) );
break;
case 'P':
nn = sscanf( PtLine, "%d %d", &m_Pos0.x, &m_Pos0.y );
m_Pos = m_Pos0;
break;
case 'L':
int lengthdie;
nn = sscanf( PtLine, "%d", &lengthdie );
m_LengthDie = lengthdie;
break;
case '.': /* Read specific data */
if( strnicmp( Line, ".SolderMask ", 12 ) == 0 )
m_LocalSolderMaskMargin = atoi( Line + 12 );
else if( strnicmp( Line, ".SolderPaste ", 13 ) == 0 )
m_LocalSolderPasteMargin = atoi( Line + 13 );
else if( strnicmp( Line, ".SolderPasteRatio ", 18 ) == 0 )
m_LocalSolderPasteMarginRatio = atoi( Line + 18 );
else if( strnicmp( Line, ".LocalClearance ", 16 ) == 0 )
m_LocalClearance = atoi( Line + 16 );
break;
default:
DisplayError( NULL, wxT( "Err Pad: Id inconnu" ) );
return 1;
}
}
return 2; /* error : EOF */
}
bool D_PAD::Save( FILE* aFile ) const
{
int cshape;
const char* texttype;
// check the return values for first and last fprints() in this function
if( fprintf( aFile, "$PAD\n" ) != sizeof("$PAD\n") - 1 )
return false;
switch( m_PadShape )
{
case PAD_CIRCLE:
cshape = 'C'; break;
case PAD_RECT:
cshape = 'R'; break;
case PAD_OVAL:
cshape = 'O'; break;
case PAD_TRAPEZOID:
cshape = 'T'; break;
default:
cshape = 'C';
DisplayError( NULL, _( "Unknown pad shape" ) );
break;
}
fprintf( aFile, "Sh \"%.4s\" %c %d %d %d %d %d\n",
m_Padname, cshape, m_Size.x, m_Size.y,
m_DeltaSize.x, m_DeltaSize.y, m_Orient );
fprintf( aFile, "Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y );
if( m_DrillShape == PAD_OVAL )
{
fprintf( aFile, " %c %d %d", 'O', m_Drill.x, m_Drill.y );
}
fprintf( aFile, "\n" );
switch( m_Attribut )
{
case PAD_STANDARD:
texttype = "STD"; break;
case PAD_SMD:
texttype = "SMD"; break;
case PAD_CONN:
texttype = "CONN"; break;
case PAD_HOLE_NOT_PLATED:
texttype = "HOLE"; break;
default:
texttype = "STD";
DisplayError( NULL, wxT( "Invalid Pad attribute" ) );
break;
}
fprintf( aFile, "At %s N %8.8X\n", texttype, m_layerMask );
fprintf( aFile, "Ne %d %s\n", GetNet(), EscapedUTF8( m_Netname ).c_str() );
fprintf( aFile, "Po %d %d\n", m_Pos0.x, m_Pos0.y );
if( m_LengthDie != 0 )
fprintf( aFile, "Le %d\n", m_LengthDie );
if( m_LocalSolderMaskMargin != 0 )
fprintf( aFile, ".SolderMask %d\n", m_LocalSolderMaskMargin );
if( m_LocalSolderPasteMargin != 0 )
fprintf( aFile, ".SolderPaste %d\n", m_LocalSolderPasteMargin );
if( m_LocalSolderPasteMarginRatio != 0 )
fprintf( aFile, ".SolderPasteRatio %g\n", m_LocalSolderPasteMarginRatio );
if( m_LocalClearance != 0 )
fprintf( aFile, ".LocalClearance %d\n", m_LocalClearance );
if( fprintf( aFile, "$EndPAD\n" ) != sizeof("$EndPAD\n") - 1 )
return false;
return true;
}
void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
{ {
MODULE* module; MODULE* module;
......
...@@ -56,171 +56,6 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source ) ...@@ -56,171 +56,6 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source )
} }
/**
* Function ReadTextePcbDescr
* Read a text description from pcb file.
*
* For a single line text:
*
* $TEXTPCB
* Te "Text example"
* Po 66750 53450 600 800 150 0
* From 24 1 0 Italic
* $EndTEXTPCB
*
* For a multi line text
*
* $TEXTPCB
* Te "Text example"
* Nl "Line 2"
* Po 66750 53450 600 800 150 0
* From 24 1 0 Italic
* $EndTEXTPCB
* Nl "line nn" is a line added to the current text
*/
int TEXTE_PCB::ReadTextePcbDescr( LINE_READER* aReader )
{
char* line;
char text[1024];
char style[256];
while( aReader->ReadLine() )
{
line = aReader->Line();
if( strnicmp( line, "$EndTEXTPCB", 11 ) == 0 )
return 0;
if( strncmp( line, "Te", 2 ) == 0 ) /* Text line (first line for multi line texts */
{
ReadDelimitedText( text, line + 2, sizeof(text) );
m_Text = FROM_UTF8( text );
continue;
}
if( strncmp( line, "nl", 2 ) == 0 ) /* next line of the current text */
{
ReadDelimitedText( text, line + 2, sizeof(text) );
m_Text.Append( '\n' );
m_Text += FROM_UTF8( text );
continue;
}
if( strncmp( line, "Po", 2 ) == 0 )
{
sscanf( line + 2, " %d %d %d %d %d %d",
&m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y,
&m_Thickness, &m_Orient );
// Ensure the text has minimal size to see this text on screen:
if( m_Size.x < 5 )
m_Size.x = 5;
if( m_Size.y < 5 )
m_Size.y = 5;
continue;
}
if( strncmp( line, "De", 2 ) == 0 )
{
style[0] = 0;
int normal_display = 1;
char hJustify = 'c';
sscanf( line + 2, " %d %d %lX %s %c\n", &m_Layer, &normal_display,
&m_TimeStamp, style, &hJustify );
m_Mirror = normal_display ? false : true;
if( m_Layer < FIRST_COPPER_LAYER )
m_Layer = FIRST_COPPER_LAYER;
if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER;
if( strnicmp( style, "Italic", 6 ) == 0 )
m_Italic = 1;
else
m_Italic = 0;
switch( hJustify )
{
case 'l':
case 'L':
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
break;
case 'c':
case 'C':
m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
break;
case 'r':
case 'R':
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
break;
default:
m_HJustify = GR_TEXT_HJUSTIFY_CENTER;
break;
}
continue;
}
}
// Set a reasonable width:
if( m_Thickness < 1 )
m_Thickness = 1;
m_Thickness = Clamp_Text_PenSize( m_Thickness, m_Size );
return 1;
}
bool TEXTE_PCB::Save( FILE* aFile ) const
{
if( m_Text.IsEmpty() )
return true;
if( fprintf( aFile, "$TEXTPCB\n" ) != sizeof("$TEXTPCB\n") - 1 )
return false;
const char* style = m_Italic ? "Italic" : "Normal";
wxArrayString* list = wxStringSplit( m_Text, '\n' );
for( unsigned ii = 0; ii < list->Count(); ii++ )
{
wxString txt = list->Item( ii );
if ( ii == 0 )
fprintf( aFile, "Te %s\n", EscapedUTF8( txt ).c_str() );
else
fprintf( aFile, "nl %s\n", EscapedUTF8( txt ).c_str() );
}
delete list;
fprintf( aFile, "Po %d %d %d %d %d %d\n",
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Thickness, m_Orient );
char hJustify = 'L';
switch( m_HJustify )
{
case GR_TEXT_HJUSTIFY_LEFT:
hJustify = 'L';
break;
case GR_TEXT_HJUSTIFY_CENTER:
hJustify = 'C';
break;
case GR_TEXT_HJUSTIFY_RIGHT:
hJustify = 'R';
break;
default:
hJustify = 'C';
break;
}
fprintf( aFile, "De %d %d %lX %s %c\n", m_Layer,
m_Mirror ? 0 : 1,
m_TimeStamp, style, hJustify );
if( fprintf( aFile, "$EndTEXTPCB\n" ) != sizeof("$EndTEXTPCB\n") - 1 )
return false;
return true;
}
/* /*
* Function Draw * Function Draw
* Like tracks, texts are drawn in filled or sketch mode, never in line mode * Like tracks, texts are drawn in filled or sketch mode, never in line mode
......
...@@ -64,125 +64,6 @@ TEXTE_MODULE::~TEXTE_MODULE() ...@@ -64,125 +64,6 @@ TEXTE_MODULE::~TEXTE_MODULE()
} }
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool TEXTE_MODULE::Save( FILE* aFile ) const
{
MODULE* parent = (MODULE*) GetParent();
int orient = m_Orient;
// Due to the Pcbnew history, m_Orient is saved in screen value
// but it is handled as relative to its parent footprint
if( parent )
orient += parent->m_Orient;
int ret = fprintf( aFile, "T%d %d %d %d %d %d %d %c %c %d %c %s\n",
m_Type,
m_Pos0.x, m_Pos0.y,
m_Size.y, m_Size.x,
orient,
m_Thickness,
m_Mirror ? 'M' : 'N', m_NoShow ? 'I' : 'V',
GetLayer(),
m_Italic ? 'I' : 'N',
EscapedUTF8( m_Text ).c_str()
);
return ret > 20;
}
/**
* Function ReadDescr
* Read description from a given line in "*.brd" format.
* @param aReader The line reader object which contains the first line of description.
* @return int - > 0 if success reading else 0.
*/
int TEXTE_MODULE::ReadDescr( LINE_READER* aReader )
{
int success = true;
int type;
char BufCar1[128], BufCar2[128], BufCar3[128];
char* line = aReader->Line();
int layer = SILKSCREEN_N_FRONT;
BufCar1[0] = 0;
BufCar2[0] = 0;
BufCar3[0] = 0;
if( sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s",
&type,
&m_Pos0.x, &m_Pos0.y,
&m_Size.y, &m_Size.x,
&m_Orient, &m_Thickness,
BufCar1, BufCar2, &layer, BufCar3 ) >= 10 )
{
success = true;
}
if( (type != TEXT_is_REFERENCE) && (type != TEXT_is_VALUE) )
type = TEXT_is_DIVERS;
m_Type = type;
// Due to the Pcbnew history, .m_Orient is saved in screen value
// but it is handled as relative to its parent footprint
m_Orient -= ( (MODULE*) m_Parent )->m_Orient;
if( BufCar1[0] == 'M' )
m_Mirror = true;
else
m_Mirror = false;
if( BufCar2[0] == 'I' )
m_NoShow = true;
else
m_NoShow = false;
if( BufCar3[0] == 'I' )
m_Italic = true;
else
m_Italic = false;
// Test for a reasonable layer:
if( layer < 0 )
layer = 0;
if( layer > LAST_NO_COPPER_LAYER )
layer = LAST_NO_COPPER_LAYER;
if( layer == LAYER_N_BACK )
layer = SILKSCREEN_N_BACK;
else if( layer == LAYER_N_FRONT )
layer = SILKSCREEN_N_FRONT;
SetLayer( layer );
// Calculate the actual position.
SetDrawCoord();
// Search and read the "text" string (a quoted text).
ReadDelimitedText( &m_Text, line );
// Test for a reasonable size:
if( m_Size.x < TEXTS_MIN_SIZE )
m_Size.x = TEXTS_MIN_SIZE;
if( m_Size.y < TEXTS_MIN_SIZE )
m_Size.y = TEXTS_MIN_SIZE;
// Set a reasonable width:
if( m_Thickness < 1 )
m_Thickness = 1;
m_Thickness = Clamp_Text_PenSize( m_Thickness, m_Size );
return success;
}
void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
{ {
if( source == NULL ) if( source == NULL )
......
...@@ -598,24 +598,6 @@ TRACK* TRACK::GetEndNetCode( int NetCode ) ...@@ -598,24 +598,6 @@ TRACK* TRACK::GetEndNetCode( int NetCode )
} }
bool TRACK::Save( FILE* aFile ) const
{
int type = 0;
if( Type() == PCB_VIA_T )
type = 1;
fprintf( aFile, "Po %d %d %d %d %d %d %d\n", m_Shape,
m_Start.x, m_Start.y, m_End.x, m_End.y, m_Width, m_Drill );
fprintf( aFile, "De %d %d %d %lX %X\n",
m_Layer, type, GetNet(),
m_TimeStamp, ReturnStatus() );
return true;
}
void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& aOffset ) void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& aOffset )
{ {
int l_trace; int l_trace;
......
This diff is collapsed.
...@@ -200,7 +200,7 @@ the changes?" ) ) ) ...@@ -200,7 +200,7 @@ the changes?" ) ) )
GetScreen()->SetFileName( fileName.GetFullPath() ); GetScreen()->SetFileName( fileName.GetFullPath() );
#if 1 #if !defined(USE_NEW_PCBNEW_LOAD)
// Start read PCB file // Start read PCB file
FILE* source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) ); FILE* source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
......
...@@ -963,6 +963,8 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader ) ...@@ -963,6 +963,8 @@ static bool ReadSheetDescr( BASE_SCREEN* screen, LINE_READER* aReader )
} }
#if !defined( USE_NEW_PCBNEW_LOAD )
int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append )
{ {
wxBusyCursor dummy; wxBusyCursor dummy;
...@@ -1140,6 +1142,8 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append ) ...@@ -1140,6 +1142,8 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append )
return 1; return 1;
} }
#endif
#ifdef PCBNEW #ifdef PCBNEW
...@@ -1188,5 +1192,4 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile ) ...@@ -1188,5 +1192,4 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
return rc; return rc;
} }
#endif #endif
This diff is collapsed.
This diff is collapsed.
...@@ -72,6 +72,7 @@ protected: ...@@ -72,6 +72,7 @@ protected:
BOARD* m_board; ///< which BOARD, no ownership here BOARD* m_board; ///< which BOARD, no ownership here
LINE_READER* m_reader; ///< no ownership here. LINE_READER* m_reader; ///< no ownership here.
FILE* m_fp; ///< no ownership here.
wxString m_field; ///< reused to stuff MODULE fields. wxString m_field; ///< reused to stuff MODULE fields.
......
...@@ -55,20 +55,20 @@ static void DisplayCmpDoc( wxString& Name ); ...@@ -55,20 +55,20 @@ static void DisplayCmpDoc( wxString& Name );
static FOOTPRINT_LIST MList; static FOOTPRINT_LIST MList;
bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* Module ) bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
{ {
MODULE* NewModule; MODULE* newModule;
PCB_BASE_FRAME* parent = (PCB_BASE_FRAME*) GetParent(); PCB_BASE_FRAME* parent = (PCB_BASE_FRAME*) GetParent();
if( Module == NULL ) if( aModule == NULL )
{ {
if( ! parent->GetBoard() || ! parent->GetBoard()->m_Modules ) if( ! parent->GetBoard() || ! parent->GetBoard()->m_Modules )
return false; return false;
Module = Select_1_Module_From_BOARD( parent->GetBoard() ); aModule = Select_1_Module_From_BOARD( parent->GetBoard() );
} }
if( Module == NULL ) if( aModule == NULL )
return false; return false;
SetCurItem( NULL ); SetCurItem( NULL );
...@@ -76,25 +76,25 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* Module ) ...@@ -76,25 +76,25 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* Module )
Clear_Pcb( false ); Clear_Pcb( false );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
NewModule = new MODULE( GetBoard() ); newModule = new MODULE( GetBoard() );
NewModule->Copy( Module ); newModule->Copy( aModule );
NewModule->m_Link = Module->m_TimeStamp; newModule->m_Link = aModule->m_TimeStamp;
Module = NewModule; aModule = newModule;
GetBoard()->Add( Module ); GetBoard()->Add( aModule );
Module->m_Flags = 0; aModule->m_Flags = 0;
GetBoard()->m_NetInfo->BuildListOfNets(); GetBoard()->m_NetInfo->BuildListOfNets();
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
PlaceModule( Module, NULL ); PlaceModule( aModule, NULL );
if( Module->GetLayer() != LAYER_N_FRONT ) if( aModule->GetLayer() != LAYER_N_FRONT )
Module->Flip( Module->m_Pos ); aModule->Flip( aModule->m_Pos );
Rotate_Module( NULL, Module, 0, false ); Rotate_Module( NULL, aModule, 0, false );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
Zoom_Automatique( false ); Zoom_Automatique( false );
...@@ -104,12 +104,13 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* Module ) ...@@ -104,12 +104,13 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* Module )
MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC* DC ) MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC* DC )
{ {
MODULE* module; MODULE* module;
wxPoint curspos = GetScreen()->GetCrossHairPosition(); wxPoint curspos = GetScreen()->GetCrossHairPosition();
wxString ModuleName, keys; wxString moduleName, keys;
bool AllowWildSeach = true;
static wxArrayString HistoryList; static wxArrayString HistoryList;
static wxString lastCommponentName; static wxString lastCommponentName;
bool AllowWildSeach = true;
/* Ask for a component name or key words */ /* Ask for a component name or key words */
DIALOG_GET_COMPONENT dlg( this, GetComponentDialogPosition(), HistoryList, DIALOG_GET_COMPONENT dlg( this, GetComponentDialogPosition(), HistoryList,
...@@ -120,57 +121,57 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC* ...@@ -120,57 +121,57 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return NULL; return NULL;
ModuleName = dlg.GetComponentName(); moduleName = dlg.GetComponentName();
if( ModuleName.IsEmpty() ) /* Cancel command */ if( moduleName.IsEmpty() ) /* Cancel command */
{ {
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
return NULL; return NULL;
} }
ModuleName.MakeUpper(); moduleName.MakeUpper();
if( ModuleName[0] == '=' ) // Selection by keywords if( moduleName[0] == '=' ) // Selection by keywords
{ {
AllowWildSeach = false; AllowWildSeach = false;
keys = ModuleName.AfterFirst( '=' ); keys = moduleName.AfterFirst( '=' );
ModuleName = Select_1_Module_From_List( this, library, wxEmptyString, keys ); moduleName = Select_1_Module_From_List( this, library, wxEmptyString, keys );
if( ModuleName.IsEmpty() ) /* Cancel command */ if( moduleName.IsEmpty() ) /* Cancel command */
{ {
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
return NULL; return NULL;
} }
} }
else if( ( ModuleName.Contains( wxT( "?" ) ) ) else if( ( moduleName.Contains( wxT( "?" ) ) )
|| ( ModuleName.Contains( wxT( "*" ) ) ) ) // Selection wild card || ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
{ {
AllowWildSeach = false; AllowWildSeach = false;
ModuleName = Select_1_Module_From_List( this, library, ModuleName, wxEmptyString ); moduleName = Select_1_Module_From_List( this, library, moduleName, wxEmptyString );
if( ModuleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
return NULL; /* Cancel command. */ return NULL; /* Cancel command. */
} }
} }
module = GetModuleLibrary( library, ModuleName, false ); module = GetModuleLibrary( library, moduleName, false );
if( ( module == NULL ) && AllowWildSeach ) /* Search with wild card */ if( ( module == NULL ) && AllowWildSeach ) /* Search with wild card */
{ {
AllowWildSeach = false; AllowWildSeach = false;
wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' ); wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
ModuleName = wildname; moduleName = wildname;
ModuleName = Select_1_Module_From_List( this, library, ModuleName, wxEmptyString ); moduleName = Select_1_Module_From_List( this, library, moduleName, wxEmptyString );
if( ModuleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
return NULL; /* Cancel command. */ return NULL; /* Cancel command. */
} }
else else
{ {
module = GetModuleLibrary( library, ModuleName, true ); module = GetModuleLibrary( library, moduleName, true );
} }
} }
...@@ -179,8 +180,8 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC* ...@@ -179,8 +180,8 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
if( module ) if( module )
{ {
lastCommponentName = ModuleName; lastCommponentName = moduleName;
AddHistoryComponentName( HistoryList, ModuleName ); AddHistoryComponentName( HistoryList, moduleName );
module->m_Flags = IS_NEW; module->m_Flags = IS_NEW;
module->m_Link = 0; module->m_Link = 0;
...@@ -211,14 +212,13 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename, ...@@ -211,14 +212,13 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename,
bool aDisplayMessageError ) bool aDisplayMessageError )
{ {
wxFileName fn; wxFileName fn;
wxString Name;
wxString msg, tmp; wxString msg, tmp;
MODULE* NewModule; MODULE* newModule;
FILE* file = NULL; FILE* file = NULL;
unsigned ii;
bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true; bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true;
for( ii = 0; ii < g_LibraryNames.GetCount(); ii++ ) for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
{ {
if( one_lib ) if( one_lib )
fn = aLibraryFullFilename; fn = aLibraryFullFilename;
...@@ -266,38 +266,42 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename, ...@@ -266,38 +266,42 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename,
return NULL; return NULL;
} }
/* Reading the list of modules in the library. */ // Reading the list of modules in the library.
curr_lib.ReadSectionIndex(); curr_lib.ReadSectionIndex();
bool found = curr_lib.FindInList( aModuleName ); bool found = curr_lib.FindInList( aModuleName );
/* Read library. */ // Read library.
if( found ) if( found )
{ {
wxString name;
fileReader.Rewind(); fileReader.Rewind();
while( reader.ReadLine() ) while( reader.ReadLine() )
{ {
char * line = reader.Line(); char* line = reader.Line();
StrPurge( line + 8 ); StrPurge( line + 8 );
if( strnicmp( line, "$MODULE", 7 ) != 0 ) if( strnicmp( line, "$MODULE", 7 ) != 0 )
continue; continue;
// Read module name. // Read module name.
Name = FROM_UTF8( line + 8 ); name = FROM_UTF8( line + 8 );
if( Name.CmpNoCase( aModuleName ) == 0 ) if( name.CmpNoCase( aModuleName ) == 0 )
{ {
NewModule = new MODULE( GetBoard() ); newModule = new MODULE( GetBoard() );
// Switch the locale to standard C (needed to print // Temporarily switch the locale to standard C (needed to print
// floating point numbers like 1.3) // floating point numbers like 1.3)
SetLocaleTo_C_standard(); LOCALE_IO toggle;
NewModule->ReadDescr( &reader );
SetLocaleTo_Default(); // revert to the current locale newModule->ReadDescr( &reader );
GetBoard()->Add( NewModule, ADD_APPEND );
GetBoard()->Add( newModule, ADD_APPEND );
SetStatusText( wxEmptyString ); SetStatusText( wxEmptyString );
return NewModule; return newModule;
} }
} }
} }
...@@ -405,16 +409,16 @@ static void DisplayCmpDoc( wxString& Name ) ...@@ -405,16 +409,16 @@ static void DisplayCmpDoc( wxString& Name )
MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb ) MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
{ {
MODULE* Module; MODULE* module;
static wxString OldName; /* Save name of last module selected. */ static wxString OldName; /* Save name of last module selected. */
wxString CmpName, msg; wxString CmpName, msg;
wxArrayString listnames; wxArrayString listnames;
Module = aPcb->m_Modules; module = aPcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() ) for( ; module != NULL; module = (MODULE*) module->Next() )
listnames.Add( Module->m_Reference->m_Text ); listnames.Add( module->m_Reference->m_Text );
msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() ); msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() );
...@@ -428,13 +432,13 @@ MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb ) ...@@ -428,13 +432,13 @@ MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
OldName = CmpName; OldName = CmpName;
Module = aPcb->m_Modules; module = aPcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() ) for( ; module != NULL; module = (MODULE*) module->Next() )
{ {
if( CmpName == Module->m_Reference->m_Text ) if( CmpName == module->m_Reference->m_Text )
break; break;
} }
return Module; return module;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment