Commit a37fdd97 authored by Dick Hollenbeck's avatar Dick Hollenbeck

First working version of KICAD_PLUGIN::Load(), short of some globals and minor conflicts

parents 0fb4954f 343e55b0
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
*/ */
#define IO_FORMAT _( "IO_ERROR: %s\n from %s : %s" ) #define IO_FORMAT _( "IO_ERROR: %s\nfrom %s : %s" )
#define PARSE_FORMAT _( "PARSE_ERROR: %s in input/source \"%s\", line %d, offset %d\n from %s : %s" ) #define PARSE_FORMAT _( "PARSE_ERROR: %s in input/source \"%s\", line %d, offset %d\nfrom %s : %s" )
// references: // references:
// http://stackoverflow.com/questions/2670816/how-can-i-use-the-compile-time-constant-line-in-a-string // http://stackoverflow.com/questions/2670816/how-can-i-use-the-compile-time-constant-line-in-a-string
......
...@@ -221,6 +221,14 @@ wxPoint DRAWSEGMENT::GetEnd() const ...@@ -221,6 +221,14 @@ wxPoint DRAWSEGMENT::GetEnd() const
} }
void DRAWSEGMENT::SetAngle( double aAngle )
{
NORMALIZE_ANGLE_360( aAngle );
m_Angle = (int) aAngle;
}
MODULE* DRAWSEGMENT::GetParentModule() const MODULE* DRAWSEGMENT::GetParentModule() const
{ {
if( m_Parent->Type() != PCB_MODULE_T ) if( m_Parent->Type() != PCB_MODULE_T )
......
...@@ -46,7 +46,12 @@ public: ...@@ -46,7 +46,12 @@ public:
void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; } void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
void SetAngle( double aAngle ) { m_Angle = (int) aAngle; } /**
* Function SetAngle
* sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
* @param aAngle is tenths of degrees, but will soon be degrees.
*/
void SetAngle( double aAngle ); // encapsulates the transition to degrees
void SetType( int aType ) { m_Type = aType; } void SetType( int aType ) { m_Type = aType; }
......
...@@ -58,7 +58,6 @@ public: ...@@ -58,7 +58,6 @@ public:
*/ */
void DisplayInfo( EDA_DRAW_FRAME* frame ); void DisplayInfo( EDA_DRAW_FRAME* frame );
/** /**
* Function GetClass * Function GetClass
* returns the class name. * returns the class name.
......
...@@ -185,6 +185,17 @@ void D_PAD::SetPadName( const wxString& name ) ...@@ -185,6 +185,17 @@ void D_PAD::SetPadName( const wxString& name )
m_Padname[ii] = 0; m_Padname[ii] = 0;
} }
void D_PAD::SetPadName( const char* aName )
{
unsigned i;
for( i=0; i<sizeof(m_Padname) && *aName; ++i )
m_Padname[i] = *aName++;
while( i < sizeof(m_Padname) )
m_Padname[i++] = 0;
}
/** /**
* Function SetNetname * Function SetNetname
......
...@@ -183,7 +183,20 @@ public: ...@@ -183,7 +183,20 @@ public:
void SetDelta( const wxSize& aSize ) { m_DeltaSize = aSize; } void SetDelta( const wxSize& aSize ) { m_DeltaSize = aSize; }
void SetDrillSize( const wxSize& aSize ) { m_Drill = aSize; } void SetDrillSize( const wxSize& aSize ) { m_Drill = aSize; }
void SetOffset( const wxSize& aOffset ) { m_Offset = aOffset; } void SetOffset( const wxSize& aOffset ) { m_Offset = aOffset; }
void SetOrientation( int aAngle ) { m_Orient = aAngle; }
/**
* Function SetOrientation
* sets the rotation angle of the pad.
* @param aAngle is tenths of degrees, but will soon be degrees.
*/
void SetOrientation( double aAngle ) { m_Orient = (int) aAngle; } // manage migration to degrees
/**
* Function GetOrientation
* returns the rotation angle of the pad in tenths of degress, but soon degress.
*/
double GetOrientation() const { return m_Orient; }
void SetDrillShape( int aDrillShape ) { m_DrillShape = aDrillShape; } void SetDrillShape( int aDrillShape ) { m_DrillShape = aDrillShape; }
void SetLayerMask( int aLayerMask ) { m_layerMask = aLayerMask; } void SetLayerMask( int aLayerMask ) { m_layerMask = aLayerMask; }
void SetAttribute( int aAttribute ) { m_Attribut = aAttribute; } void SetAttribute( int aAttribute ) { m_Attribut = aAttribute; }
...@@ -313,6 +326,7 @@ public: ...@@ -313,6 +326,7 @@ public:
// others // others
void SetPadName( const wxString& name ); // Change pad name void SetPadName( const wxString& name ); // Change pad name
void SetPadName( const char* aName );
wxString ReturnStringPadName() const; // Return pad name as string in a wxString wxString ReturnStringPadName() const; // Return pad name as string in a wxString
......
...@@ -50,11 +50,19 @@ public: ...@@ -50,11 +50,19 @@ public:
return m_Pos; // from EDA_TEXT return m_Pos; // from EDA_TEXT
} }
/// @deprecated it seems
void SetType( int aType ) { m_Type = aType; }
void SetPosition( const wxPoint& aPos ) // overload a base void SetPosition( const wxPoint& aPos ) // overload a base
{ {
m_Pos = aPos; // in EDA_TEXT m_Pos = aPos; // in EDA_TEXT
} }
void SetVisible( bool isVisible ) { m_NoShow = !isVisible; }
void SetInvisible( bool isHidden ) { m_NoShow = isHidden; }
void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; }
void Copy( TEXTE_MODULE* source ); // copy structure void Copy( TEXTE_MODULE* source ); // copy structure
int GetLength() const; /* text length */ int GetLength() const; /* text length */
......
...@@ -280,10 +280,12 @@ this file again." ) ); ...@@ -280,10 +280,12 @@ this file again." ) );
if( !aAppend ) if( !aAppend )
SetBoard( board ); SetBoard( board );
} }
catch ( IO_ERROR ioe ) catch( IO_ERROR ioe )
{ {
// @todo wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
printf( "Error loading board: %s\n", TO_UTF8( ioe.errorText ) ); ioe.errorText.GetData() );
wxMessageBox( msg, _( "Open Board File" ), wxICON_ERROR );
} }
if( !aAppend ) if( !aAppend )
......
...@@ -66,17 +66,15 @@ void IO_MGR::PluginRelease( PLUGIN* aPlugin ) ...@@ -66,17 +66,15 @@ void IO_MGR::PluginRelease( PLUGIN* aPlugin )
} }
const wxString& IO_MGR::ShowType( PCB_FILE_T aFileType ) const wxString IO_MGR::ShowType( PCB_FILE_T aFileType )
{ {
static const wxString kicad = wxT( "KiCad" );
static const wxString unknown = _( "Unknown" );
switch( aFileType ) switch( aFileType )
{ {
case KICAD:
return kicad;
default: default:
return unknown; // could Printf() the numeric value of aFileType return wxString::Format( _( "Unknown PCB_FILE_T value: %d" ), aFileType );
case KICAD:
return wxString( wxT( "KiCad" ) );
} }
} }
...@@ -92,11 +90,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName, ...@@ -92,11 +90,7 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
return pi->Load( aFileName, aAppendToMe, aProperties ); // virtual return pi->Load( aFileName, aAppendToMe, aProperties ); // virtual
} }
wxString msg; THROW_IO_ERROR( wxString::Format( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() ) );
msg.Printf( _( "Plugin type '%s' is not found.\n" ), ShowType( aFileType ).GetData() );
THROW_IO_ERROR( msg );
} }
...@@ -111,11 +105,7 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar ...@@ -111,11 +105,7 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar
return; return;
} }
wxString msg; THROW_IO_ERROR( wxString::Format( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() ) );
msg.Printf( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() );
THROW_IO_ERROR( msg );
} }
...@@ -124,12 +114,8 @@ BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* ...@@ -124,12 +114,8 @@ BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES*
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface, // not pure virtual so that plugins only have to implement subset of the PLUGIN interface,
// e.g. Load() or Save() but not both. // e.g. Load() or Save() but not both.
wxString msg; THROW_IO_ERROR( wxString::Format(
_( "Plugin %s does not implement the BOARD Load() function." ), PluginName().GetData() ) );
msg.Printf( _( "Plugin %s does not implement the BOARD Load() function." ),
PluginName().GetData() );
THROW_IO_ERROR( msg );
} }
...@@ -138,11 +124,6 @@ void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProper ...@@ -138,11 +124,6 @@ void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProper
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface, // not pure virtual so that plugins only have to implement subset of the PLUGIN interface,
// e.g. Load() or Save() but not both. // e.g. Load() or Save() but not both.
wxString msg; THROW_IO_ERROR( wxString::Format(
_( "Plugin %s does not implement the BOARD Save() function." ), PluginName().GetData() ) );
msg.Printf( _( "Plugin %s does not implement the BOARD Save() function." ),
PluginName().GetData() );
THROW_IO_ERROR( msg );
} }
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
WX_DECLARE_STRING_HASH_MAP( wxString, PROPERTIES ); WX_DECLARE_STRING_HASH_MAP( wxString, PROPERTIES );
class BOARD; class BOARD;
class SCHEMATIC;
class PLUGIN; class PLUGIN;
...@@ -88,7 +87,7 @@ public: ...@@ -88,7 +87,7 @@ public:
* Function ShowType * Function ShowType
* returns a brief name for a plugin, given aFileType enum. * returns a brief name for a plugin, given aFileType enum.
*/ */
static const wxString& ShowType( PCB_FILE_T aFileType ); static const wxString ShowType( PCB_FILE_T aFileType );
/** /**
* Function Load * Function Load
...@@ -268,6 +267,8 @@ public: ...@@ -268,6 +267,8 @@ public:
//-----<SCHEMATIC STUFF>------------------------------------------------ //-----<SCHEMATIC STUFF>------------------------------------------------
// Should split into schematic specific PLUGIN base type // Should split into schematic specific PLUGIN base type
class SCHEMATIC;
/** /**
* Function Load * Function Load
* loads a file from some special input file format that * loads a file from some special input file format that
......
This diff is collapsed.
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); // overload BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); // overload
void Save( const wxString* aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload
const wxString& PluginName() const wxString& PluginName()
{ {
...@@ -103,8 +103,10 @@ protected: ...@@ -103,8 +103,10 @@ protected:
BIU biuParse( const char* aValue, const char** nptrptr = NULL ); BIU biuParse( const char* aValue, const char** nptrptr = NULL );
/** /**
* Function dblParse * Function degParse
* parses an ASCII decimal floating point value without scaling into a double. * parses an ASCII decimal floating point value which is certainy an angle. This
* is a dedicated function for encapsulating support for the migration from
* tenths of degrees to degrees in floating point.
* *
* @param aValue is the ASCII value in C locale form with possible leading whitespace * @param aValue is the ASCII value in C locale form with possible leading whitespace
* *
...@@ -113,7 +115,7 @@ protected: ...@@ -113,7 +115,7 @@ protected:
* *
* @return double - the string converted to a primitive double type * @return double - the string converted to a primitive double type
*/ */
double dblParse( const char* aValue, const char** nptrptr = NULL ); double degParse( const char* aValue, const char** nptrptr = NULL );
// load / parse functions // load / parse functions
......
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