Fields: preserve field order across sch<->pcb
This commit is contained in:
parent
25de3e6b33
commit
30eae5d896
|
@ -34,6 +34,7 @@
|
|||
#include <core/kicad_algo.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <xnode.h> // also nests: <wx/xml/xml.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <symbol_lib_table.h>
|
||||
|
||||
|
@ -98,7 +99,7 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
|||
wxString datasheet;
|
||||
wxString description;
|
||||
wxString candidate;
|
||||
std::map<wxString, wxString> userFields;
|
||||
nlohmann::ordered_map<wxString, wxString> userFields;
|
||||
|
||||
if( aSymbol->GetUnitCount() > 1 )
|
||||
{
|
||||
|
@ -235,7 +236,6 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
|||
UnescapeString( TEMPLATE_FIELDNAME::GetDefaultFieldName( DESCRIPTION_FIELD ) ) );
|
||||
xfields->AddChild( descriptionField );
|
||||
|
||||
// non MANDATORY fields are output alphabetically
|
||||
for( const std::pair<const wxString, wxString>& f : userFields )
|
||||
{
|
||||
XNODE* xfield = node( wxT( "field" ), UnescapeString( f.second ) );
|
||||
|
|
|
@ -563,7 +563,7 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
}
|
||||
}
|
||||
|
||||
std::map<wxString, wxString> fields;
|
||||
nlohmann::ordered_map<wxString, wxString> fields;
|
||||
for( PCB_FIELD* field : footprint->Fields() )
|
||||
fields[field->GetCanonicalName()] = field->GetText();
|
||||
|
||||
|
|
|
@ -344,7 +344,7 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
|
|||
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
|
||||
}
|
||||
|
||||
std::map<wxString, wxString> fpFieldsAsMap;
|
||||
nlohmann::ordered_map<wxString, wxString> fpFieldsAsMap;
|
||||
for( PCB_FIELD* field : aPcbFootprint->GetFields() )
|
||||
{
|
||||
// These fields are individually checked above, and are not currently present in (fields) anyway.
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <netlist_lexer.h> // netlist_lexer is common to Eeschema and Pcbnew
|
||||
#include <macros.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "pcb_netlist.h"
|
||||
#include "netlist_reader.h"
|
||||
|
@ -310,7 +311,7 @@ void KICAD_NETLIST_PARSER::parseComponent()
|
|||
|
||||
std::vector<KIID> uuids;
|
||||
std::map<wxString, wxString> properties;
|
||||
std::map<wxString, wxString> fields;
|
||||
nlohmann::ordered_map<wxString, wxString> fields;
|
||||
|
||||
// The token comp was read, so the next data is (ref P1)
|
||||
while( (token = NextTok() ) != T_RIGHT )
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
#include <wx/arrstr.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <lib_id.h>
|
||||
#include <footprint.h>
|
||||
|
@ -128,8 +129,11 @@ public:
|
|||
void SetValue( const wxString& aValue ) { m_value = aValue; }
|
||||
const wxString& GetValue() const { return m_value; }
|
||||
|
||||
void SetFields( std::map<wxString, wxString>& aFields ) { m_fields = std::move( aFields ); }
|
||||
const std::map<wxString, wxString>& GetFields() const { return m_fields; }
|
||||
void SetFields( nlohmann::ordered_map<wxString, wxString>& aFields )
|
||||
{
|
||||
m_fields = std::move( aFields );
|
||||
}
|
||||
const nlohmann::ordered_map<wxString, wxString>& GetFields() const { return m_fields; }
|
||||
|
||||
void SetProperties( std::map<wxString, wxString>& aProps )
|
||||
{
|
||||
|
@ -202,7 +206,7 @@ private:
|
|||
std::map<wxString, wxString> m_properties;
|
||||
|
||||
/// Component-specific user fields found in the netlist.
|
||||
std::map<wxString, wxString> m_fields;
|
||||
nlohmann::ordered_map<wxString, wxString> m_fields;
|
||||
|
||||
static COMPONENT_NET m_emptyNet;
|
||||
};
|
||||
|
|
|
@ -473,7 +473,7 @@ int BOARD_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
std::map<wxString, wxString> fields;
|
||||
nlohmann::ordered_map<wxString, wxString> fields;
|
||||
for( PCB_FIELD* field : footprint->Fields() )
|
||||
fields[field->GetCanonicalName()] = field->GetText();
|
||||
|
||||
|
|
Loading…
Reference in New Issue