Eeschema Eagle Import: Assign timestamps for modules
This commit is contained in:
parent
f5e7c2ee48
commit
2adc3d48b4
|
@ -26,13 +26,9 @@
|
|||
|
||||
#include <eagle_parser.h>
|
||||
|
||||
#include <wx/xml/xml.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/filename.h>
|
||||
|
||||
#include <convert_to_biu.h>
|
||||
|
||||
using std::string;
|
||||
#include <functional>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
// Template specializations below parse wxString to the used types:
|
||||
// - string
|
||||
|
@ -175,6 +171,25 @@ unsigned long timeStamp( wxXmlNode* aTree )
|
|||
}
|
||||
|
||||
|
||||
time_t moduleTstamp( const string& aName, const string& aValue )
|
||||
{
|
||||
std::size_t h1 = std::hash<string>{}( aName );
|
||||
std::size_t h2 = std::hash<string>{}( aValue );
|
||||
return ((h1 ^ h2 << 1) & 0xffffffff);
|
||||
}
|
||||
|
||||
|
||||
string modulePath( const string& aName, const string& aValue )
|
||||
{
|
||||
std::ostringstream s;
|
||||
|
||||
s << '/' << std::setfill('0') << std::uppercase << std::hex << std::setw(8)
|
||||
<< moduleTstamp( aName, aValue );
|
||||
|
||||
return s.str();
|
||||
}
|
||||
|
||||
|
||||
wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAngle )
|
||||
{
|
||||
// Eagle give us start and end.
|
||||
|
|
|
@ -970,8 +970,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
|
|||
component->SetConvert( 0 );
|
||||
component->SetPosition( wxPoint( einstance.x * EUNIT_TO_MIL, -einstance.y * EUNIT_TO_MIL ) );
|
||||
component->GetField( FOOTPRINT )->SetText( wxString( package ) );
|
||||
// component->SetTimeStamp( parseHex( aReader, line, &line ) ); // TODO we need to find a way
|
||||
// to correlate symbols and footprints
|
||||
component->SetTimeStamp( moduleTstamp( einstance.part, epart->value ? *epart->value : "" ) );
|
||||
// component->AddHierarchicalReference( path, reference, (int)tmp ); // TODO ??
|
||||
|
||||
if( einstance.rot )
|
||||
|
|
|
@ -364,6 +364,13 @@ string makeKey( const string& aFirst, const string& aSecond );
|
|||
/// Make a unique time stamp
|
||||
unsigned long timeStamp( wxXmlNode* aTree );
|
||||
|
||||
/// Computes module path basing on its name and value
|
||||
time_t moduleTstamp( const string& aName, const string& aValue );
|
||||
|
||||
/// Returns module path using the module timestamp
|
||||
// TODO does not handle multisheet schematics correctly
|
||||
string modulePath( const string& aName, const string& aValue );
|
||||
|
||||
/// Convert an Eagle curve end to a KiCad center for S_ARC
|
||||
wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAngle );
|
||||
|
||||
|
|
|
@ -853,6 +853,9 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
|
|||
|
||||
// copy constructor to clone the template
|
||||
MODULE* m = new MODULE( *mi->second );
|
||||
// TODO currently not handled correctly for multisheet schematics
|
||||
//m->SetTimeStamp( moduleTstamp( e.name, e.value ) );
|
||||
//m->SetPath( modulePath( e.name, e.value ) );
|
||||
m_board->Add( m, ADD_APPEND );
|
||||
|
||||
// update the nets within the pads of the clone
|
||||
|
@ -871,18 +874,21 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
|
|||
refanceNamePresetInPackageLayout = true;
|
||||
valueNamePresetInPackageLayout = true;
|
||||
m->SetPosition( wxPoint( kicad_x( e.x ), kicad_y( e.y ) ) );
|
||||
|
||||
// Is >NAME field set in package layout ?
|
||||
if( m->GetReference().size() == 0 )
|
||||
{
|
||||
m->Reference().SetVisible( false ); // No so no show
|
||||
refanceNamePresetInPackageLayout = false;
|
||||
}
|
||||
|
||||
// Is >VALUE field set in package layout
|
||||
if( m->GetValue().size() == 0 )
|
||||
{
|
||||
m->Value().SetVisible( false ); // No so no show
|
||||
valueNamePresetInPackageLayout = false;
|
||||
}
|
||||
|
||||
m->SetReference( FROM_UTF8( e.name.c_str() ) );
|
||||
m->SetValue( FROM_UTF8( e.value.c_str() ) );
|
||||
|
||||
|
@ -890,6 +896,7 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
|
|||
{ // Not smashed so show NAME & VALUE
|
||||
if( valueNamePresetInPackageLayout )
|
||||
m->Value().SetVisible( true ); // Only if place holder in package layout
|
||||
|
||||
if( refanceNamePresetInPackageLayout )
|
||||
m->Reference().SetVisible( true ); // Only if place holder in package layout
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue