diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 8d6ed41883..6d0aee62ad 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -103,56 +103,67 @@ static int countChildren( wxXmlNode* aCurrentNode, const std::string& aName ) return count; } - -static SCH_LAYER_ID kicadLayer( int aEagleLayer ) +void SCH_EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers ) { - /** - * Layers in Kicad schematics are not actually layers, but abstract groups mainly used to - * decide item colours. - * - * - * - * - * - * - * - * - * - * - * - * - */ + std::vector eagleLayers; - switch( aEagleLayer ) + // Get the first layer and iterate + wxXmlNode* layerNode = aLayers->GetChildren(); + + // find the subset of layers that are copper, and active + while( layerNode ) { - case 90: - break; + ELAYER elayer( layerNode ); + eagleLayers.push_back(elayer); - case 91: - return LAYER_WIRE; - - case 92: - return LAYER_BUS; - - case 93: - break; - - case 94: - break; - - case 95: - break; - - case 96: - break; - - case 97: - return LAYER_NOTES; - - case 98: - break; + layerNode = layerNode->GetNext(); + } + + for( const auto &elayer : eagleLayers ) + { + /** + * Layers in Kicad schematics are not actually layers, but abstract groups mainly used to + * decide item colours. + * + * + * + * + * + * + * + * + * + * + * + * + */ + + if(elayer.name == "Nets") + { + m_LayerMap[elayer.number] = LAYER_WIRE; + } + else if(elayer.name == "Info" || elayer.name == "Guide") + { + m_LayerMap[elayer.number] = LAYER_NOTES; + } + else if(elayer.name == "Busses") + { + m_LayerMap[elayer.number] = LAYER_BUS; + } + } +} + + +SCH_LAYER_ID SCH_EAGLE_PLUGIN::kicadLayer( int aEagleLayer ) +{ + if(m_LayerMap.find(aEagleLayer) == m_LayerMap.end() ) + { + return LAYER_NOTES; + } + else + { + return m_LayerMap[aEagleLayer]; } - return LAYER_NOTES; } @@ -363,7 +374,8 @@ void SCH_EAGLE_PLUGIN::loadDrawing( wxXmlNode* aDrawingNode ) // wxXmlNode* grid = drawingChildren["grid"] // TODO: handle layers nodes - // wxXmlNode* layers = drawingChildren["layers"] + wxXmlNode* layers = drawingChildren["layers"]; + loadLayerDefs(layers); // TODO: handle library nodes // wxXmlNode* library = drawingChildren["library"] diff --git a/eeschema/sch_eagle_plugin.h b/eeschema/sch_eagle_plugin.h index aa0c41b108..db919e405b 100644 --- a/eeschema/sch_eagle_plugin.h +++ b/eeschema/sch_eagle_plugin.h @@ -129,6 +129,7 @@ public: private: void loadDrawing( wxXmlNode* aDrawingNode ); + void loadLayerDefs( wxXmlNode* aLayers ); void loadSchematic( wxXmlNode* aSchematicNode ); void loadSheet( wxXmlNode* aSheetNode ); void loadInstance( wxXmlNode* aInstanceNode ); @@ -137,6 +138,7 @@ private: void countNets( wxXmlNode* aSchematicNode ); void addBusEntries(); + SCH_LAYER_ID kicadLayer( int aEagleLayer ); wxPoint findNearestLinePoint(wxPoint aPoint, const DLIST< SCH_LINE >& lines); void loadSegments( wxXmlNode* aSegmentsNode, const wxString& aNetName, @@ -166,7 +168,7 @@ private: EDA_RECT sheetBoundingBox; std::map m_NetCounts; - + std::map m_LayerMap; protected: };