diff --git a/pcbnew/import_dxf/dialog_dxf_import.cpp b/pcbnew/import_dxf/dialog_dxf_import.cpp index 7b1e569927..caf0c775b2 100644 --- a/pcbnew/import_dxf/dialog_dxf_import.cpp +++ b/pcbnew/import_dxf/dialog_dxf_import.cpp @@ -7,7 +7,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,12 +39,12 @@ #include // Keys to store setup in config -#define DXF_IMPORT_LAYER_OPTION_KEY wxT("DxfImportBrdLayer") -#define DXF_IMPORT_COORD_ORIGIN_KEY wxT("DxfImportCoordOrigin") -#define DXF_IMPORT_LAST_FILE_KEY wxT("DxfImportLastFile") -#define DXF_IMPORT_GRID_UNITS_KEY wxT("DxfImportGridUnits") -#define DXF_IMPORT_GRID_OFFSET_X_KEY wxT("DxfImportGridOffsetX") -#define DXF_IMPORT_GRID_OFFSET_Y_KEY wxT("DxfImportGridOffsetY") +#define DXF_IMPORT_LAYER_OPTION_KEY "DxfImportBrdLayer" +#define DXF_IMPORT_COORD_ORIGIN_KEY "DxfImportCoordOrigin" +#define DXF_IMPORT_LAST_FILE_KEY "DxfImportLastFile" +#define DXF_IMPORT_GRID_UNITS_KEY "DxfImportGridUnits" +#define DXF_IMPORT_GRID_OFFSET_X_KEY "DxfImportGridOffsetX" +#define DXF_IMPORT_GRID_OFFSET_Y_KEY "DxfImportGridOffsetY" // Static members of DIALOG_DXF_IMPORT, to remember @@ -54,10 +54,11 @@ int DIALOG_DXF_IMPORT::m_offsetSelection = 0; LAYER_NUM DIALOG_DXF_IMPORT::m_layer = Dwgs_User; -DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent ) +DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent, bool aUseModuleItems ) : DIALOG_DXF_IMPORT_BASE( aParent ) { m_parent = aParent; + m_dxfImporter.UseModuleItems( aUseModuleItems ); m_config = Kiface().KifaceSettings(); m_PCBGridUnits = 0; m_PCBGridOffsetX = 0.0; @@ -77,7 +78,7 @@ DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent ) wxString tmpStr; tmpStr << m_PCBGridOffsetX; m_DXFPCBXCoord->SetValue( tmpStr ); - tmpStr = wxT( "" ); + tmpStr = ""; tmpStr << m_PCBGridOffsetY; m_DXFPCBYCoord->SetValue( tmpStr ); @@ -136,7 +137,7 @@ void DIALOG_DXF_IMPORT::OnBrowseDxfFiles( wxCommandEvent& event ) wxFileDialog dlg( m_parent, _( "Open File" ), path, filename, - wxT( "DXF Files (*.dxf)|*.dxf" ), + "DXF Files (*.dxf)|*.dxf", wxFD_OPEN|wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() != wxID_OK ) @@ -238,7 +239,7 @@ bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule ) { wxASSERT( aModule ); - DIALOG_DXF_IMPORT dlg( aCaller ); + DIALOG_DXF_IMPORT dlg( aCaller, true ); bool success = ( dlg.ShowModal() == wxID_OK ); if( success ) @@ -252,37 +253,7 @@ bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule ) for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it ) { - BOARD_ITEM* item = *it; - BOARD_ITEM* converted = NULL; - - // Modules use different types for the same things, - // so we need to convert imported items to appropriate classes. - switch( item->Type() ) - { - case PCB_LINE_T: - { - converted = new EDGE_MODULE( aModule ); - *static_cast( converted ) = *static_cast( item ); - aModule->Add( converted ); - static_cast( converted )->SetLocalCoord(); - delete item; - break; - } - - case PCB_TEXT_T: - { - converted = new TEXTE_MODULE( aModule ); - *static_cast( converted ) = *static_cast( item ); - aModule->Add( converted ); - static_cast( converted )->SetLocalCoord(); - delete item; - break; - } - - default: - wxLogDebug( wxT( "type %d currently not handled" ), item->Type() ); - break; - } + aModule->Add( *it ); } } @@ -305,6 +276,7 @@ int DIALOG_DXF_IMPORT::GetPCBGridUnits( void ) return m_DXFPCBGridUnits->GetSelection(); } + void DIALOG_DXF_IMPORT::GetPCBGridOffsets( double &aXOffset, double &aYOffset ) { aXOffset = DoubleValueFromString( UNSCALED_UNITS, m_DXFPCBXCoord->GetValue() ); diff --git a/pcbnew/import_dxf/dialog_dxf_import.h b/pcbnew/import_dxf/dialog_dxf_import.h index 68944f91e3..91f87de588 100644 --- a/pcbnew/import_dxf/dialog_dxf_import.h +++ b/pcbnew/import_dxf/dialog_dxf_import.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -29,7 +29,7 @@ class DIALOG_DXF_IMPORT : public DIALOG_DXF_IMPORT_BASE { public: - DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent ); + DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent, bool aUseModuleItems = false ); ~DIALOG_DXF_IMPORT(); /** diff --git a/pcbnew/import_dxf/dxf2brd_items.cpp b/pcbnew/import_dxf/dxf2brd_items.cpp index 8efc051449..524f0e981c 100644 --- a/pcbnew/import_dxf/dxf2brd_items.cpp +++ b/pcbnew/import_dxf/dxf2brd_items.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -44,8 +44,10 @@ #include #include #include +#include #include #include +#include #include // minimum bulge value before resorting to a line segment; @@ -98,9 +100,6 @@ bool DXF2BRD_CONVERTER::ImportDxfFile( const wxString& aFile ) } -/* - * Implementation of the method which handles layers. - */ void DXF2BRD_CONVERTER::addLayer( const DRW_Layer& aData ) { // Not yet useful in Pcbnew. @@ -111,12 +110,10 @@ void DXF2BRD_CONVERTER::addLayer( const DRW_Layer& aData ) } -/* - * Import line entities. - */ void DXF2BRD_CONVERTER::addLine( const DRW_Line& aData ) { - DRAWSEGMENT* segm = new DRAWSEGMENT; + DRAWSEGMENT* segm = ( m_useModuleItems ) ? + static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT; segm->SetLayer( ToLAYER_ID( m_brdLayer ) ); wxPoint start( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) ); @@ -148,7 +145,9 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& aData ) continue; } - DRAWSEGMENT* segm = new DRAWSEGMENT( NULL ); + DRAWSEGMENT* segm = ( m_useModuleItems ) ? + static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : + new DRAWSEGMENT; segm->SetLayer( ToLAYER_ID( m_brdLayer ) ); segm->SetStart( segment_startpoint ); @@ -163,7 +162,9 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& aData ) // Polyline flags bit 0 indicates closed (1) or open (0) polyline if( aData.flags & 1 ) { - DRAWSEGMENT* closing_segm = new DRAWSEGMENT( NULL ); + DRAWSEGMENT* closing_segm = ( m_useModuleItems ) ? + static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : + new DRAWSEGMENT; closing_segm->SetLayer( ToLAYER_ID( m_brdLayer ) ); closing_segm->SetStart( segment_startpoint ); @@ -174,6 +175,7 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& aData ) } } + void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& aData ) { // Currently, Pcbnew does not know polylines, for boards. @@ -221,12 +223,11 @@ void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& aData ) } } -/* - * Import Circle entities. - */ + void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& aData ) { - DRAWSEGMENT* segm = new DRAWSEGMENT; + DRAWSEGMENT* segm = ( m_useModuleItems ) ? + static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT; segm->SetLayer( ToLAYER_ID( m_brdLayer ) ); segm->SetShape( S_CIRCLE ); @@ -244,7 +245,8 @@ void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& aData ) */ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data ) { - DRAWSEGMENT* segm = new DRAWSEGMENT; + DRAWSEGMENT* segm = ( m_useModuleItems ) ? + static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT; segm->SetLayer( ToLAYER_ID( m_brdLayer ) ); segm->SetShape( S_ARC ); @@ -276,13 +278,26 @@ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data ) m_newItemsList.push_back( segm ); } -/** - * Import texts (TEXT). - */ + void DXF2BRD_CONVERTER::addText( const DRW_Text& aData ) { - TEXTE_PCB* pcb_text = new TEXTE_PCB( NULL ); - pcb_text->SetLayer( ToLAYER_ID( m_brdLayer ) ); + BOARD_ITEM* brdItem; + EDA_TEXT* textItem; + + if( m_useModuleItems ) + { + TEXTE_MODULE* modText = new TEXTE_MODULE( NULL ); + brdItem = static_cast< BOARD_ITEM* >( modText ); + textItem = static_cast< EDA_TEXT* >( modText ); + } + else + { + TEXTE_PCB* pcbText = new TEXTE_PCB( NULL ); + brdItem = static_cast< BOARD_ITEM* >( pcbText ); + textItem = static_cast< EDA_TEXT* >( pcbText ); + } + + brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) ); wxPoint refPoint( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) ); wxPoint secPoint( mapX( aData.secPoint.x ), mapY( aData.secPoint.y ) ); @@ -299,63 +314,63 @@ void DXF2BRD_CONVERTER::addText( const DRW_Text& aData ) switch( aData.alignV ) { - case DRW_Text::VBaseLine: - pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - break; + case DRW_Text::VBaseLine: + textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + break; - case DRW_Text::VBottom: - pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - break; + case DRW_Text::VBottom: + textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + break; - case DRW_Text::VMiddle: - pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - break; + case DRW_Text::VMiddle: + textItem->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + break; - case DRW_Text::VTop: - pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - break; + case DRW_Text::VTop: + textItem->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + break; } switch( aData.alignH ) { - case DRW_Text::HLeft: - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - break; + case DRW_Text::HLeft: + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + break; - case DRW_Text::HCenter: - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - break; + case DRW_Text::HCenter: + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + break; - case DRW_Text::HRight: - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - break; + case DRW_Text::HRight: + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + break; - case DRW_Text::HAligned: - // no equivalent options in text pcb. - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - break; + case DRW_Text::HAligned: + // no equivalent options in text pcb. + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + break; - case DRW_Text::HMiddle: - // no equivalent options in text pcb. - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - break; + case DRW_Text::HMiddle: + // no equivalent options in text pcb. + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + break; - case DRW_Text::HFit: - // no equivalent options in text pcb. - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - break; + case DRW_Text::HFit: + // no equivalent options in text pcb. + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + break; } #if 0 - wxString sty = wxString::FromUTF8(aData.style.c_str()); - sty=sty.ToLower(); + wxString sty = wxString::FromUTF8( aData.style.c_str() ); + sty = sty.ToLower(); - if (aData.textgen==2) + if( aData.textgen == 2 ) { // Text dir = left to right; - } else if (aData.textgen==4) + } else if( aData.textgen == 4 ) { - / Text dir = top to bottom; + // Text dir = top to bottom; } else { } @@ -363,21 +378,19 @@ void DXF2BRD_CONVERTER::addText( const DRW_Text& aData ) wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) ); - pcb_text->SetTextPosition( refPoint ); - pcb_text->SetOrientation( aData.angle * 10 ); - // The 0.8 factor gives a better height/width ratio with our font - pcb_text->SetWidth( mapDim( aData.height * 0.8 ) ); - pcb_text->SetHeight( mapDim( aData.height ) ); - pcb_text->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) ); - pcb_text->SetText( text ); + textItem->SetTextPosition( refPoint ); + textItem->SetOrientation( aData.angle * 10 ); - m_newItemsList.push_back( pcb_text ); + // The 0.8 factor gives a better height/width ratio with our font + textItem->SetWidth( mapDim( aData.height * 0.8 ) ); + textItem->SetHeight( mapDim( aData.height ) ); + textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) ); + textItem->SetText( text ); + + m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) ); } -/** - * Import multi line texts (MTEXT). - */ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData ) { wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) ); @@ -408,46 +421,63 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData ) text = tmp; } - TEXTE_PCB* pcb_text = new TEXTE_PCB( NULL ); - pcb_text->SetLayer( ToLAYER_ID( m_brdLayer ) ); + BOARD_ITEM* brdItem; + EDA_TEXT* textItem; + + if( m_useModuleItems ) + { + TEXTE_MODULE* modText = new TEXTE_MODULE( NULL ); + brdItem = static_cast< BOARD_ITEM* >( modText ); + textItem = static_cast< EDA_TEXT* >( modText ); + } + else + { + TEXTE_PCB* pcbText = new TEXTE_PCB( NULL ); + brdItem = static_cast< BOARD_ITEM* >( pcbText ); + textItem = static_cast< EDA_TEXT* >( pcbText ); + } + + brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) ); wxPoint textpos( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) ); - pcb_text->SetTextPosition( textpos ); - pcb_text->SetOrientation( aData.angle * 10 ); + + textItem->SetTextPosition( textpos ); + textItem->SetOrientation( aData.angle * 10 ); + // The 0.8 factor gives a better height/width ratio with our font - pcb_text->SetWidth( mapDim( aData.height * 0.8 ) ); - pcb_text->SetHeight( mapDim( aData.height ) ); - pcb_text->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) ); - pcb_text->SetText( text ); + textItem->SetWidth( mapDim( aData.height * 0.8 ) ); + textItem->SetHeight( mapDim( aData.height ) ); + textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) ); + textItem->SetText( text ); // Initialize text justifications: if( aData.textgen <= 3 ) { - pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + textItem->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); } else if( aData.textgen <= 6 ) { - pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + textItem->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); } else { - pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); } if( aData.textgen % 3 == 1 ) { - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); } else if( aData.textgen % 3 == 2 ) { - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); } else { - pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); } #if 0 // These setting have no mening in Pcbnew - if( data.alignH==1 ) + if( data.alignH == 1 ) { // Text is left to right; } @@ -460,7 +490,7 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData ) // use ByStyle; } - if( aData.alignV==1 ) + if( aData.alignV == 1 ) { // use AtLeast; } @@ -470,13 +500,10 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData ) } #endif - m_newItemsList.push_back( pcb_text ); + m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) ); } -/** - * Sets the header variables from the DXF file. - */ void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data ) { std::map::const_iterator it; @@ -497,77 +524,69 @@ void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data ) switch( var->content.i ) { - case 1: // inches - m_DXF2mm = 25.4; - break; + case 1: // inches + m_DXF2mm = 25.4; + break; - case 2: // feet - m_DXF2mm = 304.8; - break; + case 2: // feet + m_DXF2mm = 304.8; + break; - case 5: // centimeters - m_DXF2mm = 10.0; - break; + case 5: // centimeters + m_DXF2mm = 10.0; + break; - case 6: // meters - m_DXF2mm = 1000.0; - break; + case 6: // meters + m_DXF2mm = 1000.0; + break; - case 8: // microinches - m_DXF2mm = 2.54e-5; - break; + case 8: // microinches + m_DXF2mm = 2.54e-5; + break; - case 9: // mils - m_DXF2mm = 0.0254; - break; + case 9: // mils + m_DXF2mm = 0.0254; + break; - case 10: // yards - m_DXF2mm = 914.4; - break; + case 10: // yards + m_DXF2mm = 914.4; + break; - case 11: // Angstroms - m_DXF2mm = 1.0e-7; - break; + case 11: // Angstroms + m_DXF2mm = 1.0e-7; + break; - case 12: // nanometers - m_DXF2mm = 1.0e-6; - break; + case 12: // nanometers + m_DXF2mm = 1.0e-6; + break; - case 13: // micrometers - m_DXF2mm = 1.0e-3; - break; + case 13: // micrometers + m_DXF2mm = 1.0e-3; + break; - case 14: // decimeters - m_DXF2mm = 100.0; - break; + case 14: // decimeters + m_DXF2mm = 100.0; + break; - default: - // use the default of 1.0 for: - // 0: Unspecified Units - // 4: mm - // 3: miles - // 7: kilometers - // 15: decameters - // 16: hectometers - // 17: gigameters - // 18: AU - // 19: lightyears - // 20: parsecs - break; + default: + // use the default of 1.0 for: + // 0: Unspecified Units + // 4: mm + // 3: miles + // 7: kilometers + // 15: decameters + // 16: hectometers + // 17: gigameters + // 18: AU + // 19: lightyears + // 20: parsecs + break; } } } } -/** - * Converts a native unicode string into a DXF encoded string. - * - * DXF endoding includes the following special sequences: - * - %%%c for a diameter sign - * - %%%d for a degree sign - * - %%%p for a plus/minus sign - */ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& aStr ) { wxString res; @@ -622,9 +641,6 @@ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& aStr ) } -/** - * Converts a DXF encoded string into a native Unicode string. - */ wxString DXF2BRD_CONVERTER::toNativeString( const wxString& aData ) { wxString res; @@ -708,7 +724,8 @@ void DXF2BRD_CONVERTER::addTextStyle( const DRW_Textstyle& aData ) void DXF2BRD_CONVERTER::insertLine( const wxRealPoint& aSegStart, const wxRealPoint& aSegEnd, int aWidth ) { - DRAWSEGMENT* segm = new DRAWSEGMENT( NULL ); + DRAWSEGMENT* segm = ( m_useModuleItems ) ? + static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT; wxPoint segment_startpoint( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) ); wxPoint segment_endpoint( Millimeter2iu( aSegEnd.x ), Millimeter2iu( aSegEnd.y ) ); @@ -725,7 +742,8 @@ void DXF2BRD_CONVERTER::insertLine( const wxRealPoint& aSegStart, void DXF2BRD_CONVERTER::insertArc( const wxRealPoint& aSegStart, const wxRealPoint& aSegEnd, double aBulge, int aWidth ) { - DRAWSEGMENT* segm = new DRAWSEGMENT( NULL ); + DRAWSEGMENT* segm = ( m_useModuleItems ) ? + static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT; wxPoint segment_startpoint( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) ); wxPoint segment_endpoint( Millimeter2iu( aSegEnd.x ), Millimeter2iu( aSegEnd.y ) ); diff --git a/pcbnew/import_dxf/dxf2brd_items.h b/pcbnew/import_dxf/dxf2brd_items.h index 7951f39900..7e4f7e9de8 100644 --- a/pcbnew/import_dxf/dxf2brd_items.h +++ b/pcbnew/import_dxf/dxf2brd_items.h @@ -50,11 +50,15 @@ private: int m_brdLayer; // The board layer to place imported DXF items int m_version; // the dxf version, not used here std::string m_codePage; // The code page, not used here + bool m_useModuleItems; // Use module items instead of board items when true. public: DXF2BRD_CONVERTER(); ~DXF2BRD_CONVERTER(); + bool IsUsingModuleItems() const { return m_useModuleItems; } + void UseModuleItems( bool aUseModuleItems = true ) { m_useModuleItems = aUseModuleItems; } + /** * Set the coordinate offset between the importede dxf items * and Pcbnew. @@ -151,7 +155,19 @@ private: virtual void setBlock( const int aHandle ) {} + /** + * Converts a native unicode string into a DXF encoded string. + * + * DXF endoding includes the following special sequences: + * - %%%c for a diameter sign + * - %%%d for a degree sign + * - %%%p for a plus/minus sign + */ static wxString toDxfString( const wxString& aStr ); + + /** + * Converts a DXF encoded string into a native Unicode string. + */ static wxString toNativeString( const wxString& aData ); // These functions are not used in Kicad.