From b089630b4ca0ca201e061bde1e7e644e59a48805 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 18 Oct 2023 14:20:34 +0100 Subject: [PATCH] Simplify Import Graphics. Removed no-longer-required differentiation between importing footprint vs board objects. Renamed files to match the dialog. Made Position At and Set Layer optional checkboxes. Removed Group Items checkbox. (In the unlikely event that you don't want a group, do an UnGroup after importing.) Flattened out labelled-sizers in the dialog. Removed importers blacklist, which hasn't been active for at least 4 years. Fixed undo/redo bug that caused items to be no-longer-grouped after a redo. --- common/import_gfx/graphics_import_mgr.cpp | 32 +- common/import_gfx/graphics_import_mgr.h | 18 +- common/import_gfx/graphics_import_plugin.h | 9 +- common/widgets/unit_binder.cpp | 4 +- eeschema/import_gfx/dialog_import_gfx_sch.cpp | 16 +- pcbnew/CMakeLists.txt | 4 +- .../import_gfx/dialog_import_gfx_pcb_base.cpp | 283 --- .../import_gfx/dialog_import_gfx_pcb_base.fbp | 1989 ----------------- ...gfx_pcb.cpp => dialog_import_graphics.cpp} | 117 +- ...ort_gfx_pcb.h => dialog_import_graphics.h} | 48 +- .../dialog_import_graphics_base.cpp | 194 ++ .../dialog_import_graphics_base.fbp | 1628 ++++++++++++++ ...b_base.h => dialog_import_graphics_base.h} | 49 +- .../import_gfx/graphics_importer_pcbnew.cpp | 38 +- pcbnew/import_gfx/graphics_importer_pcbnew.h | 68 +- pcbnew/tools/drawing_tool.cpp | 45 +- 16 files changed, 1957 insertions(+), 2585 deletions(-) delete mode 100644 pcbnew/import_gfx/dialog_import_gfx_pcb_base.cpp delete mode 100644 pcbnew/import_gfx/dialog_import_gfx_pcb_base.fbp rename pcbnew/import_gfx/{dialog_import_gfx_pcb.cpp => dialog_import_graphics.cpp} (70%) rename pcbnew/import_gfx/{dialog_import_gfx_pcb.h => dialog_import_graphics.h} (68%) create mode 100644 pcbnew/import_gfx/dialog_import_graphics_base.cpp create mode 100644 pcbnew/import_gfx/dialog_import_graphics_base.fbp rename pcbnew/import_gfx/{dialog_import_gfx_pcb_base.h => dialog_import_graphics_base.h} (63%) diff --git a/common/import_gfx/graphics_import_mgr.cpp b/common/import_gfx/graphics_import_mgr.cpp index 6041dc4f74..bf50e10c87 100644 --- a/common/import_gfx/graphics_import_mgr.cpp +++ b/common/import_gfx/graphics_import_mgr.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2016 CERN + * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -24,40 +25,21 @@ #include "graphics_import_mgr.h" -#include #include #include "dxf_import_plugin.h" #include "svg_import_plugin.h" #include -GRAPHICS_IMPORT_MGR::GRAPHICS_IMPORT_MGR( const TYPE_LIST& aBlacklist ) -{ - // This is the full list of types, from which we'll subtract our blacklist - static const TYPE_LIST all_types = { - DXF, - SVG, - }; - - std::copy_if( all_types.begin(), all_types.end(), std::back_inserter( m_importableTypes ), - [&aBlacklist]( const GFX_FILE_T& arg ) - { - return !alg::contains( aBlacklist, arg ); - } ); -} - - std::unique_ptr GRAPHICS_IMPORT_MGR::GetPlugin( GFX_FILE_T aType ) const { std::unique_ptr ret; switch( aType ) { - case DXF: ret = std::make_unique(); break; - - case SVG: ret = std::make_unique(); break; - - default: throw std::runtime_error( "Unhandled graphics format" ); break; + case DXF: ret = std::make_unique(); break; + case SVG: ret = std::make_unique(); break; + default: throw std::runtime_error( "Unhandled graphics format" ); break; } return ret; @@ -67,10 +49,10 @@ std::unique_ptr GRAPHICS_IMPORT_MGR::GetPlugin( GFX_FILE std::unique_ptr GRAPHICS_IMPORT_MGR::GetPluginByExt( const wxString& aExtension ) const { - for( auto fileType : GetImportableFileTypes() ) + for( GRAPHICS_IMPORT_MGR::GFX_FILE_T fileType : GetImportableFileTypes() ) { - auto plugin = GetPlugin( fileType ); - auto fileExtensions = plugin->GetFileExtensions(); + std::unique_ptr plugin = GetPlugin( fileType ); + const std::vector& fileExtensions = plugin->GetFileExtensions(); if( compareFileExtensions( aExtension.ToStdString(), fileExtensions ) ) return plugin; diff --git a/common/import_gfx/graphics_import_mgr.h b/common/import_gfx/graphics_import_mgr.h index 10fff3799c..d5c641d3ca 100644 --- a/common/import_gfx/graphics_import_mgr.h +++ b/common/import_gfx/graphics_import_mgr.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2016 CERN - * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors. * * @author Maciej Suminski * @@ -46,19 +46,10 @@ public: SVG }; - using TYPE_LIST = std::vector; - - /** - * Construct an import plugin manager, with a specified list of filetypes - * that are not permitted (can be used for when some file type support - * is not available due to config or other reasons) - */ - GRAPHICS_IMPORT_MGR( const TYPE_LIST& aBlacklist ); - ///< Vector containing all GFX_FILE_T values that can be imported. - TYPE_LIST GetImportableFileTypes() const + std::vector GetImportableFileTypes() const { - return m_importableTypes; + return { DXF, SVG }; } ///< Returns a plugin that handles a specific file extension. @@ -66,9 +57,6 @@ public: ///< Returns a plugin instance for a specific file type. std::unique_ptr GetPlugin( GFX_FILE_T aType ) const; - -private: - TYPE_LIST m_importableTypes; }; #endif /* GRAPHICS_IMPORT_MGR_H */ diff --git a/common/import_gfx/graphics_import_plugin.h b/common/import_gfx/graphics_import_plugin.h index c6189505db..4db938ac53 100644 --- a/common/import_gfx/graphics_import_plugin.h +++ b/common/import_gfx/graphics_import_plugin.h @@ -39,17 +39,12 @@ class GRAPHICS_IMPORTER; class GRAPHICS_IMPORT_PLUGIN { public: - virtual ~GRAPHICS_IMPORT_PLUGIN() - { - } + virtual ~GRAPHICS_IMPORT_PLUGIN() { } /** * Set the receiver of the imported shapes. */ - virtual void SetImporter( GRAPHICS_IMPORTER* aImporter ) - { - m_importer = aImporter; - } + virtual void SetImporter( GRAPHICS_IMPORTER* aImporter ) { m_importer = aImporter; } /** * Return the plugin name. diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 4b5600195b..36da267f0f 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -591,7 +591,9 @@ void UNIT_BINDER::SetLabel( const wxString& aLabel ) void UNIT_BINDER::Enable( bool aEnable ) { - m_label->Enable( aEnable ); + if( m_label ) + m_label->Enable( aEnable ); + m_valueCtrl->Enable( aEnable ); if( m_unitLabel ) diff --git a/eeschema/import_gfx/dialog_import_gfx_sch.cpp b/eeschema/import_gfx/dialog_import_gfx_sch.cpp index ea070a081d..011d59545f 100644 --- a/eeschema/import_gfx/dialog_import_gfx_sch.cpp +++ b/eeschema/import_gfx/dialog_import_gfx_sch.cpp @@ -108,21 +108,7 @@ DIALOG_IMPORT_GFX_SCH::DIALOG_IMPORT_GFX_SCH( SCH_BASE_FRAME* aParent ) : initWidgetsFromSettings( cfg ); } - // construct an import manager with options from config - { - GRAPHICS_IMPORT_MGR::TYPE_LIST blacklist; - // Currently: all types are allowed, so the blacklist is empty - // (no GFX_FILE_T in the blacklist) - // To disable SVG import, enable these 2 lines - // if( !ADVANCED_CFG::GetCfg().m_enableSvgImport ) - // blacklist.push_back( GRAPHICS_IMPORT_MGR::SVG ); - // The SVG import has currently a flaw: all SVG shapes are imported as curves and - // converted to a lot of segments. A better approach is to convert to polylines - // (not yet existing in Pcbnew) and keep arcs and circles as primitives (not yet - // possible with tinysvg library). - - m_gfxImportMgr = std::make_unique( blacklist ); - } + m_gfxImportMgr = std::make_unique(); wxCommandEvent dummy; onFilename( dummy ); diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index b303fe2d02..a18f7dc834 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -198,8 +198,8 @@ set( PCBNEW_BRDSTACKUP_MGR ) set( PCBNEW_IMPORT_GFX - import_gfx/dialog_import_gfx_pcb_base.cpp - import_gfx/dialog_import_gfx_pcb.cpp + import_gfx/dialog_import_graphics.cpp + import_gfx/dialog_import_graphics_base.cpp import_gfx/graphics_importer_pcbnew.cpp ) diff --git a/pcbnew/import_gfx/dialog_import_gfx_pcb_base.cpp b/pcbnew/import_gfx/dialog_import_gfx_pcb_base.cpp deleted file mode 100644 index fb64ca9975..0000000000 --- a/pcbnew/import_gfx/dialog_import_gfx_pcb_base.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "pcb_layer_box_selector.h" -#include "widgets/std_bitmap_button.h" - -#include "dialog_import_gfx_pcb_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_IMPORT_GFX_PCB_BASE::DIALOG_IMPORT_GFX_PCB_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, 5 ); - - m_browseButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 ); - bSizerFile->Add( m_browseButton, 0, wxTOP|wxBOTTOM, 5 ); - - - bSizerMain->Add( bSizerFile, 0, wxALL|wxEXPAND, 10 ); - - 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 ); - bSizerOptions->Add( m_rbInteractivePlacement, 0, wxEXPAND|wxBOTTOM, 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_xLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_xLabel->Wrap( -1 ); - bSizerPosSettings->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); - - m_xCtrl = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - #ifdef __WXGTK__ - if ( !m_xCtrl->HasFlag( wxTE_MULTILINE ) ) - { - m_xCtrl->SetMaxLength( 10 ); - } - #else - m_xCtrl->SetMaxLength( 10 ); - #endif - m_xCtrl->SetToolTip( _("DXF origin on PCB Grid, X Coordinate") ); - - bSizerPosSettings->Add( m_xCtrl, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_xUnits = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_xUnits->Wrap( -1 ); - bSizerPosSettings->Add( m_xUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 ); - - m_yLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_yLabel->Wrap( -1 ); - bSizerPosSettings->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); - - m_yCtrl = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - #ifdef __WXGTK__ - if ( !m_yCtrl->HasFlag( wxTE_MULTILINE ) ) - { - m_yCtrl->SetMaxLength( 10 ); - } - #else - m_yCtrl->SetMaxLength( 10 ); - #endif - m_yCtrl->SetToolTip( _("DXF origin on PCB Grid, Y Coordinate") ); - - bSizerPosSettings->Add( m_yCtrl, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_yUnits = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_yUnits->Wrap( -1 ); - bSizerPosSettings->Add( m_yUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - bSizerUserPos->Add( bSizerPosSettings, 1, wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP, 5 ); - - - bSizerOptions->Add( bSizerUserPos, 0, wxEXPAND, 5 ); - - - sbSizer2->Add( bSizerOptions, 0, wxEXPAND, 5 ); - - - bSizerMain->Add( sbSizer2, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); - - wxStaticBoxSizer* sbSizer1; - sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Import Parameters") ), wxVERTICAL ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxHORIZONTAL ); - - wxFlexGridSizer* fgSizerImportSettings; - fgSizerImportSettings = new wxFlexGridSizer( 0, 3, 5, 5 ); - fgSizerImportSettings->AddGrowableCol( 1 ); - fgSizerImportSettings->SetFlexibleDirection( wxBOTH ); - fgSizerImportSettings->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - 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 ); - fgSizerImportSettings->Add( m_SelLayerBox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - - fgSizerImportSettings->Add( 0, 0, 0, 0, 5 ); - - m_importScaleLabel = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Import scale:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_importScaleLabel->Wrap( -1 ); - fgSizerImportSettings->Add( m_importScaleLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_importScaleCtrl = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerImportSettings->Add( m_importScaleCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - - fgSizerImportSettings->Add( 0, 0, 1, wxEXPAND, 5 ); - - - bSizer7->Add( fgSizerImportSettings, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - - - sbSizer1->Add( bSizer7, 1, wxEXPAND, 5 ); - - m_staticline1 = new wxStaticLine( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - sbSizer1->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - wxBoxSizer* bSizer71; - bSizer71 = new wxBoxSizer( wxVERTICAL ); - - m_rbFixDiscontinuities = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Fix discontinuities"), wxDefaultPosition, wxDefaultSize, 0 ); - m_rbFixDiscontinuities->SetToolTip( _("Trim/extend open shapes or add segments to make vertices of shapes coincide") ); - - bSizer71->Add( m_rbFixDiscontinuities, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - wxBoxSizer* bSizer14; - bSizer14 = new wxBoxSizer( wxHORIZONTAL ); - - m_toleranceLabel = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Tolerance:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_toleranceLabel->Wrap( -1 ); - bSizer14->Add( m_toleranceLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_toleranceCtrl = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer14->Add( m_toleranceCtrl, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_toleranceUnits = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_toleranceUnits->Wrap( -1 ); - bSizer14->Add( m_toleranceUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - bSizer71->Add( bSizer14, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - - sbSizer1->Add( bSizer71, 0, wxEXPAND, 5 ); - - m_staticline11 = new wxStaticLine( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - sbSizer1->Add( m_staticline11, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - wxBoxSizer* bSizer8; - bSizer8 = new wxBoxSizer( wxVERTICAL ); - - m_groupItems = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Group items"), wxDefaultPosition, wxDefaultSize, 0 ); - m_groupItems->SetToolTip( _("Add all imported items into a new group") ); - - bSizer8->Add( m_groupItems, 0, wxEXPAND|wxBOTTOM|wxLEFT, 5 ); - - - sbSizer1->Add( bSizer8, 0, wxEXPAND|wxTOP, 5 ); - - - bSizerMain->Add( sbSizer1, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); - - wxStaticBoxSizer* sbSizer3; - sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("DXF Parameters") ), wxVERTICAL ); - - wxBoxSizer* bSizer81; - bSizer81 = new wxBoxSizer( wxHORIZONTAL ); - - wxFlexGridSizer* fgDxfImportSettings; - fgDxfImportSettings = new wxFlexGridSizer( 0, 3, 5, 5 ); - fgDxfImportSettings->AddGrowableCol( 1 ); - fgDxfImportSettings->SetFlexibleDirection( wxBOTH ); - fgDxfImportSettings->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_lineWidthLabel = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Default line width:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_lineWidthLabel->Wrap( -1 ); - fgDxfImportSettings->Add( m_lineWidthLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_lineWidthCtrl = new wxTextCtrl( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgDxfImportSettings->Add( m_lineWidthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - m_lineWidthUnits = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_lineWidthUnits->Wrap( -1 ); - fgDxfImportSettings->Add( m_lineWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 ); - - m_staticTextLineWidth1 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Default units:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextLineWidth1->Wrap( -1 ); - fgDxfImportSettings->Add( m_staticTextLineWidth1, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - wxArrayString m_choiceDxfUnitsChoices; - m_choiceDxfUnits = new wxChoice( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceDxfUnitsChoices, 0 ); - m_choiceDxfUnits->SetSelection( 0 ); - fgDxfImportSettings->Add( m_choiceDxfUnits, 0, wxEXPAND, 5 ); - - - fgDxfImportSettings->Add( 0, 0, 1, wxEXPAND, 5 ); - - - bSizer81->Add( fgDxfImportSettings, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - - - sbSizer3->Add( bSizer81, 1, wxEXPAND, 5 ); - - - bSizerMain->Add( sbSizer3, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 ); - - 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_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onBrowseFiles ), NULL, this ); - m_rbInteractivePlacement->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onInteractivePlacement ), NULL, this ); - m_rbInteractivePlacement->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::originOptionOnUpdateUI ), NULL, this ); - m_rbAbsolutePlacement->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onAbsolutePlacement ), NULL, this ); - m_rbAbsolutePlacement->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::originOptionOnUpdateUI ), NULL, this ); - m_rbFixDiscontinuities->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onFixDiscontinuities ), NULL, this ); - m_groupItems->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onGroupItems ), NULL, this ); -} - -DIALOG_IMPORT_GFX_PCB_BASE::~DIALOG_IMPORT_GFX_PCB_BASE() -{ - // Disconnect Events - m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onBrowseFiles ), NULL, this ); - m_rbInteractivePlacement->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onInteractivePlacement ), NULL, this ); - m_rbInteractivePlacement->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::originOptionOnUpdateUI ), NULL, this ); - m_rbAbsolutePlacement->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onAbsolutePlacement ), NULL, this ); - m_rbAbsolutePlacement->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::originOptionOnUpdateUI ), NULL, this ); - m_rbFixDiscontinuities->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onFixDiscontinuities ), NULL, this ); - m_groupItems->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB_BASE::onGroupItems ), NULL, this ); - -} diff --git a/pcbnew/import_gfx/dialog_import_gfx_pcb_base.fbp b/pcbnew/import_gfx/dialog_import_gfx_pcb_base.fbp deleted file mode 100644 index d104d6c6f9..0000000000 --- a/pcbnew/import_gfx/dialog_import_gfx_pcb_base.fbp +++ /dev/null @@ -1,1989 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_import_gfx_pcb_base - 1000 - none - - - 1 - dialog_import_gfx_pcb_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_IMPORT_GFX_PCB_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Import Vector Graphics File - - 0 - - - - - - bSizerMain - wxVERTICAL - none - - 10 - wxALL|wxEXPAND - 0 - - - bSizerFile - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - File: - 0 - - 0 - - - 0 - - 1 - m_staticTextFile - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Only vectors will be imported. Bitmaps and fonts will be ignored. - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - 300,-1 - 1 - m_textCtrlFileName - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Only vectors will be imported. Bitmaps and fonts will be ignored. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Browse... - - 0 - - 0 - - - 0 - - 1 - m_browseButton - 1 - - - protected - 1 - - - - Resizable - 1 - -1,-1 - - STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onBrowseFiles - - - - - - 10 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - wxID_ANY - Placement - - sbSizer2 - wxVERTICAL - 1 - none - - 5 - wxEXPAND - 0 - - - bSizerOptions - wxVERTICAL - none - - 5 - wxEXPAND|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Interactive placement - - 0 - - - 0 - - 1 - m_rbInteractivePlacement - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 1 - - - - onInteractivePlacement - originOptionOnUpdateUI - - - - 5 - wxEXPAND - 0 - - - bSizerUserPos - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - At - - 0 - - - 0 - - 1 - m_rbAbsolutePlacement - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - onAbsolutePlacement - originOptionOnUpdateUI - - - - 5 - wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP - 1 - - - bSizerPosSettings - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - X: - 0 - - 0 - - - 0 - - 1 - m_xLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 10 - - 0 - - 1 - m_xCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - DXF origin on PCB Grid, X Coordinate - - wxFILTER_NUMERIC - wxTextValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_xUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Y: - 0 - - 0 - - - 0 - - 1 - m_yLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 10 - - 0 - - 1 - m_yCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - DXF origin on PCB Grid, Y Coordinate - - wxFILTER_NUMERIC - wxTextValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_yUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - 10 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - wxID_ANY - Import Parameters - - sbSizer1 - wxVERTICAL - 1 - none - - 5 - wxEXPAND - 1 - - - bSizer7 - wxHORIZONTAL - none - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 1 - - 3 - wxBOTH - 1 - - 5 - - fgSizerImportSettings - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 5 - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Graphic layer: - 0 - - 0 - - - 0 - - 1 - m_staticTextBrdlayer - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_SelLayerBox - 1 - - - protected - 1 - - Resizable - -1 - 1 - - - PCB_LAYER_BOX_SELECTOR; pcb_layer_box_selector.h - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - - 0 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Import scale: - 0 - - 0 - - - 0 - - 1 - m_importScaleLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_importScaleCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline1 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - ; ; forward_declare - 0 - - - - - - - - 5 - wxEXPAND - 0 - - - bSizer71 - wxVERTICAL - none - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Fix discontinuities - - 0 - - - 0 - - 1 - m_rbFixDiscontinuities - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - Trim/extend open shapes or add segments to make vertices of shapes coincide - - wxFILTER_NONE - wxDefaultValidator - - - - - onFixDiscontinuities - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - - bSizer14 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Tolerance: - 0 - - 0 - - - 0 - - 1 - m_toleranceLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_toleranceCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_toleranceUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline11 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - ; ; forward_declare - 0 - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - - bSizer8 - wxVERTICAL - none - - 5 - wxEXPAND|wxBOTTOM|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Group items - - 0 - - - 0 - - 1 - m_groupItems - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - Add all imported items into a new group - - wxFILTER_NONE - wxDefaultValidator - - - - - onGroupItems - - - - - - - - 10 - wxEXPAND|wxRIGHT|wxLEFT - 1 - - wxID_ANY - DXF Parameters - - sbSizer3 - wxVERTICAL - 1 - none - - 5 - wxEXPAND - 1 - - - bSizer81 - wxHORIZONTAL - none - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 1 - - 3 - wxBOTH - 1 - - 5 - - fgDxfImportSettings - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 5 - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Default line width: - 0 - - 0 - - - 0 - - 1 - m_lineWidthLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_lineWidthCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_lineWidthUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Default units: - 0 - - 0 - - - 0 - - 1 - m_staticTextLineWidth1 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_choiceDxfUnits - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - - - diff --git a/pcbnew/import_gfx/dialog_import_gfx_pcb.cpp b/pcbnew/import_gfx/dialog_import_graphics.cpp similarity index 70% rename from pcbnew/import_gfx/dialog_import_gfx_pcb.cpp rename to pcbnew/import_gfx/dialog_import_graphics.cpp index 64e464cdb9..55980b90fa 100644 --- a/pcbnew/import_gfx/dialog_import_gfx_pcb.cpp +++ b/pcbnew/import_gfx/dialog_import_graphics.cpp @@ -24,7 +24,7 @@ #include -#include "dialog_import_gfx_pcb.h" +#include "dialog_import_graphics.h" #include #include #include @@ -34,17 +34,17 @@ #include #include #include +#include #include #include #include -// Static members of DIALOG_IMPORT_GFX_PCB, to remember the user's choices during the session -bool DIALOG_IMPORT_GFX_PCB::s_placementInteractive = true; -bool DIALOG_IMPORT_GFX_PCB::s_shouldGroupItems = true; -bool DIALOG_IMPORT_GFX_PCB::s_fixDiscontinuities = true; -int DIALOG_IMPORT_GFX_PCB::s_toleranceValue = pcbIUScale.mmToIU( 1 ); -double DIALOG_IMPORT_GFX_PCB::s_importScale = 1.0; // Do not change the imported items size +// Static members of DIALOG_IMPORT_GRAPHICS, to remember the user's choices during the session +bool DIALOG_IMPORT_GRAPHICS::s_placementInteractive = true; +bool DIALOG_IMPORT_GRAPHICS::s_fixDiscontinuities = true; +int DIALOG_IMPORT_GRAPHICS::s_toleranceValue = pcbIUScale.mmToIU( 1 ); +double DIALOG_IMPORT_GRAPHICS::s_importScale = 1.0; // Do not change the imported items size const std::map dxfUnitsMap = { @@ -56,35 +56,21 @@ const std::map dxfUnitsMap = { }; -DIALOG_IMPORT_GFX_PCB::DIALOG_IMPORT_GFX_PCB( PCB_BASE_FRAME* aParent, - bool aImportAsFootprintGraphic ) : - DIALOG_IMPORT_GFX_PCB_BASE( aParent ), +DIALOG_IMPORT_GRAPHICS::DIALOG_IMPORT_GRAPHICS( PCB_BASE_FRAME* aParent ) : + DIALOG_IMPORT_GRAPHICS_BASE( aParent ), m_parent( aParent ), - m_xOrigin( aParent, m_xLabel, m_xCtrl, m_xUnits ), + m_xOrigin( aParent, nullptr, m_xCtrl, nullptr ), m_yOrigin( aParent, m_yLabel, m_yCtrl, m_yUnits ), m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ), m_tolerance( aParent, m_toleranceLabel, m_toleranceCtrl, m_toleranceUnits ) { - if( aImportAsFootprintGraphic ) - m_importer = std::make_unique( m_parent->GetBoard()->GetFirstFootprint() ); - else - m_importer = std::make_unique( m_parent->GetBoard() ); + // The SVG import has currently a flaw: all SVG shapes are imported as curves and + // converted to a lot of segments. A better approach is to convert to polylines + // (not yet existing in Pcbnew) and keep arcs and circles as primitives (not yet + // possible with tinysvg library). - // construct an import manager with options from config - { - GRAPHICS_IMPORT_MGR::TYPE_LIST blacklist; - // Currently: all types are allowed, so the blacklist is empty - // (no GFX_FILE_T in the blacklist) - // To disable SVG import, enable these 2 lines - // if( !ADVANCED_CFG::GetCfg().m_enableSvgImport ) - // blacklist.push_back( GRAPHICS_IMPORT_MGR::SVG ); - // The SVG import has currently a flaw: all SVG shapes are imported as curves and - // converted to a lot of segments. A better approach is to convert to polylines - // (not yet existing in Pcbnew) and keep arcs and circles as primitives (not yet - // possible with tinysvg library). - - m_gfxImportMgr = std::make_unique( blacklist ); - } + m_importer = std::make_unique( aParent->GetModel() ); + m_gfxImportMgr = std::make_unique(); PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings(); @@ -97,9 +83,7 @@ DIALOG_IMPORT_GFX_PCB::DIALOG_IMPORT_GFX_PCB( PCB_BASE_FRAME* aParent, m_importScaleCtrl->SetValue( wxString::Format( wxT( "%f" ), s_importScale ) ); m_textCtrlFileName->SetValue( cfg->m_ImportGraphics.last_file ); - m_rbInteractivePlacement->SetValue( s_placementInteractive ); - m_rbAbsolutePlacement->SetValue( !s_placementInteractive ); - m_groupItems->SetValue( s_shouldGroupItems ); + m_placeAtCheckbox->SetValue( !s_placementInteractive ); m_tolerance.SetValue( s_toleranceValue ); m_rbFixDiscontinuities->SetValue( s_fixDiscontinuities ); @@ -113,9 +97,9 @@ DIALOG_IMPORT_GFX_PCB::DIALOG_IMPORT_GFX_PCB( PCB_BASE_FRAME* aParent, m_SelLayerBox->SetLayerSelection( Dwgs_User ); for( const std::pair& unitEntry : dxfUnitsMap ) - m_choiceDxfUnits->Append( unitEntry.second ); + m_dxfUnitsChoice->Append( unitEntry.second ); - m_choiceDxfUnits->SetSelection( cfg->m_ImportGraphics.dxf_units ); + m_dxfUnitsChoice->SetSelection( cfg->m_ImportGraphics.dxf_units ); m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) ); @@ -130,13 +114,17 @@ DIALOG_IMPORT_GFX_PCB::DIALOG_IMPORT_GFX_PCB( PCB_BASE_FRAME* aParent, Centre(); m_textCtrlFileName->Connect( wxEVT_COMMAND_TEXT_UPDATED, - wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB::onFilename ), + wxCommandEventHandler( DIALOG_IMPORT_GRAPHICS::onFilename ), nullptr, this ); } -DIALOG_IMPORT_GFX_PCB::~DIALOG_IMPORT_GFX_PCB() +DIALOG_IMPORT_GRAPHICS::~DIALOG_IMPORT_GRAPHICS() { + s_placementInteractive = !m_placeAtCheckbox->GetValue(); + s_fixDiscontinuities = m_rbFixDiscontinuities->GetValue(); + s_toleranceValue = m_tolerance.GetIntValue(); + PCBNEW_SETTINGS* cfg = nullptr; try @@ -153,22 +141,22 @@ DIALOG_IMPORT_GFX_PCB::~DIALOG_IMPORT_GFX_PCB() cfg->m_ImportGraphics.layer = m_SelLayerBox->GetLayerSelection(); cfg->m_ImportGraphics.interactive_placement = s_placementInteractive; cfg->m_ImportGraphics.last_file = m_textCtrlFileName->GetValue(); - cfg->m_ImportGraphics.dxf_line_width = pcbIUScale.IUTomm( m_defaultLineWidth.GetValue() ); - cfg->m_ImportGraphics.origin_x = pcbIUScale.IUTomm( m_xOrigin.GetValue() ); - cfg->m_ImportGraphics.origin_y = pcbIUScale.IUTomm( m_yOrigin.GetValue() ); - cfg->m_ImportGraphics.dxf_units = m_choiceDxfUnits->GetSelection(); + cfg->m_ImportGraphics.dxf_line_width = pcbIUScale.IUTomm( m_defaultLineWidth.GetIntValue() ); + cfg->m_ImportGraphics.origin_x = pcbIUScale.IUTomm( m_xOrigin.GetIntValue() ); + cfg->m_ImportGraphics.origin_y = pcbIUScale.IUTomm( m_yOrigin.GetIntValue() ); + cfg->m_ImportGraphics.dxf_units = m_dxfUnitsChoice->GetSelection(); } s_importScale = EDA_UNIT_UTILS::UI::DoubleValueFromString( m_importScaleCtrl->GetValue() ); s_toleranceValue = m_tolerance.GetIntValue(); m_textCtrlFileName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, - wxCommandEventHandler( DIALOG_IMPORT_GFX_PCB::onFilename ), + wxCommandEventHandler( DIALOG_IMPORT_GRAPHICS::onFilename ), nullptr, this ); } -void DIALOG_IMPORT_GFX_PCB::onFilename( wxCommandEvent& event ) +void DIALOG_IMPORT_GRAPHICS::onFilename( wxCommandEvent& event ) { bool enableDXFControls = true; wxString ext = wxFileName( m_textCtrlFileName->GetValue() ).GetExt(); @@ -178,12 +166,12 @@ void DIALOG_IMPORT_GFX_PCB::onFilename( wxCommandEvent& event ) m_defaultLineWidth.Enable( enableDXFControls ); - m_staticTextLineWidth1->Enable( enableDXFControls ); - m_choiceDxfUnits->Enable( enableDXFControls ); + m_dxfUnitsLabel->Enable( enableDXFControls ); + m_dxfUnitsChoice->Enable( enableDXFControls ); } -void DIALOG_IMPORT_GFX_PCB::onBrowseFiles( wxCommandEvent& event ) +void DIALOG_IMPORT_GRAPHICS::onBrowseFiles( wxCommandEvent& event ) { wxString path; wxString filename = m_textCtrlFileName->GetValue(); @@ -218,18 +206,18 @@ void DIALOG_IMPORT_GFX_PCB::onBrowseFiles( wxCommandEvent& event ) } -bool DIALOG_IMPORT_GFX_PCB::TransferDataFromWindow() +bool DIALOG_IMPORT_GRAPHICS::TransferDataFromWindow() { if( !wxDialog::TransferDataFromWindow() ) return false; if( m_textCtrlFileName->GetValue().IsEmpty() ) { - wxMessageBox( _( "No file selected!" ) ); + wxMessageBox( _( "Please select a file to import." ) ); return false; } - if( m_SelLayerBox->GetLayerSelection() < 0 ) + if( m_setLayerCheckbox->GetValue() && m_SelLayerBox->GetLayerSelection() < 0 ) { wxMessageBox( _( "Please select a valid layer." ) ); return false; @@ -242,30 +230,26 @@ bool DIALOG_IMPORT_GFX_PCB::TransferDataFromWindow() double yscale = scale; if( cfg->m_Display.m_DisplayInvertXAxis ) - { xscale *= -1.0; - } if( cfg->m_Display.m_DisplayInvertYAxis ) - { yscale *= -1.0; - } - VECTOR2D origin( m_xOrigin.GetValue() / xscale, m_yOrigin.GetValue() / yscale ); + VECTOR2D origin( m_xOrigin.GetIntValue() / xscale, m_yOrigin.GetIntValue() / yscale ); if( std::unique_ptr plugin = m_gfxImportMgr->GetPluginByExt( ext ) ) { if( DXF_IMPORT_PLUGIN* dxfPlugin = dynamic_cast( plugin.get() ) ) { auto it = dxfUnitsMap.begin(); - std::advance( it, m_choiceDxfUnits->GetSelection() ); + std::advance( it, m_dxfUnitsChoice->GetSelection() ); if( it == dxfUnitsMap.end() ) dxfPlugin->SetUnit( DXF_IMPORT_UNITS::DEFAULT ); else dxfPlugin->SetUnit( it->first ); - m_importer->SetLineWidthMM( pcbIUScale.IUTomm( m_defaultLineWidth.GetValue() ) ); + m_importer->SetLineWidthMM( pcbIUScale.IUTomm( m_defaultLineWidth.GetIntValue() ) ); } else { @@ -273,7 +257,12 @@ bool DIALOG_IMPORT_GFX_PCB::TransferDataFromWindow() } m_importer->SetPlugin( std::move( plugin ) ); - m_importer->SetLayer( PCB_LAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); + + if( m_setLayerCheckbox->GetValue() ) + m_importer->SetLayer( PCB_LAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); + else + m_importer->SetLayer( m_parent->GetActiveLayer() ); + m_importer->SetImportOffsetMM( { pcbIUScale.IUTomm( origin.x ), pcbIUScale.IUTomm( origin.y ) } ); @@ -305,18 +294,14 @@ bool DIALOG_IMPORT_GFX_PCB::TransferDataFromWindow() } -void DIALOG_IMPORT_GFX_PCB::originOptionOnUpdateUI( wxUpdateUIEvent& event ) +void DIALOG_IMPORT_GRAPHICS::onUpdateUI( wxUpdateUIEvent& event ) { - if( m_rbInteractivePlacement->GetValue() != s_placementInteractive ) - m_rbInteractivePlacement->SetValue( s_placementInteractive ); + m_xOrigin.Enable( m_placeAtCheckbox->GetValue() ); + m_yOrigin.Enable( m_placeAtCheckbox->GetValue() ); - if( m_rbAbsolutePlacement->GetValue() == s_placementInteractive ) - m_rbAbsolutePlacement->SetValue( !s_placementInteractive ); + m_tolerance.Enable( m_rbFixDiscontinuities->GetValue() ); - m_xOrigin.Enable( !s_placementInteractive ); - m_yOrigin.Enable( !s_placementInteractive ); - - m_tolerance.Enable( s_fixDiscontinuities ); + m_SelLayerBox->Enable( m_setLayerCheckbox->GetValue() ); } diff --git a/pcbnew/import_gfx/dialog_import_gfx_pcb.h b/pcbnew/import_gfx/dialog_import_graphics.h similarity index 68% rename from pcbnew/import_gfx/dialog_import_gfx_pcb.h rename to pcbnew/import_gfx/dialog_import_graphics.h index a435e6d11a..ded79ba4d0 100644 --- a/pcbnew/import_gfx/dialog_import_gfx_pcb.h +++ b/pcbnew/import_gfx/dialog_import_graphics.h @@ -22,23 +22,23 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __DIALOG_IMPORT_GFX_PCB_H__ -#define __DIALOG_IMPORT_GFX_PCB_H__ +#ifndef DIALOG_IMPORT_GRAPHICS_H +#define DIALOG_IMPORT_GRAPHICS_H #include #include #include -#include "dialog_import_gfx_pcb_base.h" +#include #include class GRAPHICS_IMPORT_MGR; -class DIALOG_IMPORT_GFX_PCB : public DIALOG_IMPORT_GFX_PCB_BASE +class DIALOG_IMPORT_GRAPHICS : public DIALOG_IMPORT_GRAPHICS_BASE { public: - DIALOG_IMPORT_GFX_PCB( PCB_BASE_FRAME* aParent, bool aUseModuleItems = false ); - ~DIALOG_IMPORT_GFX_PCB(); + DIALOG_IMPORT_GRAPHICS( PCB_BASE_FRAME* aParent ); + ~DIALOG_IMPORT_GRAPHICS(); /** * @return a list of items imported from a vector graphics file. @@ -53,22 +53,17 @@ public: * items must be moved by the mouse cursor to the final position * false means the imported items are placed to the final position after import. */ - bool IsPlacementInteractive() { return s_placementInteractive; } - - /** - * @return true if the items should be added into a group when being placed. - */ - bool ShouldGroupItems() { return s_shouldGroupItems; } + bool IsPlacementInteractive() { return !m_placeAtCheckbox->GetValue(); } /** * @return true if discontinuities in the shapes should be fixed. */ - bool ShouldFixDiscontinuities() { return s_fixDiscontinuities; } + bool ShouldFixDiscontinuities() { return m_rbFixDiscontinuities->GetValue(); } /** * @return tolerance to connect the shapes. */ - int GetTolerance() { return s_toleranceValue; } + int GetTolerance() { return m_tolerance.GetValue(); } bool TransferDataFromWindow() override; @@ -76,28 +71,7 @@ private: // Virtual event handlers void onBrowseFiles( wxCommandEvent& event ) override; void onFilename( wxCommandEvent& event ); - void originOptionOnUpdateUI( wxUpdateUIEvent& event ) override; - - void onInteractivePlacement( wxCommandEvent& event ) override - { - s_placementInteractive = true; - } - - void onAbsolutePlacement( wxCommandEvent& event ) override - { - s_placementInteractive = false; - } - - void onGroupItems( wxCommandEvent& event ) override - { - s_shouldGroupItems = m_groupItems->GetValue(); - } - - void onFixDiscontinuities( wxCommandEvent& event ) override - { - s_fixDiscontinuities = m_rbFixDiscontinuities->GetValue(); - m_tolerance.Enable( s_fixDiscontinuities ); - } + void onUpdateUI( wxUpdateUIEvent& event ) override; private: PCB_BASE_FRAME* m_parent; @@ -117,4 +91,4 @@ private: // items m_importScale =1.0 means keep original size }; -#endif // __DIALOG_IMPORT_GFX_PCB_H__ +#endif // DIALOG_IMPORT_GRAPHICS_H diff --git a/pcbnew/import_gfx/dialog_import_graphics_base.cpp b/pcbnew/import_gfx/dialog_import_graphics_base.cpp new file mode 100644 index 0000000000..25b626a4d2 --- /dev/null +++ b/pcbnew/import_gfx/dialog_import_graphics_base.cpp @@ -0,0 +1,194 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "pcb_layer_box_selector.h" +#include "widgets/std_bitmap_button.h" + +#include "dialog_import_graphics_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_IMPORT_GRAPHICS_BASE::DIALOG_IMPORT_GRAPHICS_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, 5 ); + + m_browseButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 ); + bSizerFile->Add( m_browseButton, 0, wxTOP|wxBOTTOM, 5 ); + + + bSizerMain->Add( bSizerFile, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + + wxFlexGridSizer* fgSizer3; + fgSizer3 = new wxFlexGridSizer( 0, 3, 5, 3 ); + fgSizer3->AddGrowableCol( 1 ); + fgSizer3->SetFlexibleDirection( wxBOTH ); + fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_importScaleLabel = new wxStaticText( this, wxID_ANY, _("Import scale:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_importScaleLabel->Wrap( -1 ); + fgSizer3->Add( m_importScaleLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_importScaleCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 120,-1 ), 0 ); + fgSizer3->Add( m_importScaleCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_lineWidthLabel = new wxStaticText( this, wxID_ANY, _("DXF default line width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lineWidthLabel->Wrap( -1 ); + fgSizer3->Add( m_lineWidthLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_lineWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer3->Add( m_lineWidthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_lineWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lineWidthUnits->Wrap( -1 ); + fgSizer3->Add( m_lineWidthUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_dxfUnitsLabel = new wxStaticText( this, wxID_ANY, _("DXF default units:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dxfUnitsLabel->Wrap( -1 ); + fgSizer3->Add( m_dxfUnitsLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + wxArrayString m_dxfUnitsChoiceChoices; + m_dxfUnitsChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dxfUnitsChoiceChoices, 0 ); + m_dxfUnitsChoice->SetSelection( 0 ); + fgSizer3->Add( m_dxfUnitsChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + + bSizerMain->Add( fgSizer3, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); + + m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerMain->Add( m_staticline2, 0, wxEXPAND|wxBOTTOM, 6 ); + + wxGridBagSizer* gbSizer2; + gbSizer2 = new wxGridBagSizer( 5, 3 ); + gbSizer2->SetFlexibleDirection( wxBOTH ); + gbSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_placeAtCheckbox = new wxCheckBox( this, wxID_ANY, _("Place at X:"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer2->Add( m_placeAtCheckbox, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_xCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + #ifdef __WXGTK__ + if ( !m_xCtrl->HasFlag( wxTE_MULTILINE ) ) + { + m_xCtrl->SetMaxLength( 10 ); + } + #else + m_xCtrl->SetMaxLength( 10 ); + #endif + m_xCtrl->SetToolTip( _("DXF origin on PCB Grid, X Coordinate") ); + + gbSizer2->Add( m_xCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_yLabel = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_yLabel->Wrap( -1 ); + gbSizer2->Add( m_yLabel, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 18 ); + + m_yCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + #ifdef __WXGTK__ + if ( !m_yCtrl->HasFlag( wxTE_MULTILINE ) ) + { + m_yCtrl->SetMaxLength( 10 ); + } + #else + m_yCtrl->SetMaxLength( 10 ); + #endif + m_yCtrl->SetToolTip( _("DXF origin on PCB Grid, Y Coordinate") ); + + gbSizer2->Add( m_yCtrl, wxGBPosition( 0, 3 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_yUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_yUnits->Wrap( -1 ); + gbSizer2->Add( m_yUnits, wxGBPosition( 0, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_setLayerCheckbox = new wxCheckBox( this, wxID_ANY, _("Set layer:"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer2->Add( m_setLayerCheckbox, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + gbSizer2->Add( m_SelLayerBox, wxGBPosition( 1, 1 ), wxGBSpan( 1, 4 ), wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + + + gbSizer2->AddGrowableCol( 1 ); + gbSizer2->AddGrowableCol( 3 ); + + bSizerMain->Add( gbSizer2, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 6 ); + + wxBoxSizer* bSizer11; + bSizer11 = new wxBoxSizer( wxHORIZONTAL ); + + m_rbFixDiscontinuities = new wxCheckBox( this, wxID_ANY, _("Fix discontinuities"), wxDefaultPosition, wxDefaultSize, 0 ); + m_rbFixDiscontinuities->SetToolTip( _("Trim/extend open shapes or add segments to make vertices of shapes coincide") ); + + bSizer11->Add( m_rbFixDiscontinuities, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_toleranceLabel = new wxStaticText( this, wxID_ANY, _("Tolerance:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_toleranceLabel->Wrap( -1 ); + bSizer11->Add( m_toleranceLabel, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 ); + + m_toleranceCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + bSizer11->Add( m_toleranceCtrl, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 3 ); + + m_toleranceUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_toleranceUnits->Wrap( -1 ); + bSizer11->Add( m_toleranceUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizerMain->Add( bSizer11, 0, wxEXPAND|wxALL, 10 ); + + + bSizerMain->Add( 0, 3, 1, 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 + this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GRAPHICS_BASE::onUpdateUI ) ); + m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GRAPHICS_BASE::onBrowseFiles ), NULL, this ); +} + +DIALOG_IMPORT_GRAPHICS_BASE::~DIALOG_IMPORT_GRAPHICS_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GRAPHICS_BASE::onUpdateUI ) ); + m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GRAPHICS_BASE::onBrowseFiles ), NULL, this ); + +} diff --git a/pcbnew/import_gfx/dialog_import_graphics_base.fbp b/pcbnew/import_gfx/dialog_import_graphics_base.fbp new file mode 100644 index 0000000000..9b8f9bd5fd --- /dev/null +++ b/pcbnew/import_gfx/dialog_import_graphics_base.fbp @@ -0,0 +1,1628 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_import_graphics_base + 1000 + none + + + 1 + dialog_import_graphics_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_IMPORT_GRAPHICS_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Import Vector Graphics File + + 0 + + + + onUpdateUI + + + bSizerMain + wxVERTICAL + none + + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + + bSizerFile + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + File: + 0 + + 0 + + + 0 + + 1 + m_staticTextFile + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Only vectors will be imported. Bitmaps and fonts will be ignored. + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + 300,-1 + 1 + m_textCtrlFileName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Only vectors will be imported. Bitmaps and fonts will be ignored. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Browse... + + 0 + + 0 + + + 0 + + 1 + m_browseButton + 1 + + + protected + 1 + + + + Resizable + 1 + -1,-1 + + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onBrowseFiles + + + + + + 10 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 3 + wxBOTH + 1 + + 3 + + fgSizer3 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 5 + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Import scale: + 0 + + 0 + + + 0 + + 1 + m_importScaleLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_importScaleCtrl + 1 + + + protected + 1 + + Resizable + 1 + 120,-1 + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + DXF default line width: + 0 + + 0 + + + 0 + + 1 + m_lineWidthLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_lineWidthCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_lineWidthUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + DXF default units: + 0 + + 0 + + + 0 + + 1 + m_dxfUnitsLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_dxfUnitsChoice + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 6 + wxEXPAND|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline2 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + + + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + + wxBOTH + 1,3 + + 3 + + gbSizer2 + wxFLEX_GROWMODE_SPECIFIED + none + 5 + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Place at X: + + 0 + + + 0 + + 1 + m_placeAtCheckbox + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 10 + + 0 + + 1 + m_xCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + DXF origin on PCB Grid, X Coordinate + + wxFILTER_NUMERIC + wxTextValidator + + + + + + + + + 18 + 1 + 2 + wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Y: + 0 + + 0 + + + 0 + + 1 + m_yLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 3 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 10 + + 0 + + 1 + m_yCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + DXF origin on PCB Grid, Y Coordinate + + wxFILTER_NUMERIC + wxTextValidator + + + + + + + + + 5 + 1 + 4 + wxALIGN_CENTER_VERTICAL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_yUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Set layer: + + 0 + + + 0 + + 1 + m_setLayerCheckbox + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 4 + 1 + wxEXPAND|wxALIGN_CENTER_VERTICAL + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_SelLayerBox + 1 + + + protected + 1 + + Resizable + -1 + 1 + + + PCB_LAYER_BOX_SELECTOR; pcb_layer_box_selector.h + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + 6 + wxEXPAND|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + + + 10 + wxEXPAND|wxALL + 0 + + + bSizer11 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Fix discontinuities + + 0 + + + 0 + + 1 + m_rbFixDiscontinuities + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Trim/extend open shapes or add segments to make vertices of shapes coincide + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 20 + wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Tolerance: + 0 + + 0 + + + 0 + + 1 + m_toleranceLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 3 + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_toleranceCtrl + 1 + + + protected + 1 + + Resizable + 1 + -1,-1 + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_toleranceUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 5 + wxEXPAND + 1 + + 3 + protected + 0 + + + + 5 + wxEXPAND|wxALL + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + + + diff --git a/pcbnew/import_gfx/dialog_import_gfx_pcb_base.h b/pcbnew/import_gfx/dialog_import_graphics_base.h similarity index 63% rename from pcbnew/import_gfx/dialog_import_gfx_pcb_base.h rename to pcbnew/import_gfx/dialog_import_graphics_base.h index c0a3bf2e63..398452b72c 100644 --- a/pcbnew/import_gfx/dialog_import_gfx_pcb_base.h +++ b/pcbnew/import_gfx/dialog_import_graphics_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -27,22 +27,21 @@ class STD_BITMAP_BUTTON; #include #include #include -#include -#include -#include -#include +#include #include #include -#include +#include +#include +#include #include /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_IMPORT_GFX_PCB_BASE +/// Class DIALOG_IMPORT_GRAPHICS_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_IMPORT_GFX_PCB_BASE : public DIALOG_SHIM +class DIALOG_IMPORT_GRAPHICS_BASE : public DIALOG_SHIM { private: @@ -50,48 +49,40 @@ class DIALOG_IMPORT_GFX_PCB_BASE : public DIALOG_SHIM wxStaticText* m_staticTextFile; wxTextCtrl* m_textCtrlFileName; STD_BITMAP_BUTTON* m_browseButton; - wxRadioButton* m_rbInteractivePlacement; - wxRadioButton* m_rbAbsolutePlacement; - wxStaticText* m_xLabel; + wxStaticText* m_importScaleLabel; + wxTextCtrl* m_importScaleCtrl; + wxStaticText* m_lineWidthLabel; + wxTextCtrl* m_lineWidthCtrl; + wxStaticText* m_lineWidthUnits; + wxStaticText* m_dxfUnitsLabel; + wxChoice* m_dxfUnitsChoice; + wxStaticLine* m_staticline2; + wxCheckBox* m_placeAtCheckbox; wxTextCtrl* m_xCtrl; - wxStaticText* m_xUnits; wxStaticText* m_yLabel; wxTextCtrl* m_yCtrl; wxStaticText* m_yUnits; - wxStaticText* m_staticTextBrdlayer; + wxCheckBox* m_setLayerCheckbox; PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; - wxStaticText* m_importScaleLabel; - wxTextCtrl* m_importScaleCtrl; wxStaticLine* m_staticline1; wxCheckBox* m_rbFixDiscontinuities; wxStaticText* m_toleranceLabel; wxTextCtrl* m_toleranceCtrl; wxStaticText* m_toleranceUnits; - wxStaticLine* m_staticline11; - wxCheckBox* m_groupItems; - wxStaticText* m_lineWidthLabel; - wxTextCtrl* m_lineWidthCtrl; - wxStaticText* m_lineWidthUnits; - wxStaticText* m_staticTextLineWidth1; - wxChoice* m_choiceDxfUnits; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; // Virtual event handlers, override them in your derived class + virtual void onUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void onBrowseFiles( wxCommandEvent& event ) { event.Skip(); } - virtual void onInteractivePlacement( wxCommandEvent& event ) { event.Skip(); } - virtual void originOptionOnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } - virtual void onAbsolutePlacement( wxCommandEvent& event ) { event.Skip(); } - virtual void onFixDiscontinuities( wxCommandEvent& event ) { event.Skip(); } - virtual void onGroupItems( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_IMPORT_GFX_PCB_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_GRAPHICS_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_PCB_BASE(); + ~DIALOG_IMPORT_GRAPHICS_BASE(); }; diff --git a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp index d6c50f3ae9..3c1a28e58a 100644 --- a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp +++ b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp @@ -33,7 +33,8 @@ #include -GRAPHICS_IMPORTER_PCBNEW::GRAPHICS_IMPORTER_PCBNEW() +GRAPHICS_IMPORTER_PCBNEW::GRAPHICS_IMPORTER_PCBNEW( BOARD_ITEM_CONTAINER* aParent ) : + m_parent( aParent ) { m_layer = Dwgs_User; m_millimeterToIu = pcbIUScale.mmToIU( 1.0 ); @@ -76,7 +77,7 @@ STROKE_PARAMS GRAPHICS_IMPORTER_PCBNEW::MapStrokeParams( const IMPORTED_STROKE& void GRAPHICS_IMPORTER_PCBNEW::AddLine( const VECTOR2D& aStart, const VECTOR2D& aEnd, const IMPORTED_STROKE& aStroke ) { - std::unique_ptr line( createDrawing() ); + std::unique_ptr line = std::make_unique( m_parent ); line->SetShape( SHAPE_T::SEGMENT ); line->SetLayer( GetLayer() ); line->SetStroke( MapStrokeParams( aStroke ) ); @@ -95,7 +96,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, double aRadiu const IMPORTED_STROKE& aStroke, bool aFilled, const COLOR4D& aFillColor ) { - std::unique_ptr circle( createDrawing() ); + std::unique_ptr circle = std::make_unique( m_parent ); circle->SetShape( SHAPE_T::CIRCLE ); circle->SetFilled( aFilled ); circle->SetLayer( GetLayer() ); @@ -110,7 +111,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, double aRadiu void GRAPHICS_IMPORTER_PCBNEW::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, const EDA_ANGLE& aAngle, const IMPORTED_STROKE& aStroke ) { - std::unique_ptr arc( createDrawing() ); + std::unique_ptr arc = std::make_unique( m_parent ); arc->SetShape( SHAPE_T::ARC ); arc->SetLayer( GetLayer() ); @@ -157,7 +158,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddPolygon( const std::vector& aVertice for( const VECTOR2D& precisePoint : aVertices ) convertedPoints.emplace_back( MapCoordinate( precisePoint ) ); - std::unique_ptr polygon( createDrawing() ); + std::unique_ptr polygon = std::make_unique( m_parent ); polygon->SetShape( SHAPE_T::POLY ); polygon->SetFilled( GetLayer() != Edge_Cuts ); polygon->SetLayer( GetLayer() ); @@ -179,7 +180,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddText( const VECTOR2D& aOrigin, const wxString& double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, GR_TEXT_V_ALIGN_T aVJustify, const COLOR4D& aColor ) { - std::unique_ptr textItem = createText(); + std::unique_ptr textItem = std::make_unique( m_parent ); textItem->SetLayer( GetLayer() ); textItem->SetTextThickness( MapLineWidth( aThickness ) ); textItem->SetTextPos( MapCoordinate( aOrigin ) ); @@ -198,7 +199,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddSpline( const VECTOR2D& aStart, const VECTOR2D const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, const IMPORTED_STROKE& aStroke ) { - std::unique_ptr spline( createDrawing() ); + std::unique_ptr spline = std::make_unique( m_parent ); spline->SetShape( SHAPE_T::BEZIER ); spline->SetLayer( GetLayer() ); spline->SetStroke( MapStrokeParams( aStroke ) ); @@ -224,26 +225,3 @@ void GRAPHICS_IMPORTER_PCBNEW::AddSpline( const VECTOR2D& aStart, const VECTOR2D addItem( std::move( spline ) ); } - -std::unique_ptr GRAPHICS_IMPORTER_BOARD::createDrawing() -{ - return std::make_unique( m_board ); -} - - -std::unique_ptr GRAPHICS_IMPORTER_BOARD::createText() -{ - return std::make_unique( m_board ); -} - - -std::unique_ptr GRAPHICS_IMPORTER_FOOTPRINT::createDrawing() -{ - return std::make_unique( m_footprint ); -} - - -std::unique_ptr GRAPHICS_IMPORTER_FOOTPRINT::createText() -{ - return std::make_unique( m_footprint ); -} diff --git a/pcbnew/import_gfx/graphics_importer_pcbnew.h b/pcbnew/import_gfx/graphics_importer_pcbnew.h index de7005740b..4dfb5d951b 100644 --- a/pcbnew/import_gfx/graphics_importer_pcbnew.h +++ b/pcbnew/import_gfx/graphics_importer_pcbnew.h @@ -28,36 +28,17 @@ #define GRAPHICS_IMPORTER_PCBNEW_H #include - #include -class BOARD; -class FOOTPRINT; -class PCB_SHAPE; -class PCB_TEXT; +class BOARD_ITEM_CONTAINER; class GRAPHICS_IMPORTER_PCBNEW : public GRAPHICS_IMPORTER { public: - GRAPHICS_IMPORTER_PCBNEW(); + GRAPHICS_IMPORTER_PCBNEW( BOARD_ITEM_CONTAINER* aParent ); - /** - * Set the target layer for the imported shapes. - * - * @param aLayer is the layer to be used by the imported shapes. - */ - void SetLayer( PCB_LAYER_ID aLayer ) - { - m_layer = aLayer; - } - - /** - * Return the target layer for the imported shapes. - */ - PCB_LAYER_ID GetLayer() const - { - return m_layer; - } + void SetLayer( PCB_LAYER_ID aLayer ) { m_layer = aLayer; } + PCB_LAYER_ID GetLayer() const { return m_layer; } void AddLine( const VECTOR2D& aStart, const VECTOR2D& aEnd, const IMPORTED_STROKE& aStroke ) override; @@ -99,46 +80,11 @@ public: STROKE_PARAMS MapStrokeParams( const IMPORTED_STROKE& aStroke ); protected: - ///< Create an object representing a graphical shape. - virtual std::unique_ptr createDrawing() = 0; - - ///< Create an object representing a text. - virtual std::unique_ptr createText() = 0; - ///< Target layer for the imported shapes. - PCB_LAYER_ID m_layer; + PCB_LAYER_ID m_layer; + BOARD_ITEM_CONTAINER* m_parent; }; -class GRAPHICS_IMPORTER_BOARD : public GRAPHICS_IMPORTER_PCBNEW -{ -public: - GRAPHICS_IMPORTER_BOARD( BOARD* aBoard ) - : m_board( aBoard ) - { - } -protected: - std::unique_ptr createDrawing() override; - std::unique_ptr createText() override; - - BOARD* m_board; -}; - - -class GRAPHICS_IMPORTER_FOOTPRINT : public GRAPHICS_IMPORTER_PCBNEW -{ -public: - GRAPHICS_IMPORTER_FOOTPRINT( FOOTPRINT* aFootprint ) - : m_footprint( aFootprint ) - { - } - -protected: - std::unique_ptr createDrawing() override; - std::unique_ptr createText() override; - - FOOTPRINT* m_footprint; -}; - -#endif /* GRAPHICS_IMPORTER_PCBNEW */ +#endif /* GRAPHICS_IMPORTER_PCBNEW_H */ diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index eb182da5db..6ff623c704 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -1485,9 +1485,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) REENTRANCY_GUARD guard( &m_inDrawingTool ); - // Note: PlaceImportedGraphics() will convert PCB_SHAPE_T and PCB_TEXT_T to footprint - // items if needed - DIALOG_IMPORT_GFX_PCB dlg( m_frame, m_isFootprintEditor ); + DIALOG_IMPORT_GRAPHICS dlg( m_frame ); int dlgResult = dlg.ShowModal(); std::list>& list = dlg.GetImportedItems(); @@ -1508,20 +1506,14 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) std::vector selectedItems; // the group, or newItems if no group PCB_SELECTION preview; BOARD_COMMIT commit( m_frame ); - PCB_GROUP* group = nullptr; + PICKED_ITEMS_LIST groupUndoList; PCB_LAYER_ID layer = F_Cu; - if( dlg.ShouldGroupItems() ) - { - if( m_isFootprintEditor ) - group = new PCB_GROUP( m_frame->GetBoard()->GetFirstFootprint() ); - else - group = new PCB_GROUP( m_frame->GetBoard() ); + PCB_GROUP* group = new PCB_GROUP( m_frame->GetModel() ); - newItems.push_back( group ); - selectedItems.push_back( group ); - preview.Add( group ); - } + newItems.push_back( group ); + selectedItems.push_back( group ); + preview.Add( group ); if( dlg.ShouldFixDiscontinuities() ) { @@ -1545,19 +1537,14 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) for( std::unique_ptr& ptr : list ) { - BOARD_ITEM* item = dynamic_cast( ptr.get() ); + BOARD_ITEM* item = dynamic_cast( ptr.release() ); wxCHECK2( item, continue ); newItems.push_back( item ); - - if( group ) - group->AddItem( item ); - else - selectedItems.push_back( item ); + group->AddItem( item ); + groupUndoList.PushItem( ITEM_PICKER( nullptr, item, UNDO_REDO::REGROUP ) ); preview.Add( item ); - - ptr.release(); } if( !dlg.IsPlacementInteractive() ) @@ -1565,7 +1552,11 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) for( BOARD_ITEM* item : newItems ) commit.Add( item ); - commit.Push( _( "Import Graphic" ) ); + commit.Push( _( "Import Graphics" ) ); + + if( groupUndoList.GetCount() > 0 ) + m_frame->AppendCopyToUndoList( groupUndoList, UNDO_REDO::REGROUP ); + return 0; } @@ -1652,7 +1643,11 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) for( BOARD_ITEM* item : newItems ) commit.Add( item ); - commit.Push( _( "Import Graphic" ) ); + commit.Push( _( "Import Graphics" ) ); + + if( groupUndoList.GetCount() > 0 ) + m_frame->AppendCopyToUndoList( groupUndoList, UNDO_REDO::REGROUP ); + break; // This is a one-shot command, not a tool } else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) )