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
FILE_PATTERNS = *.h \
*.cpp
RECURSIVE = YES
EXCLUDE = include\boost
EXCLUDE = include/boost polygon/kbool
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
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;
* This is wrapper to the C setlocale( LC_NUMERIC, "C" ) function,
* but could make more easier an optional use of locale in KiCad
*/
void SetLocaleTo_C_standard( void );
void SetLocaleTo_C_standard();
/**
* Function SetLocaleTo_Default
......@@ -230,8 +230,21 @@ void SetLocaleTo_C_standard( void );
* This is wrapper to the C setlocale( LC_NUMERIC, "" ) function,
* 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
......
......@@ -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_Drill; // <= 0 means use Netclass via drill
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);
}
bool operator <( const VIA_DIMENSION& other ) const
bool operator < ( const VIA_DIMENSION& other ) const
{
if( m_Diameter != other.m_Diameter )
return m_Diameter < other.m_Diameter;
......
......@@ -3,8 +3,8 @@
* @brief Class to handle a graphic segment.
*/
#ifndef CLASS_DRAWSEGMENT_H
#define CLASS_DRAWSEGMENT_H
#ifndef CLASS_DRAWSEGMENT_H_
#define CLASS_DRAWSEGMENT_H_
#include "class_board_item.h"
......@@ -30,8 +30,8 @@ public:
wxPoint m_BezierC2; // Bezier Control Point 1
protected:
std::vector<wxPoint> m_BezierPoints;
std::vector<wxPoint> m_PolyPoints;
std::vector<wxPoint> m_BezierPoints;
std::vector<wxPoint> m_PolyPoints;
public:
DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype = PCB_LINE_T );
......@@ -40,6 +40,21 @@ public:
DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; }
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
* returns the position of this object.
......@@ -83,7 +98,17 @@ public:
MODULE* GetParentModule() const;
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
......@@ -158,7 +183,7 @@ public:
{
wxPoint delta = GetEnd() - GetStart();
return hypot( delta.x, delta.y );
return hypot( double( delta.x ), double( delta.y ) );
}
......@@ -212,9 +237,7 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
};
#endif // #ifndef CLASS_DRAWSEGMENT_H
#endif // CLASS_DRAWSEGMENT_H_
......@@ -44,6 +44,7 @@
#include "pcbnew.h"
#include "protos.h"
#include "pcbnew_id.h"
#include "io_mgr.h"
#include "class_board.h"
......@@ -150,7 +151,6 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend,
bool aForceFileDialog )
{
FILE* source;
wxString msg;
if( GetScreen()->IsModify() && !aAppend )
......@@ -199,8 +199,9 @@ the changes?" ) ) )
GetScreen()->SetFileName( fileName.GetFullPath() );
#if 1
// Start read PCB file
source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
FILE* source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
if( source == NULL )
{
......@@ -257,6 +258,41 @@ this file again." ) );
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();
/* If append option: change the initial board name to <oldname>-append.brd */
......
......@@ -117,16 +117,9 @@ public:
* is a base class that BOARD loading and saving plugins should derive from.
* Implementations can provide either Load() or Save() functions, or both.
* 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
* 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.
* functions in a try catch block.
*
* <pre>
*
* // Switch the locale to standard C (needed to read floating point numbers
* // like 1.3)
*
* SetLocaleTo_C_standard();
* try
* {
* pi->Load(...);
......@@ -135,8 +128,6 @@ public:
* {
* // grab text from ioe, show in error window.
* }
* SetLocaleTo_Default(); // revert to the current locale
*
* </pre>
*/
class PLUGIN
......
This diff is collapsed.
......@@ -28,7 +28,6 @@
#include <string>
typedef int BIU;
typedef double BFU;
class PCB_TARGET;
class MODULE;
......@@ -63,12 +62,13 @@ public:
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.
void init( BOARD* board, PROPERTIES* aProperties );
void init( PROPERTIES* aProperties );
int NbDraw;
int NbTrack;
......@@ -76,28 +76,47 @@ protected:
int NbMod;
int NbNets;
BFU 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 biuToDisk; ///< convert from BIUs to disk engineering units 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.
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
void loadGeneral( BOARD* me );
void loadSetup( BOARD* me );
void loadSheet( BOARD* me );
void loadAllSections( bool doAppend );
void loadGENERAL();
void loadSETUP();
void loadSHEET();
void loadMODULE();
void loadDRAWSEGMENT();
void loadNETINFO_ITEM();
void loadPCB_TEXTE();
/*
void load( PCB_TARGET* me );
void load( MODULE* me );
void load( DRAWSEGMENT* me );
void load( NETINFO* me );
void load( TEXTE_PCB* me );
void load( TRACK* me );
void load( NETCLASS* me );
void load( ZONE_CONTAINER* me );
void load( DIMENSION* me );
void load( NETINFO_ITEM* me );
*/
// void load( SEGZONE* me );
};
......
......@@ -146,11 +146,12 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
const wxString& new_name,
bool ShowError )
{
wxFileName fn;
wxFileName tmpFileName;
FILE* FichCmp, * NewFile;
char Line[1024];
wxString msg;
wxFileName fn;
wxFileName tmpFileName;
FILE* FichCmp, * NewFile;
char line[1024];
wxString msg;
char* rs;
if( old_name == new_name )
return 0;
......@@ -188,17 +189,18 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
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() ) );
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];
strcpy( buf, Line + 12 );
strcpy( buf, line + 12 );
strtok( buf, ";\n\r" );
if( stricmp( buf, TO_UTF8( reference ) ) == 0 )
......@@ -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;
}
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" );
m_WinMessages->AppendText( msg );
......@@ -222,7 +224,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
start_descr = false;
}
fputs( Line, NewFile );
fputs( line, NewFile );
}
fclose( FichCmp );
......@@ -422,7 +424,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
{
wxString namecmp, oldnamecmp;
MODULE* NewModule;
wxString Line;
wxString line;
if( Module == NULL )
return false;
......@@ -434,10 +436,10 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
namecmp = new_module;
/* Load module. */
Line.Printf( _( "Change module %s (%s) " ),
line.Printf( _( "Change module %s (%s) " ),
GetChars( Module->m_Reference->m_Text ),
GetChars( oldnamecmp ) );
m_WinMessages->AppendText( Line );
m_WinMessages->AppendText( line );
namecmp.Trim( true );
namecmp.Trim( false );
......@@ -579,12 +581,13 @@ void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event )
*/
void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
{
wxFileName fn;
FILE* FichCmp;
char Line[1024];
MODULE* Module = GetBoard()->m_Modules;
wxString msg;
wxString wildcard;
wxFileName fn;
FILE* FichCmp;
char line[1024];
MODULE* Module = GetBoard()->m_Modules;
wxString msg;
wxString wildcard;
char* rs;
if( Module == NULL )
{
......@@ -615,7 +618,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
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() ) );
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