diff --git a/pcbnew/import_gfx/dialog_import_graphics.cpp b/pcbnew/import_gfx/dialog_import_graphics.cpp index 6e314b530f..6bb62dfea9 100644 --- a/pcbnew/import_gfx/dialog_import_graphics.cpp +++ b/pcbnew/import_gfx/dialog_import_graphics.cpp @@ -41,9 +41,11 @@ #include // Static members of DIALOG_IMPORT_GRAPHICS, to remember the user's choices during the session +bool DIALOG_IMPORT_GRAPHICS::s_useDlgLayerSelection = true; bool DIALOG_IMPORT_GRAPHICS::s_placementInteractive = true; +bool DIALOG_IMPORT_GRAPHICS::s_shouldGroupItems = true; bool DIALOG_IMPORT_GRAPHICS::s_fixDiscontinuities = true; -int DIALOG_IMPORT_GRAPHICS::s_toleranceValue = pcbIUScale.mmToIU( 1 ); +int DIALOG_IMPORT_GRAPHICS::s_toleranceValue = pcbIUScale.mmToIU( 0.01 ); double DIALOG_IMPORT_GRAPHICS::s_importScale = 1.0; // Do not change the imported items size @@ -74,7 +76,14 @@ DIALOG_IMPORT_GRAPHICS::DIALOG_IMPORT_GRAPHICS( PCB_BASE_FRAME* aParent ) : PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings(); + s_shouldGroupItems = cfg->m_ImportGraphics.group_items; + s_fixDiscontinuities = cfg->m_ImportGraphics.fix_discontinuities; + s_toleranceValue = cfg->m_ImportGraphics.tolerance * pcbIUScale.IU_PER_MM; + s_useDlgLayerSelection = cfg->m_ImportGraphics.use_dlg_layer_selection; + s_placementInteractive = cfg->m_ImportGraphics.interactive_placement; + m_cbGroupItems->SetValue( s_shouldGroupItems ); + m_setLayerCheckbox->SetValue( s_useDlgLayerSelection ); m_xOrigin.SetValue( cfg->m_ImportGraphics.origin_x * pcbIUScale.IU_PER_MM ); m_yOrigin.SetValue( cfg->m_ImportGraphics.origin_y * pcbIUScale.IU_PER_MM ); @@ -124,6 +133,8 @@ DIALOG_IMPORT_GRAPHICS::~DIALOG_IMPORT_GRAPHICS() s_placementInteractive = !m_placeAtCheckbox->GetValue(); s_fixDiscontinuities = m_rbFixDiscontinuities->GetValue(); s_toleranceValue = m_tolerance.GetIntValue(); + s_shouldGroupItems = m_cbGroupItems->IsChecked(); + s_useDlgLayerSelection = m_setLayerCheckbox->IsChecked(); PCBNEW_SETTINGS* cfg = nullptr; @@ -139,16 +150,19 @@ DIALOG_IMPORT_GRAPHICS::~DIALOG_IMPORT_GRAPHICS() if( cfg ) { cfg->m_ImportGraphics.layer = m_SelLayerBox->GetLayerSelection(); + cfg->m_ImportGraphics.use_dlg_layer_selection = s_useDlgLayerSelection; 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.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(); + cfg->m_ImportGraphics.group_items = s_shouldGroupItems; + cfg->m_ImportGraphics.fix_discontinuities = s_fixDiscontinuities; + cfg->m_ImportGraphics.tolerance = pcbIUScale.IUTomm( s_toleranceValue ); } 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_GRAPHICS::onFilename ), diff --git a/pcbnew/import_gfx/dialog_import_graphics.h b/pcbnew/import_gfx/dialog_import_graphics.h index ded79ba4d0..bbe07c4595 100644 --- a/pcbnew/import_gfx/dialog_import_graphics.h +++ b/pcbnew/import_gfx/dialog_import_graphics.h @@ -65,6 +65,11 @@ public: */ int GetTolerance() { return m_tolerance.GetValue(); } + /** + * @return true if imported items must be placed in a new PCB_GROUP. + */ + bool ShouldGroupItems() { return m_cbGroupItems->IsChecked(); } + bool TransferDataFromWindow() override; private: @@ -83,6 +88,7 @@ private: UNIT_BINDER m_defaultLineWidth; UNIT_BINDER m_tolerance; + static bool s_useDlgLayerSelection; static bool s_shouldGroupItems; static bool s_placementInteractive; static bool s_fixDiscontinuities; diff --git a/pcbnew/import_gfx/dialog_import_graphics_base.cpp b/pcbnew/import_gfx/dialog_import_graphics_base.cpp index 25b626a4d2..93b990e816 100644 --- a/pcbnew/import_gfx/dialog_import_graphics_base.cpp +++ b/pcbnew/import_gfx/dialog_import_graphics_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -125,6 +125,8 @@ DIALOG_IMPORT_GRAPHICS_BASE::DIALOG_IMPORT_GRAPHICS_BASE( wxWindow* parent, wxWi 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 ); + m_setLayerCheckbox->SetToolTip( _("If checked, use the selected layer in this dialog\nIf unchecked, use the Board Editor active layer") ); + 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 ); @@ -139,6 +141,19 @@ DIALOG_IMPORT_GRAPHICS_BASE::DIALOG_IMPORT_GRAPHICS_BASE( wxWindow* parent, wxWi m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 6 ); + wxBoxSizer* bSizerGroupOpt; + bSizerGroupOpt = new wxBoxSizer( wxVERTICAL ); + + m_cbGroupItems = new wxCheckBox( this, wxID_ANY, _("Group imported items"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbGroupItems->SetValue(true); + bSizerGroupOpt->Add( m_cbGroupItems, 0, wxALL, 5 ); + + m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerGroupOpt->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 ); + + + bSizerMain->Add( bSizerGroupOpt, 0, wxEXPAND|wxLEFT, 5 ); + wxBoxSizer* bSizer11; bSizer11 = new wxBoxSizer( wxHORIZONTAL ); @@ -159,7 +174,7 @@ DIALOG_IMPORT_GRAPHICS_BASE::DIALOG_IMPORT_GRAPHICS_BASE( wxWindow* parent, wxWi bSizer11->Add( m_toleranceUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); - bSizerMain->Add( bSizer11, 0, wxEXPAND|wxALL, 10 ); + bSizerMain->Add( bSizer11, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); bSizerMain->Add( 0, 3, 1, wxEXPAND, 5 ); diff --git a/pcbnew/import_gfx/dialog_import_graphics_base.fbp b/pcbnew/import_gfx/dialog_import_graphics_base.fbp index 9b8f9bd5fd..3cb4a25b74 100644 --- a/pcbnew/import_gfx/dialog_import_graphics_base.fbp +++ b/pcbnew/import_gfx/dialog_import_graphics_base.fbp @@ -1195,7 +1195,7 @@ ; ; forward_declare 0 - + If checked, use the selected layer in this dialog If unchecked, use the Board Editor active layer wxFILTER_NONE wxDefaultValidator @@ -1333,9 +1333,142 @@ + + 5 + wxEXPAND|wxLEFT + 0 + + + bSizerGroupOpt + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Group imported items + + 0 + + + 0 + + 1 + m_cbGroupItems + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline3 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + + + 10 - wxEXPAND|wxALL + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 diff --git a/pcbnew/import_gfx/dialog_import_graphics_base.h b/pcbnew/import_gfx/dialog_import_graphics_base.h index 398452b72c..e73dfe1fd9 100644 --- a/pcbnew/import_gfx/dialog_import_graphics_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-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -65,6 +65,8 @@ class DIALOG_IMPORT_GRAPHICS_BASE : public DIALOG_SHIM wxCheckBox* m_setLayerCheckbox; PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; wxStaticLine* m_staticline1; + wxCheckBox* m_cbGroupItems; + wxStaticLine* m_staticline3; wxCheckBox* m_rbFixDiscontinuities; wxStaticText* m_toleranceLabel; wxTextCtrl* m_toleranceCtrl; diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index c46fae66fd..c402e087c0 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -425,9 +425,21 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_params.emplace_back( new PARAM( "import_graphics.layer", &m_ImportGraphics.layer, Dwgs_User ) ); + m_params.emplace_back( new PARAM( "import_graphics.use_dlg_layer_selection", + &m_ImportGraphics.use_dlg_layer_selection, true ) ); + m_params.emplace_back( new PARAM( "import_graphics.interactive_placement", &m_ImportGraphics.interactive_placement, true ) ); + m_params.emplace_back( new PARAM( "import_graphics.group_items", + &m_ImportGraphics.group_items, true ) ); + + m_params.emplace_back( new PARAM( "import_graphics.fix_discontinuities", + &m_ImportGraphics.fix_discontinuities, false ) ); + + m_params.emplace_back( new PARAM( "import_graphics.tolerance", + &m_ImportGraphics.tolerance, 0.01, 0.0, 10.0 ) ); + m_params.emplace_back( new PARAM( "import_graphics.line_width_units", &m_ImportGraphics.dxf_line_width_units, 0 ) ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index c4e5459190..ce32ca28b0 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -234,7 +234,11 @@ public: struct DIALOG_IMPORT_GRAPHICS { int layer; + bool use_dlg_layer_selection; bool interactive_placement; + bool group_items; + bool fix_discontinuities; + double tolerance; wxString last_file; double dxf_line_width; int dxf_line_width_units; diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 5c48b487cb..ab8ff540de 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1509,11 +1509,15 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) PICKED_ITEMS_LIST groupUndoList; PCB_LAYER_ID layer = F_Cu; - PCB_GROUP* group = new PCB_GROUP( m_frame->GetModel() ); + PCB_GROUP* group = dlg.ShouldGroupItems() ? new PCB_GROUP( m_frame->GetModel() ) + : nullptr; - newItems.push_back( group ); - selectedItems.push_back( group ); - preview.Add( group ); + if( group ) + { + newItems.push_back( group ); + selectedItems.push_back( group ); + preview.Add( group ); + } if( dlg.ShouldFixDiscontinuities() ) { @@ -1541,7 +1545,12 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) wxCHECK2( item, continue ); newItems.push_back( item ); - group->AddItem( item ); + + if( group ) + group->AddItem( item ); + else + selectedItems.push_back( item ); + groupUndoList.PushItem( ITEM_PICKER( nullptr, item, UNDO_REDO::REGROUP ) ); preview.Add( item );