Commit 701fa6b0 authored by Dick Hollenbeck's avatar Dick Hollenbeck

intermediate check in to show progress on new nanometer file loader PLUGIN

parent 2515a806
...@@ -88,7 +88,7 @@ INPUT_ENCODING = UTF-8 ...@@ -88,7 +88,7 @@ INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.h \ FILE_PATTERNS = *.h \
*.cpp *.cpp
RECURSIVE = YES RECURSIVE = YES
EXCLUDE = include\boost EXCLUDE = include/boost polygon/kbool
EXCLUDE_SYMLINKS = NO EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS = EXCLUDE_SYMBOLS =
......
/**
* @file class_via_dimension.h
* @brief Class via dimension.
*/
#ifndef CLASS_VIA_DIMENSION_H
#define CLASS_VIA_DIMENSION_H
#include "lengthpcb.h"
/** a small helper class to handle a stock of specific vias diameter and drill pair
* in the BOARD class
*/
class VIA_DIMENSION
{
public:
LENGTH_PCB m_Diameter; // <= 0 means use Netclass via diameter
LENGTH_PCB m_Drill; // <= 0 means use Netclass via drill
VIA_DIMENSION()
{
m_Diameter = FROM_LEGACY_LU( 0 );
m_Drill = FROM_LEGACY_LU( 0 );
}
bool operator ==( const VIA_DIMENSION& other ) const
{
return (m_Diameter == other.m_Diameter) && (m_Drill == other.m_Drill);
}
bool operator <( const VIA_DIMENSION& other ) const
{
if( m_Diameter != other.m_Diameter )
return m_Diameter < other.m_Diameter;
return m_Drill < other.m_Drill;
}
};
#endif /* CLASS_VIA_DIMENSION_H */
\ No newline at end of file
...@@ -217,7 +217,7 @@ extern int g_GhostColor; ...@@ -217,7 +217,7 @@ extern int g_GhostColor;
* This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function, * This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
* but could make more easier an optional use of locale in KiCad * but could make more easier an optional use of locale in KiCad
*/ */
void SetLocaleTo_C_standard( void ); void SetLocaleTo_C_standard();
/** /**
* Function SetLocaleTo_Default * Function SetLocaleTo_Default
...@@ -230,8 +230,21 @@ void SetLocaleTo_C_standard( void ); ...@@ -230,8 +230,21 @@ void SetLocaleTo_C_standard( void );
* This is wrapper to the C setlocale( LC_NUMERIC, "" ) function, * This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
* but could make more easier an optional use of locale in KiCad * but could make more easier an optional use of locale in KiCad
*/ */
void SetLocaleTo_Default( void ); void SetLocaleTo_Default();
/**
* Class LOCALE_IO
* is a class that can be instantiated within a scope in which you are expecting
* exceptions to be thrown. Its constructor calls SetLocaleTo_C_Standard().
* Its destructor insures that the default locale is restored if an exception
* is thrown, or not.
*/
class LOCALE_IO
{
public:
LOCALE_IO() { SetLocaleTo_C_standard(); }
~LOCALE_IO() { SetLocaleTo_Default(); }
};
/** /**
* Function EnsureTextCtrlWidth * Function EnsureTextCtrlWidth
......
...@@ -80,28 +80,34 @@ struct LAYER ...@@ -80,28 +80,34 @@ struct LAYER
}; };
/** a small helper class to handle a stock of specific vias diameter and drill pair /**
* in the BOARD class * Struct VIA_DIMENSION
* is a small helper container to handle a stock of specific vias each with
* unique diameter and drill sizes in the BOARD class.
*/ */
class VIA_DIMENSION struct VIA_DIMENSION
{ {
public:
int m_Diameter; // <= 0 means use Netclass via diameter int m_Diameter; // <= 0 means use Netclass via diameter
int m_Drill; // <= 0 means use Netclass via drill int m_Drill; // <= 0 means use Netclass via drill
VIA_DIMENSION() VIA_DIMENSION()
{ {
m_Diameter = 0; m_Drill = 0; m_Diameter = 0;
m_Drill = 0;
} }
VIA_DIMENSION( int aDiameter, int aDrill )
{
m_Diameter = aDiameter;
m_Drill = aDrill;
}
bool operator ==( const VIA_DIMENSION& other ) const bool operator == ( const VIA_DIMENSION& other ) const
{ {
return (m_Diameter == other.m_Diameter) && (m_Drill == other.m_Drill); return (m_Diameter == other.m_Diameter) && (m_Drill == other.m_Drill);
} }
bool operator < ( const VIA_DIMENSION& other ) const
bool operator <( const VIA_DIMENSION& other ) const
{ {
if( m_Diameter != other.m_Diameter ) if( m_Diameter != other.m_Diameter )
return m_Diameter < other.m_Diameter; return m_Diameter < other.m_Diameter;
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* @brief Class to handle a graphic segment. * @brief Class to handle a graphic segment.
*/ */
#ifndef CLASS_DRAWSEGMENT_H #ifndef CLASS_DRAWSEGMENT_H_
#define CLASS_DRAWSEGMENT_H #define CLASS_DRAWSEGMENT_H_
#include "class_board_item.h" #include "class_board_item.h"
...@@ -40,6 +40,21 @@ public: ...@@ -40,6 +40,21 @@ public:
DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; } DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; }
DRAWSEGMENT* Back() const { return (DRAWSEGMENT*) Pback; } DRAWSEGMENT* Back() const { return (DRAWSEGMENT*) Pback; }
void SetWidth( int aWidth ) { m_Width = aWidth; }
void SetStart( const wxPoint& aStart ) { m_Start = aStart; }
void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
void SetAngle( double aAngle ) { m_Angle = (int) aAngle; }
void SetType( int aType ) { m_Type = aType; }
void SetShape( int aShape ) { m_Shape = aShape; }
void SetBezControl1( const wxPoint& aPoint ) { m_BezierC1 = aPoint; }
void SetBezControl2( const wxPoint& aPoint ) { m_BezierC2 = aPoint; }
/** /**
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
...@@ -85,6 +100,16 @@ public: ...@@ -85,6 +100,16 @@ public:
std::vector<wxPoint>& GetBezierPoints() { return m_BezierPoints; }; std::vector<wxPoint>& GetBezierPoints() { return m_BezierPoints; };
std::vector<wxPoint>& GetPolyPoints() { return m_PolyPoints; }; std::vector<wxPoint>& GetPolyPoints() { return m_PolyPoints; };
void SetBezierPoints( std::vector<wxPoint>& aPoints )
{
m_BezierPoints = aPoints;
}
void SetPolyPoints( std::vector<wxPoint>& aPoints )
{
m_PolyPoints = aPoints;
}
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
...@@ -158,7 +183,7 @@ public: ...@@ -158,7 +183,7 @@ public:
{ {
wxPoint delta = GetEnd() - GetStart(); wxPoint delta = GetEnd() - GetStart();
return hypot( delta.x, delta.y ); return hypot( double( delta.x ), double( delta.y ) );
} }
...@@ -212,9 +237,7 @@ public: ...@@ -212,9 +237,7 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
#endif // CLASS_DRAWSEGMENT_H_
#endif // #ifndef CLASS_DRAWSEGMENT_H
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "pcbnew.h" #include "pcbnew.h"
#include "protos.h" #include "protos.h"
#include "pcbnew_id.h" #include "pcbnew_id.h"
#include "io_mgr.h"
#include "class_board.h" #include "class_board.h"
...@@ -150,7 +151,6 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -150,7 +151,6 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend, bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend,
bool aForceFileDialog ) bool aForceFileDialog )
{ {
FILE* source;
wxString msg; wxString msg;
if( GetScreen()->IsModify() && !aAppend ) if( GetScreen()->IsModify() && !aAppend )
...@@ -199,8 +199,9 @@ the changes?" ) ) ) ...@@ -199,8 +199,9 @@ the changes?" ) ) )
GetScreen()->SetFileName( fileName.GetFullPath() ); GetScreen()->SetFileName( fileName.GetFullPath() );
#if 1
// Start read PCB file // Start read PCB file
source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) ); FILE* source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
if( source == NULL ) if( source == NULL )
{ {
...@@ -257,6 +258,41 @@ this file again." ) ); ...@@ -257,6 +258,41 @@ this file again." ) );
LoadProjectSettings( GetScreen()->GetFileName() ); LoadProjectSettings( GetScreen()->GetFileName() );
} }
#else
if( !aAppend )
{
// Update the option toolbar
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayModText = DisplayOpt.DisplayModText;
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
}
try
{
// load or append either:
BOARD* board = IO_MGR::Load( IO_MGR::KICAD, GetScreen()->GetFileName(),
aAppend ? GetBoard() : NULL,
NULL );
if( !aAppend )
SetBoard( board );
}
catch ( IO_ERROR ioe )
{
// @todo
printf( "Error loading board: %s\n", TO_UTF8( ioe.errorText ) );
}
if( !aAppend )
{
LoadProjectSettings( GetScreen()->GetFileName() );
}
#endif
GetScreen()->ClrModify(); GetScreen()->ClrModify();
/* If append option: change the initial board name to <oldname>-append.brd */ /* If append option: change the initial board name to <oldname>-append.brd */
......
...@@ -117,16 +117,9 @@ public: ...@@ -117,16 +117,9 @@ public:
* is a base class that BOARD loading and saving plugins should derive from. * is a base class that BOARD loading and saving plugins should derive from.
* Implementations can provide either Load() or Save() functions, or both. * Implementations can provide either Load() or Save() functions, or both.
* PLUGINs throw exceptions, so it is best that you wrap your calls to these * PLUGINs throw exceptions, so it is best that you wrap your calls to these
* functions in a try catch block, and also do the switching to stardard C locale * functions in a try catch block.
* and back, outside the region in which an exception can be thrown. This means
* the PLUGINs do not deal with the locale, the caller does.
* *
* <pre> * <pre>
*
* // Switch the locale to standard C (needed to read floating point numbers
* // like 1.3)
*
* SetLocaleTo_C_standard();
* try * try
* { * {
* pi->Load(...); * pi->Load(...);
...@@ -135,8 +128,6 @@ public: ...@@ -135,8 +128,6 @@ public:
* { * {
* // grab text from ioe, show in error window. * // grab text from ioe, show in error window.
* } * }
* SetLocaleTo_Default(); // revert to the current locale
*
* </pre> * </pre>
*/ */
class PLUGIN class PLUGIN
......
This diff is collapsed.
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <string> #include <string>
typedef int BIU; typedef int BIU;
typedef double BFU;
class PCB_TARGET; class PCB_TARGET;
class MODULE; class MODULE;
...@@ -63,12 +62,13 @@ public: ...@@ -63,12 +62,13 @@ public:
protected: protected:
wxString m_Error; ///< for throwing exceptions wxString m_error; ///< for throwing exceptions
BOARD* m_board; ///< which BOARD, no ownership here
LINE_READER* m_Reader; ///< no ownership here. LINE_READER* aReader; ///< no ownership here.
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed. /// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void init( BOARD* board, PROPERTIES* aProperties ); void init( PROPERTIES* aProperties );
int NbDraw; int NbDraw;
int NbTrack; int NbTrack;
...@@ -76,28 +76,47 @@ protected: ...@@ -76,28 +76,47 @@ protected:
int NbMod; int NbMod;
int NbNets; int NbNets;
BFU biuToDisk; ///< convert from BIUs to disk engineering units with this scale factor double biuToDisk; ///< convert from BIUs to disk engineering units with this scale factor
BFU diskToBiu; ///< convert from disk engineering units to BIUs with this scale factor double diskToBiu; ///< convert from disk engineering units to BIUs with this scale factor
/// convert a BIU to engineering units by scaling and formatting to ASCII. /// convert a BIU to engineering units by scaling and formatting to ASCII.
std::string biuFmt( BIU aValue ); std::string biuFmt( BIU aValue );
/**
* Function biuParse
* parses an ASCII decimal floating point value and scales it into a BIU
* according to the current value of diskToBui.
*
* @param aValue is the ASCII value in C locale form.
*
* @param nptrptr may be NULL, but if not, then it tells where to put a
* pointer to the next unconsumed input text. See man strtod() for more information.
*
* @return BIU - the converted Board Internal Unit.
*/
BIU biuParse( const char* aValue, const char** nptrptr = NULL );
// load / parse functions // load / parse functions
void loadGeneral( BOARD* me ); void loadAllSections( bool doAppend );
void loadSetup( BOARD* me );
void loadSheet( BOARD* me ); void loadGENERAL();
void loadSETUP();
void loadSHEET();
void loadMODULE();
void loadDRAWSEGMENT();
void loadNETINFO_ITEM();
void loadPCB_TEXTE();
/*
void load( PCB_TARGET* me ); void load( PCB_TARGET* me );
void load( MODULE* me );
void load( DRAWSEGMENT* me );
void load( NETINFO* me ); void load( NETINFO* me );
void load( TEXTE_PCB* me );
void load( TRACK* me ); void load( TRACK* me );
void load( NETCLASS* me ); void load( NETCLASS* me );
void load( ZONE_CONTAINER* me ); void load( ZONE_CONTAINER* me );
void load( DIMENSION* me ); void load( DIMENSION* me );
void load( NETINFO_ITEM* me ); */
// void load( SEGZONE* me ); // void load( SEGZONE* me );
}; };
......
...@@ -149,8 +149,9 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -149,8 +149,9 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
wxFileName fn; wxFileName fn;
wxFileName tmpFileName; wxFileName tmpFileName;
FILE* FichCmp, * NewFile; FILE* FichCmp, * NewFile;
char Line[1024]; char line[1024];
wxString msg; wxString msg;
char* rs;
if( old_name == new_name ) if( old_name == new_name )
return 0; return 0;
...@@ -188,17 +189,18 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -188,17 +189,18 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
return 1; return 1;
} }
fgets( Line, sizeof(Line), FichCmp ); rs = fgets( line, sizeof(line), FichCmp );
fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", TO_UTF8( DateAndTime() ) ); fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", TO_UTF8( DateAndTime() ) );
bool start_descr = false; bool start_descr = false;
while( fgets( Line, sizeof(Line), FichCmp ) != NULL ) while( fgets( line, sizeof(line), FichCmp ) != NULL )
{ {
if( strnicmp( Line, "Reference = ", 9 ) == 0 ) if( strnicmp( line, "Reference = ", 9 ) == 0 )
{ {
char buf[1024]; char buf[1024];
strcpy( buf, Line + 12 ); strcpy( buf, line + 12 );
strtok( buf, ";\n\r" ); strtok( buf, ";\n\r" );
if( stricmp( buf, TO_UTF8( reference ) ) == 0 ) if( stricmp( buf, TO_UTF8( reference ) ) == 0 )
...@@ -207,14 +209,14 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -207,14 +209,14 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
} }
} }
if( (strnicmp( Line, "Begin", 5 ) == 0) || (strnicmp( Line, "End", 3 ) == 0) ) if( (strnicmp( line, "Begin", 5 ) == 0) || (strnicmp( line, "End", 3 ) == 0) )
{ {
start_descr = false; start_descr = false;
} }
if( start_descr && strnicmp( Line, "IdModule", 8 ) == 0 ) if( start_descr && strnicmp( line, "IdModule", 8 ) == 0 )
{ {
sprintf( Line + 8, " = %s;\n", TO_UTF8( new_name ) ); sprintf( line + 8, " = %s;\n", TO_UTF8( new_name ) );
msg = wxT( " * in <" ) + fn.GetFullPath() + wxT( ">.\n" ); msg = wxT( " * in <" ) + fn.GetFullPath() + wxT( ">.\n" );
m_WinMessages->AppendText( msg ); m_WinMessages->AppendText( msg );
...@@ -222,7 +224,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -222,7 +224,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
start_descr = false; start_descr = false;
} }
fputs( Line, NewFile ); fputs( line, NewFile );
} }
fclose( FichCmp ); fclose( FichCmp );
...@@ -422,7 +424,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, ...@@ -422,7 +424,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
{ {
wxString namecmp, oldnamecmp; wxString namecmp, oldnamecmp;
MODULE* NewModule; MODULE* NewModule;
wxString Line; wxString line;
if( Module == NULL ) if( Module == NULL )
return false; return false;
...@@ -434,10 +436,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, ...@@ -434,10 +436,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
namecmp = new_module; namecmp = new_module;
/* Load module. */ /* Load module. */
Line.Printf( _( "Change module %s (%s) " ), line.Printf( _( "Change module %s (%s) " ),
GetChars( Module->m_Reference->m_Text ), GetChars( Module->m_Reference->m_Text ),
GetChars( oldnamecmp ) ); GetChars( oldnamecmp ) );
m_WinMessages->AppendText( Line ); m_WinMessages->AppendText( line );
namecmp.Trim( true ); namecmp.Trim( true );
namecmp.Trim( false ); namecmp.Trim( false );
...@@ -581,10 +583,11 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -581,10 +583,11 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
{ {
wxFileName fn; wxFileName fn;
FILE* FichCmp; FILE* FichCmp;
char Line[1024]; char line[1024];
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
wxString msg; wxString msg;
wxString wildcard; wxString wildcard;
char* rs;
if( Module == NULL ) if( Module == NULL )
{ {
...@@ -615,7 +618,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -615,7 +618,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
return; return;
} }
fgets( Line, sizeof(Line), FichCmp ); rs = fgets( line, sizeof(line), FichCmp );
fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", TO_UTF8( DateAndTime() ) ); fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", TO_UTF8( DateAndTime() ) );
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
......
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