CADSTAR Schematic Archive Importer: Load Figures
This commit is contained in:
parent
40c5795c03
commit
da791c5298
|
@ -84,6 +84,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( ::SCHEMATIC* aSchematic, ::SCH_SHEET* aRo
|
|||
loadSchematicSymbolInstances();
|
||||
loadBusses();
|
||||
loadNets();
|
||||
loadFigures();
|
||||
// TODO Load other elements!
|
||||
|
||||
// For all sheets, centre all elements and re calculate the page size:
|
||||
|
@ -632,6 +633,33 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
|
|||
}
|
||||
|
||||
|
||||
void CADSTAR_SCH_ARCHIVE_LOADER::loadFigures()
|
||||
{
|
||||
for( std::pair<FIGURE_ID, FIGURE> figPair : Schematic.Figures )
|
||||
{
|
||||
FIGURE fig = figPair.second;
|
||||
|
||||
if( fig.LayerID == "ALL_SHEETS" )
|
||||
{
|
||||
for( std::pair<LAYER_ID, SHEET_NAME> sheetPair : Sheets.SheetNames )
|
||||
{
|
||||
LAYER_ID sheetID = sheetPair.first;
|
||||
|
||||
loadShapeVertices( fig.Shape.Vertices, fig.LineCodeID, sheetID, LAYER_NOTES );
|
||||
}
|
||||
}
|
||||
else if( fig.LayerID == "NO_SHEET" )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
loadShapeVertices( fig.Shape.Vertices, fig.LineCodeID, fig.LayerID, LAYER_NOTES );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdefID,
|
||||
const PART* aCadstarPart, const GATE_ID& aGateID, LIB_PART* aPart )
|
||||
{
|
||||
|
@ -1047,6 +1075,44 @@ wxString CADSTAR_SCH_ARCHIVE_LOADER::getNetName( const NET_SCH& aNet )
|
|||
}
|
||||
|
||||
|
||||
void CADSTAR_SCH_ARCHIVE_LOADER::loadShapeVertices( const std::vector<VERTEX>& aCadstarVertices,
|
||||
LINECODE_ID aCadstarLineCodeID, LAYER_ID aCadstarSheetID, SCH_LAYER_ID aKiCadSchLayerID )
|
||||
{
|
||||
const VERTEX* prev = &aCadstarVertices.at( 0 );
|
||||
const VERTEX* cur;
|
||||
|
||||
wxASSERT_MSG(
|
||||
prev->Type == VERTEX_TYPE::POINT, "First vertex should always be a point vertex" );
|
||||
|
||||
for( size_t i = 1; i < aCadstarVertices.size(); i++ )
|
||||
{
|
||||
cur = &aCadstarVertices.at( i );
|
||||
|
||||
SCH_LINE* segment = new SCH_LINE();
|
||||
wxPoint startPoint = getKiCadPoint( prev->End );
|
||||
wxPoint endPoint = getKiCadPoint( cur->End );
|
||||
|
||||
segment->SetStartPoint( startPoint );
|
||||
segment->SetEndPoint( endPoint );
|
||||
segment->SetLayer( aKiCadSchLayerID );
|
||||
segment->SetLineWidth( getLineThickness( aCadstarLineCodeID ) );
|
||||
segment->SetLineStyle( getLineStyle( aCadstarLineCodeID ) );
|
||||
|
||||
prev = cur;
|
||||
|
||||
if( mSheetMap.find( aCadstarSheetID ) != mSheetMap.end() )
|
||||
{
|
||||
mSheetMap.at( aCadstarSheetID )->GetScreen()->Append( segment );
|
||||
}
|
||||
else
|
||||
{
|
||||
delete segment;
|
||||
wxASSERT_MSG( false, "Unknown Sheet ID." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(
|
||||
LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize, SCH_SHEET* aParentSheet )
|
||||
{
|
||||
|
@ -1224,6 +1290,28 @@ int CADSTAR_SCH_ARCHIVE_LOADER::getLineThickness( const LINECODE_ID& aCadstarLin
|
|||
}
|
||||
|
||||
|
||||
PLOT_DASH_TYPE CADSTAR_SCH_ARCHIVE_LOADER::getLineStyle( const LINECODE_ID& aCadstarLineCodeID )
|
||||
{
|
||||
wxCHECK( Assignments.Codedefs.LineCodes.find( aCadstarLineCodeID )
|
||||
!= Assignments.Codedefs.LineCodes.end(),
|
||||
PLOT_DASH_TYPE::SOLID );
|
||||
|
||||
// clang-format off
|
||||
switch( Assignments.Codedefs.LineCodes.at( aCadstarLineCodeID ).Style )
|
||||
{
|
||||
case LINESTYLE::DASH: return PLOT_DASH_TYPE::DASH;
|
||||
case LINESTYLE::DASHDOT: return PLOT_DASH_TYPE::DASHDOT;
|
||||
case LINESTYLE::DASHDOTDOT: return PLOT_DASH_TYPE::DASHDOT; //TODO: update in future
|
||||
case LINESTYLE::DOT: return PLOT_DASH_TYPE::DOT;
|
||||
case LINESTYLE::SOLID: return PLOT_DASH_TYPE::SOLID;
|
||||
default: return PLOT_DASH_TYPE::DEFAULT;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
return PLOT_DASH_TYPE();
|
||||
}
|
||||
|
||||
|
||||
CADSTAR_SCH_ARCHIVE_LOADER::TEXTCODE CADSTAR_SCH_ARCHIVE_LOADER::getTextCode(
|
||||
const TEXTCODE_ID& aCadstarTextCodeID )
|
||||
{
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include <sch_plugins/cadstar/cadstar_sch_archive_parser.h>
|
||||
|
||||
#include <layers_id_colors_and_visibility.h> // SCH_LAYER_ID
|
||||
#include <plotter.h> // PLOT_DASH_TYPE
|
||||
#include <sch_io_mgr.h>
|
||||
|
||||
class EDA_TEXT;
|
||||
|
@ -97,6 +99,7 @@ private:
|
|||
void loadSchematicSymbolInstances();
|
||||
void loadBusses();
|
||||
void loadNets();
|
||||
void loadFigures();
|
||||
|
||||
//Helper Functions for loading sheets
|
||||
void loadSheetAndChildSheets( LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize,
|
||||
|
@ -125,16 +128,22 @@ private:
|
|||
POINT getLocationOfNetElement( const NET_SCH& aNet, const NETELEMENT_ID& aNetElementID );
|
||||
wxString getNetName( const NET_SCH& aNet );
|
||||
|
||||
//Helper functions for loading figures / graphical items
|
||||
void loadShapeVertices( const std::vector<VERTEX>& aCadstarVertices,
|
||||
LINECODE_ID aCadstarLineCodeID, LAYER_ID aCadstarSheetID,
|
||||
SCH_LAYER_ID aKiCadSchLayerID );
|
||||
|
||||
//Helper Functions for obtaining CADSTAR elements from the parsed structures
|
||||
SYMDEF_ID getSymDefFromName( const wxString& aSymdefName, const wxString& aSymDefAlternate );
|
||||
wxString generateSymDefName( const SYMDEF_ID& aSymdefID );
|
||||
int getLineThickness( const LINECODE_ID& aCadstarLineCodeID );
|
||||
PART getPart( const PART_ID& aCadstarPartID );
|
||||
ROUTECODE getRouteCode( const ROUTECODE_ID& aCadstarRouteCodeID );
|
||||
TEXTCODE getTextCode( const TEXTCODE_ID& aCadstarTextCodeID );
|
||||
wxString getAttributeName( const ATTRIBUTE_ID& aCadstarAttributeID );
|
||||
wxString getAttributeValue( const ATTRIBUTE_ID& aCadstarAttributeID,
|
||||
const std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE>& aCadstarAttributeMap );
|
||||
PLOT_DASH_TYPE getLineStyle( const LINECODE_ID& aCadstarLineCodeID );
|
||||
PART getPart( const PART_ID& aCadstarPartID );
|
||||
ROUTECODE getRouteCode( const ROUTECODE_ID& aCadstarRouteCodeID );
|
||||
TEXTCODE getTextCode( const TEXTCODE_ID& aCadstarTextCodeID );
|
||||
wxString getAttributeName( const ATTRIBUTE_ID& aCadstarAttributeID );
|
||||
wxString getAttributeValue( const ATTRIBUTE_ID& aCadstarAttributeID,
|
||||
const std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE>& aCadstarAttributeMap );
|
||||
PART::DEFINITION::PIN getPartDefinitionPin(
|
||||
const PART& aCadstarPart, const GATE_ID& aGateID, const TERMINAL_ID& aTerminalID );
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ void CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL_SHAPE::Parse( XNODE* aNode )
|
|||
case TERMINAL_SHAPE_TYPE::DIAMOND:
|
||||
case TERMINAL_SHAPE_TYPE::OCTAGON:
|
||||
case TERMINAL_SHAPE_TYPE::SQUARE:
|
||||
KI_FALLTHROUGH; //don't do anything
|
||||
//don't do anything
|
||||
break;
|
||||
|
||||
case TERMINAL_SHAPE_TYPE::UNDEFINED:
|
||||
|
|
Loading…
Reference in New Issue