Commit 343e55b0 authored by Dick Hollenbeck's avatar Dick Hollenbeck

First working copy of KICAD_PLUGIN::Load()

parent 0fb4954f
......@@ -46,8 +46,8 @@
*/
#define IO_FORMAT _( "IO_ERROR: %s\n from %s : %s" )
#define PARSE_FORMAT _( "PARSE_ERROR: %s in input/source \"%s\", line %d, offset %d\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\nfrom %s : %s" )
// references:
// 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
}
void DRAWSEGMENT::SetAngle( double aAngle )
{
NORMALIZE_ANGLE_360( aAngle );
m_Angle = (int) aAngle;
}
MODULE* DRAWSEGMENT::GetParentModule() const
{
if( m_Parent->Type() != PCB_MODULE_T )
......
......@@ -46,7 +46,12 @@ public:
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; }
......
......@@ -58,7 +58,6 @@ public:
*/
void DisplayInfo( EDA_DRAW_FRAME* frame );
/**
* Function GetClass
* returns the class name.
......
......@@ -185,6 +185,17 @@ void D_PAD::SetPadName( const wxString& name )
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
......
......@@ -183,7 +183,20 @@ public:
void SetDelta( const wxSize& aSize ) { m_DeltaSize = aSize; }
void SetDrillSize( const wxSize& aSize ) { m_Drill = aSize; }
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 SetLayerMask( int aLayerMask ) { m_layerMask = aLayerMask; }
void SetAttribute( int aAttribute ) { m_Attribut = aAttribute; }
......@@ -313,6 +326,7 @@ public:
// others
void SetPadName( const wxString& name ); // Change pad name
void SetPadName( const char* aName );
wxString ReturnStringPadName() const; // Return pad name as string in a wxString
......
......@@ -50,11 +50,19 @@ public:
return m_Pos; // from EDA_TEXT
}
/// @deprecated it seems
void SetType( int aType ) { m_Type = aType; }
void SetPosition( const wxPoint& aPos ) // overload a base
{
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
int GetLength() const; /* text length */
......
......@@ -280,10 +280,12 @@ this file again." ) );
if( !aAppend )
SetBoard( board );
}
catch ( IO_ERROR ioe )
catch( IO_ERROR ioe )
{
// @todo
printf( "Error loading board: %s\n", TO_UTF8( ioe.errorText ) );
wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
ioe.errorText.GetData() );
wxMessageBox( msg, _( "Open Board File" ), wxICON_ERROR );
}
if( !aAppend )
......
......@@ -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 )
{
case KICAD:
return kicad;
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,
return pi->Load( aFileName, aAppendToMe, aProperties ); // virtual
}
wxString msg;
msg.Printf( _( "Plugin type '%s' is not found.\n" ), ShowType( aFileType ).GetData() );
THROW_IO_ERROR( msg );
THROW_IO_ERROR( wxString::Format( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() ) );
}
......@@ -111,11 +105,7 @@ void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoar
return;
}
wxString msg;
msg.Printf( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() );
THROW_IO_ERROR( msg );
THROW_IO_ERROR( wxString::Format( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() ) );
}
......@@ -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,
// e.g. Load() or Save() but not both.
wxString msg;
msg.Printf( _( "Plugin %s does not implement the BOARD Load() function." ),
PluginName().GetData() );
THROW_IO_ERROR( msg );
THROW_IO_ERROR( wxString::Format(
_( "Plugin %s does not implement the BOARD Load() function." ), PluginName().GetData() ) );
}
......@@ -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,
// e.g. Load() or Save() but not both.
wxString msg;
msg.Printf( _( "Plugin %s does not implement the BOARD Save() function." ),
PluginName().GetData() );
THROW_IO_ERROR( msg );
THROW_IO_ERROR( wxString::Format(
_( "Plugin %s does not implement the BOARD Save() function." ), PluginName().GetData() ) );
}
......@@ -34,7 +34,6 @@
WX_DECLARE_STRING_HASH_MAP( wxString, PROPERTIES );
class BOARD;
class SCHEMATIC;
class PLUGIN;
......@@ -88,7 +87,7 @@ public:
* Function ShowType
* 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
......@@ -268,6 +267,8 @@ public:
//-----<SCHEMATIC STUFF>------------------------------------------------
// Should split into schematic specific PLUGIN base type
class SCHEMATIC;
/**
* Function Load
* loads a file from some special input file format that
......
This diff is collapsed.
......@@ -56,7 +56,7 @@ public:
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()
{
......@@ -103,8 +103,10 @@ protected:
BIU biuParse( const char* aValue, const char** nptrptr = NULL );
/**
* Function dblParse
* parses an ASCII decimal floating point value without scaling into a double.
* Function degParse
* 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
*
......@@ -113,7 +115,7 @@ protected:
*
* @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
......
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