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.
This commit is contained in:
parent
e01ef0a38d
commit
b089630b4c
|
@ -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 <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -24,29 +25,12 @@
|
|||
|
||||
#include "graphics_import_mgr.h"
|
||||
|
||||
#include <core/kicad_algo.h>
|
||||
#include <eda_item.h>
|
||||
#include "dxf_import_plugin.h"
|
||||
#include "svg_import_plugin.h"
|
||||
|
||||
#include <wx/regex.h>
|
||||
|
||||
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_PLUGIN> GRAPHICS_IMPORT_MGR::GetPlugin( GFX_FILE_T aType ) const
|
||||
{
|
||||
std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> ret;
|
||||
|
@ -54,9 +38,7 @@ std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> GRAPHICS_IMPORT_MGR::GetPlugin( GFX_FILE
|
|||
switch( aType )
|
||||
{
|
||||
case DXF: ret = std::make_unique<DXF_IMPORT_PLUGIN>(); break;
|
||||
|
||||
case SVG: ret = std::make_unique<SVG_IMPORT_PLUGIN>(); break;
|
||||
|
||||
default: throw std::runtime_error( "Unhandled graphics format" ); break;
|
||||
}
|
||||
|
||||
|
@ -67,10 +49,10 @@ std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> GRAPHICS_IMPORT_MGR::GetPlugin( GFX_FILE
|
|||
std::unique_ptr<GRAPHICS_IMPORT_PLUGIN> 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<GRAPHICS_IMPORT_PLUGIN> plugin = GetPlugin( fileType );
|
||||
const std::vector<std::string>& fileExtensions = plugin->GetFileExtensions();
|
||||
|
||||
if( compareFileExtensions( aExtension.ToStdString(), fileExtensions ) )
|
||||
return plugin;
|
||||
|
|
|
@ -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 <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -46,19 +46,10 @@ public:
|
|||
SVG
|
||||
};
|
||||
|
||||
using TYPE_LIST = std::vector<GFX_FILE_T>;
|
||||
|
||||
/**
|
||||
* 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<GFX_FILE_T> 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<GRAPHICS_IMPORT_PLUGIN> GetPlugin( GFX_FILE_T aType ) const;
|
||||
|
||||
private:
|
||||
TYPE_LIST m_importableTypes;
|
||||
};
|
||||
|
||||
#endif /* GRAPHICS_IMPORT_MGR_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.
|
||||
|
|
|
@ -591,7 +591,9 @@ void UNIT_BINDER::SetLabel( const wxString& aLabel )
|
|||
|
||||
void UNIT_BINDER::Enable( bool aEnable )
|
||||
{
|
||||
if( m_label )
|
||||
m_label->Enable( aEnable );
|
||||
|
||||
m_valueCtrl->Enable( aEnable );
|
||||
|
||||
if( m_unitLabel )
|
||||
|
|
|
@ -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<GRAPHICS_IMPORT_MGR>( blacklist );
|
||||
}
|
||||
m_gfxImportMgr = std::make_unique<GRAPHICS_IMPORT_MGR>();
|
||||
|
||||
wxCommandEvent dummy;
|
||||
onFilename( dummy );
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <dialogs/html_message_box.h>
|
||||
|
||||
#include "dialog_import_gfx_pcb.h"
|
||||
#include "dialog_import_graphics.h"
|
||||
#include <import_gfx/dxf_import_plugin.h>
|
||||
#include <base_units.h>
|
||||
#include <kiface_base.h>
|
||||
|
@ -34,17 +34,17 @@
|
|||
#include <bitmaps.h>
|
||||
#include <widgets/std_bitmap_button.h>
|
||||
#include <map>
|
||||
#include <footprint.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
// 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<DXF_IMPORT_UNITS, wxString> dxfUnitsMap = {
|
||||
|
@ -56,35 +56,21 @@ const std::map<DXF_IMPORT_UNITS, wxString> 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<GRAPHICS_IMPORTER_FOOTPRINT>( m_parent->GetBoard()->GetFirstFootprint() );
|
||||
else
|
||||
m_importer = std::make_unique<GRAPHICS_IMPORTER_BOARD>( m_parent->GetBoard() );
|
||||
|
||||
// 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<GRAPHICS_IMPORT_MGR>( blacklist );
|
||||
}
|
||||
m_importer = std::make_unique<GRAPHICS_IMPORTER_PCBNEW>( aParent->GetModel() );
|
||||
m_gfxImportMgr = std::make_unique<GRAPHICS_IMPORT_MGR>();
|
||||
|
||||
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<const DXF_IMPORT_UNITS, wxString>& 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<GRAPHICS_IMPORT_PLUGIN> plugin = m_gfxImportMgr->GetPluginByExt( ext ) )
|
||||
{
|
||||
if( DXF_IMPORT_PLUGIN* dxfPlugin = dynamic_cast<DXF_IMPORT_PLUGIN*>( 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 ) );
|
||||
|
||||
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() );
|
||||
}
|
||||
|
||||
|
|
@ -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 <widgets/unit_binder.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <pcbnew_settings.h>
|
||||
#include "dialog_import_gfx_pcb_base.h"
|
||||
#include <import_gfx/dialog_import_graphics_base.h>
|
||||
#include <import_gfx/graphics_importer_pcbnew.h>
|
||||
|
||||
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
|
|
@ -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 );
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -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 <wx/icon.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/valtext.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/bmpcbox.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/valtext.h>
|
||||
#include <wx/bmpcbox.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// 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();
|
||||
|
||||
};
|
||||
|
|
@ -33,7 +33,8 @@
|
|||
#include <tuple>
|
||||
|
||||
|
||||
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<PCB_SHAPE> line( createDrawing() );
|
||||
std::unique_ptr<PCB_SHAPE> line = std::make_unique<PCB_SHAPE>( 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<PCB_SHAPE> circle( createDrawing() );
|
||||
std::unique_ptr<PCB_SHAPE> circle = std::make_unique<PCB_SHAPE>( 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<PCB_SHAPE> arc( createDrawing() );
|
||||
std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( m_parent );
|
||||
arc->SetShape( SHAPE_T::ARC );
|
||||
arc->SetLayer( GetLayer() );
|
||||
|
||||
|
@ -157,7 +158,7 @@ void GRAPHICS_IMPORTER_PCBNEW::AddPolygon( const std::vector<VECTOR2D>& aVertice
|
|||
for( const VECTOR2D& precisePoint : aVertices )
|
||||
convertedPoints.emplace_back( MapCoordinate( precisePoint ) );
|
||||
|
||||
std::unique_ptr<PCB_SHAPE> polygon( createDrawing() );
|
||||
std::unique_ptr<PCB_SHAPE> polygon = std::make_unique<PCB_SHAPE>( 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<PCB_TEXT> textItem = createText();
|
||||
std::unique_ptr<PCB_TEXT> textItem = std::make_unique<PCB_TEXT>( 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<PCB_SHAPE> spline( createDrawing() );
|
||||
std::unique_ptr<PCB_SHAPE> spline = std::make_unique<PCB_SHAPE>( 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<PCB_SHAPE> GRAPHICS_IMPORTER_BOARD::createDrawing()
|
||||
{
|
||||
return std::make_unique<PCB_SHAPE>( m_board );
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<PCB_TEXT> GRAPHICS_IMPORTER_BOARD::createText()
|
||||
{
|
||||
return std::make_unique<PCB_TEXT>( m_board );
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<PCB_SHAPE> GRAPHICS_IMPORTER_FOOTPRINT::createDrawing()
|
||||
{
|
||||
return std::make_unique<PCB_SHAPE>( m_footprint );
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<PCB_TEXT> GRAPHICS_IMPORTER_FOOTPRINT::createText()
|
||||
{
|
||||
return std::make_unique<PCB_TEXT>( m_footprint );
|
||||
}
|
||||
|
|
|
@ -28,36 +28,17 @@
|
|||
#define GRAPHICS_IMPORTER_PCBNEW_H
|
||||
|
||||
#include <import_gfx/graphics_importer.h>
|
||||
|
||||
#include <layer_ids.h>
|
||||
|
||||
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<PCB_SHAPE> createDrawing() = 0;
|
||||
|
||||
///< Create an object representing a text.
|
||||
virtual std::unique_ptr<PCB_TEXT> createText() = 0;
|
||||
|
||||
///< Target layer for the imported shapes.
|
||||
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<PCB_SHAPE> createDrawing() override;
|
||||
std::unique_ptr<PCB_TEXT> 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<PCB_SHAPE> createDrawing() override;
|
||||
std::unique_ptr<PCB_TEXT> createText() override;
|
||||
|
||||
FOOTPRINT* m_footprint;
|
||||
};
|
||||
|
||||
#endif /* GRAPHICS_IMPORTER_PCBNEW */
|
||||
#endif /* GRAPHICS_IMPORTER_PCBNEW_H */
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <geometry/geometry_utils.h>
|
||||
#include <geometry/shape_segment.h>
|
||||
#include <import_gfx/dialog_import_gfx_pcb.h>
|
||||
#include <import_gfx/dialog_import_graphics.h>
|
||||
#include <preview_items/two_point_assistant.h>
|
||||
#include <preview_items/two_point_geom_manager.h>
|
||||
#include <ratsnest/ratsnest_data.h>
|
||||
|
@ -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<std::unique_ptr<EDA_ITEM>>& list = dlg.GetImportedItems();
|
||||
|
@ -1508,20 +1506,14 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
|||
std::vector<BOARD_ITEM*> 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 );
|
||||
}
|
||||
|
||||
if( dlg.ShouldFixDiscontinuities() )
|
||||
{
|
||||
|
@ -1545,19 +1537,14 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( std::unique_ptr<EDA_ITEM>& ptr : list )
|
||||
{
|
||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( ptr.get() );
|
||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( ptr.release() );
|
||||
wxCHECK2( item, continue );
|
||||
|
||||
newItems.push_back( item );
|
||||
|
||||
if( group )
|
||||
group->AddItem( item );
|
||||
else
|
||||
selectedItems.push_back( 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 ) )
|
||||
|
|
Loading…
Reference in New Issue