Dxf import: fix a bug that disable import of data inside blocks

Provide also a minimal debug info when enabled in code (and only in debug version)
This commit is contained in:
jean-pierre charras 2020-04-19 13:41:54 +02:00
parent e528769637
commit d28fea5502
5 changed files with 1091 additions and 1060 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// C++ code generated with wxFormBuilder (version Jul 10 2019)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -14,56 +14,56 @@
DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerFile;
bSizerFile = new wxBoxSizer( wxHORIZONTAL );
m_staticTextFile = new wxStaticText( this, wxID_ANY, _("File:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextFile->Wrap( -1 );
m_staticTextFile->SetToolTip( _("Only vectors will be imported. Bitmaps and fonts will be ignored.") );
bSizerFile->Add( m_staticTextFile, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_textCtrlFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlFileName->SetToolTip( _("Only vectors will be imported. Bitmaps and fonts will be ignored.") );
m_textCtrlFileName->SetMinSize( wxSize( 300,-1 ) );
bSizerFile->Add( m_textCtrlFileName, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonBrowse->SetToolTip( _("Only vectors will be imported. Bitmaps and fonts will be ignored.") );
bSizerFile->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
bSizerMain->Add( bSizerFile, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer2;
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Placement:") ), wxVERTICAL );
wxBoxSizer* bSizerOptions;
bSizerOptions = new wxBoxSizer( wxVERTICAL );
m_rbInteractivePlacement = new wxRadioButton( sbSizer2->GetStaticBox(), wxID_ANY, _("Interactive placement"), wxDefaultPosition, wxDefaultSize, 0 );
m_rbInteractivePlacement->SetValue( true );
m_rbInteractivePlacement->SetValue( true );
bSizerOptions->Add( m_rbInteractivePlacement, 0, wxBOTTOM|wxEXPAND|wxTOP, 5 );
wxBoxSizer* bSizerUserPos;
bSizerUserPos = new wxBoxSizer( wxHORIZONTAL );
m_rbAbsolutePlacement = new wxRadioButton( sbSizer2->GetStaticBox(), wxID_ANY, _("At"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerUserPos->Add( m_rbAbsolutePlacement, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* bSizerPosSettings;
bSizerPosSettings = new wxBoxSizer( wxHORIZONTAL );
m_staticTextXpos = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextXpos->Wrap( -1 );
bSizerPosSettings->Add( m_staticTextXpos, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_DxfPcbXCoord = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
if ( !m_DxfPcbXCoord->HasFlag( wxTE_MULTILINE ) )
@ -74,13 +74,13 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
m_DxfPcbXCoord->SetMaxLength( 10 );
#endif
m_DxfPcbXCoord->SetToolTip( _("DXF origin on PCB Grid, X Coordinate") );
bSizerPosSettings->Add( m_DxfPcbXCoord, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_staticTextYpos = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextYpos->Wrap( -1 );
bSizerPosSettings->Add( m_staticTextYpos, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_DxfPcbYCoord = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
if ( !m_DxfPcbYCoord->HasFlag( wxTE_MULTILINE ) )
@ -91,109 +91,109 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
m_DxfPcbYCoord->SetMaxLength( 10 );
#endif
m_DxfPcbYCoord->SetToolTip( _("DXF origin on PCB Grid, Y Coordinate") );
bSizerPosSettings->Add( m_DxfPcbYCoord, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_staticTextUnits = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnits->Wrap( -1 );
bSizerPosSettings->Add( m_staticTextUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
wxString m_DxfPcbPositionUnitsChoices[] = { _("mm"), _("inch") };
int m_DxfPcbPositionUnitsNChoices = sizeof( m_DxfPcbPositionUnitsChoices ) / sizeof( wxString );
m_DxfPcbPositionUnits = new wxChoice( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_DxfPcbPositionUnitsNChoices, m_DxfPcbPositionUnitsChoices, 0 );
m_DxfPcbPositionUnits->SetSelection( 0 );
m_DxfPcbPositionUnits->SetToolTip( _("Select PCB grid units") );
bSizerPosSettings->Add( m_DxfPcbPositionUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
bSizerUserPos->Add( bSizerPosSettings, 1, wxBOTTOM|wxEXPAND|wxTOP, 5 );
bSizerOptions->Add( bSizerUserPos, 0, wxEXPAND, 5 );
sbSizer2->Add( bSizerOptions, 1, wxEXPAND|wxLEFT, 20 );
bSizerMain->Add( sbSizer2, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Import parameters:") ), wxVERTICAL );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
bSizer7->Add( 0, 0, 0, wxLEFT|wxRIGHT, 10 );
wxFlexGridSizer* fgSizerImportSettings;
fgSizerImportSettings = new wxFlexGridSizer( 0, 3, 5, 5 );
fgSizerImportSettings->AddGrowableCol( 1 );
fgSizerImportSettings->SetFlexibleDirection( wxBOTH );
fgSizerImportSettings->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticTextLineWidth = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Line width (DXF import):"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextLineWidth->Wrap( -1 );
fgSizerImportSettings->Add( m_staticTextLineWidth, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_textCtrlLineWidth = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerImportSettings->Add( m_textCtrlLineWidth, 0, wxEXPAND, 5 );
wxString m_choiceUnitLineWidthChoices[] = { _("mm"), _("mils"), _("inches") };
int m_choiceUnitLineWidthNChoices = sizeof( m_choiceUnitLineWidthChoices ) / sizeof( wxString );
m_choiceUnitLineWidth = new wxChoice( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceUnitLineWidthNChoices, m_choiceUnitLineWidthChoices, 0 );
m_choiceUnitLineWidth->SetSelection( 0 );
fgSizerImportSettings->Add( m_choiceUnitLineWidth, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_staticTextBrdlayer = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Graphic layer:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextBrdlayer->Wrap( -1 );
fgSizerImportSettings->Add( m_staticTextBrdlayer, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
fgSizerImportSettings->Add( m_SelLayerBox, 0, wxEXPAND, 5 );
fgSizerImportSettings->Add( 0, 0, 0, 0, 5 );
m_staticTextscale = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Import scale:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextscale->Wrap( -1 );
fgSizerImportSettings->Add( m_staticTextscale, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_textCtrlImportScale = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerImportSettings->Add( m_textCtrlImportScale, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
fgSizerImportSettings->Add( 0, 0, 0, 0, 5 );
bSizer7->Add( fgSizerImportSettings, 1, wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP, 5 );
sbSizer1->Add( bSizer7, 1, wxEXPAND, 5 );
bSizerMain->Add( sbSizer1, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
bSizerMain->Add( 0, 0, 0, wxEXPAND, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
// Connect Events
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onBrowseFiles ), NULL, this );
m_rbInteractivePlacement->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onInteractivePlacement ), NULL, this );
@ -214,5 +214,5 @@ DIALOG_IMPORT_GFX_BASE::~DIALOG_IMPORT_GFX_BASE()
m_rbAbsolutePlacement->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::originOptionOnUpdateUI ), NULL, this );
m_DxfPcbPositionUnits->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onUnitPositionSelection ), NULL, this );
m_choiceUnitLineWidth->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onUnitWidthSelection ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,11 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// C++ code generated with wxFormBuilder (version Jul 10 2019)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_IMPORT_GFX_BASE_H__
#define __DIALOG_IMPORT_GFX_BASE_H__
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
@ -21,6 +20,9 @@ class PCB_LAYER_BOX_SELECTOR;
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/radiobut.h>
@ -39,7 +41,7 @@ class PCB_LAYER_BOX_SELECTOR;
class DIALOG_IMPORT_GFX_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_staticTextFile;
wxTextCtrl* m_textCtrlFileName;
@ -62,7 +64,7 @@ class DIALOG_IMPORT_GFX_BASE : public DIALOG_SHIM
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void onBrowseFiles( wxCommandEvent& event ) { event.Skip(); }
virtual void onInteractivePlacement( wxCommandEvent& event ) { event.Skip(); }
@ -70,13 +72,12 @@ class DIALOG_IMPORT_GFX_BASE : public DIALOG_SHIM
virtual void onAbsolutePlacement( wxCommandEvent& event ) { event.Skip(); }
virtual void onUnitPositionSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void onUnitWidthSelection( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Import Vector Graphics File"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Import Vector Graphics File"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_IMPORT_GFX_BASE();
};
#endif //__DIALOG_IMPORT_GFX_BASE_H__

View File

@ -332,10 +332,9 @@ void DXF_IMPORT_PLUGIN::endEntity()
void DXF_IMPORT_PLUGIN::addBlock( const DL_BlockData& aData )
{
// The DXF blocks are not useful in our import, so we skip them with the exception
// of the main block that is shown when editing the file
if( aData.name.compare( "*Model_Space") )
m_inBlock = true;
// The DXF blocks are not useful in our import, so we skip the block id
// because Pcbnew has no support to group a set of graphic items inside an entity
m_inBlock = false;
}

View File

@ -115,6 +115,13 @@ public:
* This class import DXF ASCII files and convert basic entities to board entities.
* It depends on the dxflib library.
*/
#if 0 //defined(DEBUG)
// For dxf import debug:
#define ON_UNSUPPORTED( error_msg ) wxLogMessage( error_msg )
#else
#define ON_UNSUPPORTED( error_msg )
#endif
class DXF_IMPORT_PLUGIN : public GRAPHICS_IMPORT_PLUGIN, public DL_CreationAdapter
{
private:
@ -299,37 +306,61 @@ private:
virtual void addKnot( const DL_KnotData& aData ) override;
// Not yet handled DXF entities:
virtual void addXLine( const DL_XLineData& ) override { ON_UNSUPPORTED( "addXLine" ); }
virtual void addRay( const DL_RayData& ) override { ON_UNSUPPORTED( "addRay" ); }
virtual void addArcAlignedText( const DL_ArcAlignedTextData& ) override
{ ON_UNSUPPORTED( "addArcAlignedText" ); }
virtual void addAttribute( const DL_AttributeData& ) override
{ ON_UNSUPPORTED( "addAttribute" ); }
virtual void addDimAlign( const DL_DimensionData&,
const DL_DimAlignedData& ) override {}
const DL_DimAlignedData& ) override { ON_UNSUPPORTED( "addDimAlign" ); }
virtual void addDimLinear( const DL_DimensionData&,
const DL_DimLinearData& ) override {}
const DL_DimLinearData& ) override { ON_UNSUPPORTED( "addDimLinear" ); }
virtual void addDimRadial( const DL_DimensionData&,
const DL_DimRadialData& ) override {}
const DL_DimRadialData& ) override { ON_UNSUPPORTED( "addDimRadial" ); }
virtual void addDimDiametric( const DL_DimensionData&,
const DL_DimDiametricData& ) override {}
const DL_DimDiametricData& ) override { ON_UNSUPPORTED( "addDimDiametric" ); }
virtual void addDimAngular( const DL_DimensionData&,
const DL_DimAngularData& ) override {}
const DL_DimAngularData& ) override { ON_UNSUPPORTED( "addDimAngular" ); }
virtual void addDimAngular3P( const DL_DimensionData&,
const DL_DimAngular3PData& ) override {}
const DL_DimAngular3PData& ) override { ON_UNSUPPORTED( "addDimAngular3P" ); }
virtual void addDimOrdinate( const DL_DimensionData&,
const DL_DimOrdinateData& ) override {}
virtual void addLeader( const DL_LeaderData& ) override {}
const DL_DimOrdinateData& ) override { ON_UNSUPPORTED( "addDimOrdinate" ); }
virtual void addLeaderVertex( const DL_LeaderVertexData& ) override {}
virtual void addLeader( const DL_LeaderData& ) override
{ ON_UNSUPPORTED( "addLeader" ); }
virtual void addHatch( const DL_HatchData& ) override {}
virtual void addLeaderVertex( const DL_LeaderVertexData& ) override
{ ON_UNSUPPORTED( "addLeaderVertex" ); }
virtual void addTrace( const DL_TraceData& ) override {}
virtual void add3dFace( const DL_3dFaceData& ) override {}
virtual void addHatch( const DL_HatchData& ) override { ON_UNSUPPORTED( "addHatch" ); }
virtual void addSolid( const DL_SolidData& ) override {}
virtual void addTrace( const DL_TraceData& ) override { ON_UNSUPPORTED( "addTrace" ); }
virtual void add3dFace( const DL_3dFaceData& ) override { ON_UNSUPPORTED( "add3dFace" ); }
virtual void addImage( const DL_ImageData& ) override {}
virtual void addSolid( const DL_SolidData& ) override { ON_UNSUPPORTED( "addSolid" ); }
virtual void addImage( const DL_ImageData& ) override { ON_UNSUPPORTED( "addImage" ); }
virtual void linkImage( const DL_ImageDefData& ) override {}
virtual void addHatchLoop( const DL_HatchLoopData& ) override {}
virtual void addHatchLoop( const DL_HatchLoopData& ) override { ON_UNSUPPORTED( "addHatchLoop" ); }
virtual void addHatchEdge( const DL_HatchEdgeData& ) override {}
virtual void addHatchEdge( const DL_HatchEdgeData& ) override { ON_UNSUPPORTED( "addHatchEdge" ); }
virtual void addXRecord( const std::string& ) override { ON_UNSUPPORTED( "addXRecord" ); }
virtual void addXRecordString( int, const std::string& ) override { ON_UNSUPPORTED( "addXRecordString" ); }
virtual void addXRecordReal( int, double ) override { ON_UNSUPPORTED( "addXRecordReal" ); }
virtual void addXRecordInt( int, int ) override { ON_UNSUPPORTED( "addXRecordInt" ); }
virtual void addXRecordBool( int, bool ) override { ON_UNSUPPORTED( "addXRecordBool" ); }
virtual void addXDataApp( const std::string& ) override { ON_UNSUPPORTED( "addXDataApp" ); }
virtual void addXDataString( int, const std::string& ) override { ON_UNSUPPORTED( "addXDataString" ); }
virtual void addXDataReal( int, double ) override { ON_UNSUPPORTED( "addXDataReal" ); }
virtual void addXDataInt( int, int ) override { ON_UNSUPPORTED( "addXDataInt" ); }
/**
* Convert a native unicode string into a DXF encoded string.