diff --git a/pcbnew/import_gfx/dialog_import_gfx.cpp b/pcbnew/import_gfx/dialog_import_gfx.cpp index 4354a95d1a..d40ff33c89 100644 --- a/pcbnew/import_gfx/dialog_import_gfx.cpp +++ b/pcbnew/import_gfx/dialog_import_gfx.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include "dxf_import_plugin.h" @@ -40,29 +39,27 @@ #include // Static members of DIALOG_IMPORT_GFX, to remember the user's choices during the session -wxString DIALOG_IMPORT_GFX::m_filename; -bool DIALOG_IMPORT_GFX::m_placementInteractive = true; -bool DIALOG_IMPORT_GFX::m_shouldGroupItems = true; -int DIALOG_IMPORT_GFX::m_layer = Dwgs_User; -double DIALOG_IMPORT_GFX::m_scaleImport = 1.0; // Do not change the imported items size -int DIALOG_IMPORT_GFX::m_originUnits = 0; // millimeter -int DIALOG_IMPORT_GFX::m_dxfLineWidthUnits = 0; // millimeter -int DIALOG_IMPORT_GFX::m_dxfUnits = 0; // first entry in the dxfUnits map below +bool DIALOG_IMPORT_GFX::m_placementInteractive = true; +bool DIALOG_IMPORT_GFX::m_shouldGroupItems = true; +double DIALOG_IMPORT_GFX::m_importScale = 1.0; // Do not change the imported items size + const std::map dxfUnitsMap = { - { DXF_IMPORT_UNITS::INCHES, _( "Inches" ) }, + { DXF_IMPORT_UNITS::INCHES, _( "Inches" ) }, { DXF_IMPORT_UNITS::MILLIMETERS, _( "Millimeters" ) }, - { DXF_IMPORT_UNITS::MILS, _( "Mils" ) }, + { DXF_IMPORT_UNITS::MILS, _( "Mils" ) }, { DXF_IMPORT_UNITS::CENTIMETERS, _( "Centimeter" ) }, - { DXF_IMPORT_UNITS::FEET, _( "Feet" ) }, + { DXF_IMPORT_UNITS::FEET, _( "Feet" ) }, }; -DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFootprintGraphic ) - : DIALOG_IMPORT_GFX_BASE( aParent ) +DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFootprintGraphic ) : + DIALOG_IMPORT_GFX_BASE( aParent ), + m_parent( aParent ), + m_xOrigin( aParent, m_xLabel, m_xCtrl, m_xUnits ), + m_yOrigin( aParent, m_yLabel, m_yCtrl, m_yUnits ), + m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ) { - m_parent = aParent; - if( aImportAsFootprintGraphic ) m_importer = std::make_unique( m_parent->GetBoard()->GetFirstFootprint() ); else @@ -84,52 +81,33 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFoo m_gfxImportMgr = std::make_unique( blacklist ); } - m_originUnits = 0; - m_origin.x = 0.0; // always in mm - m_origin.y = 0.0; // always in mm - m_dxfLineWidth = 0.2; // always in mm - m_dxfLineWidthUnits = 0; + PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings(); - auto cfg = m_parent->GetPcbNewSettings(); - - m_layer = cfg->m_ImportGraphics.layer; m_placementInteractive = cfg->m_ImportGraphics.interactive_placement; - m_filename = cfg->m_ImportGraphics.last_file; - m_dxfLineWidth = cfg->m_ImportGraphics.dxf_line_width; - m_dxfLineWidthUnits = cfg->m_ImportGraphics.dxf_line_width_units; - m_originUnits = cfg->m_ImportGraphics.origin_units; - m_origin.x = cfg->m_ImportGraphics.origin_x; - m_origin.y = cfg->m_ImportGraphics.origin_y; - m_dxfUnits = cfg->m_ImportGraphics.dxf_units; - m_choiceUnitLineWidth->SetSelection( m_dxfLineWidthUnits ); - showDXFDefaultLineWidth(); + m_xOrigin.SetValue( cfg->m_ImportGraphics.origin_x * IU_PER_MM ); + m_yOrigin.SetValue( cfg->m_ImportGraphics.origin_y * IU_PER_MM ); + m_defaultLineWidth.SetValue( cfg->m_ImportGraphics.dxf_line_width * IU_PER_MM ); - m_DxfPcbPositionUnits->SetSelection( m_originUnits ); - showPcbImportOffsets(); - - m_textCtrlFileName->SetValue( m_filename ); + m_textCtrlFileName->SetValue( cfg->m_ImportGraphics.last_file ); m_rbInteractivePlacement->SetValue( m_placementInteractive ); - m_rbAbsolutePlacement->SetValue( not m_placementInteractive ); + m_rbAbsolutePlacement->SetValue( !m_placementInteractive ); m_groupItems->SetValue( m_shouldGroupItems ); - m_textCtrlImportScale->SetValue( wxString::Format( wxT( "%f" ), m_scaleImport ) ); + m_importScaleCtrl->SetValue( wxString::Format( wxT( "%f" ), m_importScale ) ); // Configure the layers list selector - m_SelLayerBox->SetLayersHotkeys( false ); // Do not display hotkeys + m_SelLayerBox->SetLayersHotkeys( false ); // Do not display hotkeys m_SelLayerBox->SetBoardFrame( m_parent ); m_SelLayerBox->Resync(); - if( m_SelLayerBox->SetLayerSelection( m_layer ) < 0 ) - { - m_layer = Dwgs_User; - m_SelLayerBox->SetLayerSelection( m_layer ); - } + if( m_SelLayerBox->SetLayerSelection( cfg->m_ImportGraphics.layer ) < 0 ) + m_SelLayerBox->SetLayerSelection( Dwgs_User ); - for( auto& unitEntry : dxfUnitsMap ) + for( const std::pair& unitEntry : dxfUnitsMap ) m_choiceDxfUnits->Append( unitEntry.second ); - m_choiceDxfUnits->SetSelection( m_dxfUnits ); + m_choiceDxfUnits->SetSelection( cfg->m_ImportGraphics.dxf_units ); m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) ); @@ -145,121 +123,53 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFoo m_textCtrlFileName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_IMPORT_GFX::onFilename ), - NULL, this ); + nullptr, this ); } DIALOG_IMPORT_GFX::~DIALOG_IMPORT_GFX() { - auto cfg = m_parent->GetPcbNewSettings(); + PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings(); - cfg->m_ImportGraphics.layer = m_layer; + cfg->m_ImportGraphics.layer = m_SelLayerBox->GetLayerSelection(); cfg->m_ImportGraphics.interactive_placement = m_placementInteractive; - cfg->m_ImportGraphics.last_file = m_filename; - cfg->m_ImportGraphics.dxf_line_width = m_dxfLineWidth; - cfg->m_ImportGraphics.dxf_line_width_units = m_dxfLineWidthUnits; - cfg->m_ImportGraphics.origin_units = m_originUnits; - cfg->m_ImportGraphics.origin_x = m_origin.x; - cfg->m_ImportGraphics.origin_y = m_origin.y; - cfg->m_ImportGraphics.dxf_units = m_dxfUnits; + cfg->m_ImportGraphics.last_file = m_textCtrlFileName->GetValue(); + cfg->m_ImportGraphics.dxf_line_width = Iu2Millimeter( m_defaultLineWidth.GetValue() ); + cfg->m_ImportGraphics.origin_x = Iu2Millimeter( m_xOrigin.GetValue() ); + cfg->m_ImportGraphics.origin_y = Iu2Millimeter( m_yOrigin.GetValue() ); + cfg->m_ImportGraphics.dxf_units = m_choiceDxfUnits->GetSelection(); + + m_importScale = DoubleValueFromString( EDA_UNITS::UNSCALED, m_importScaleCtrl->GetValue() ); m_textCtrlFileName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_IMPORT_GFX::onFilename ), - NULL, this ); + nullptr, this ); } void DIALOG_IMPORT_GFX::onFilename( wxCommandEvent& event ) { bool enableDXFControls = true; - wxString filename = m_textCtrlFileName->GetValue(); + wxString ext = wxFileName( m_textCtrlFileName->GetValue() ).GetExt(); - if( auto plugin = m_gfxImportMgr->GetPluginByExt( wxFileName( filename ).GetExt() ) ) + if( std::unique_ptr plugin = m_gfxImportMgr->GetPluginByExt( ext ) ) enableDXFControls = dynamic_cast( plugin.get() ) != nullptr; - m_staticTextLineWidth->Enable( enableDXFControls ); - m_textCtrlLineWidth->Enable( enableDXFControls ); - m_choiceUnitLineWidth->Enable( enableDXFControls ); + m_defaultLineWidth.Enable( enableDXFControls ); m_staticTextLineWidth1->Enable( enableDXFControls ); m_choiceDxfUnits->Enable( enableDXFControls ); } -void DIALOG_IMPORT_GFX::onUnitPositionSelection( wxCommandEvent& event ) -{ - // Collect last entered values: - updatePcbImportOffsets_mm(); - - m_originUnits = m_DxfPcbPositionUnits->GetSelection();; - showPcbImportOffsets(); -} - - -double DIALOG_IMPORT_GFX::getDXFDefaultLineWidthMM() -{ - double value = DoubleValueFromString( EDA_UNITS::UNSCALED, m_textCtrlLineWidth->GetValue() ); - - switch( m_dxfLineWidthUnits ) - { - default: - case 0: break; // display units = mm - case 1: value *= 25.4 / 1000; break; // display units = mil - case 2: value *= 25.4; break; // display units = inch - } - - return value; // value is in mm -} - - -void DIALOG_IMPORT_GFX::onUnitWidthSelection( wxCommandEvent& event ) -{ - m_dxfLineWidth = getDXFDefaultLineWidthMM(); - - // Switch to new units - m_dxfLineWidthUnits = m_choiceUnitLineWidth->GetSelection(); - showDXFDefaultLineWidth(); -} - - -void DIALOG_IMPORT_GFX::showPcbImportOffsets() -{ - // Display m_origin value according to the unit selection: - VECTOR2D offset = m_origin; - - if( m_originUnits ) // Units are inches - offset = m_origin / 25.4; - - m_DxfPcbXCoord->SetValue( wxString::Format( wxT( "%f" ), offset.x ) ); - m_DxfPcbYCoord->SetValue( wxString::Format( wxT( "%f" ), offset.y ) ); - -} - - -void DIALOG_IMPORT_GFX::showDXFDefaultLineWidth() -{ - double value; - - switch( m_dxfLineWidthUnits ) - { - default: - case 0: value = m_dxfLineWidth; break; // display units = mm - case 1: value = m_dxfLineWidth / 25.4 * 1000; break; // display units = mil - case 2: value = m_dxfLineWidth / 25.4; break; // display units = inch - } - - m_textCtrlLineWidth->SetValue( wxString::Format( wxT( "%f" ), value ) ); -} - - void DIALOG_IMPORT_GFX::onBrowseFiles( wxCommandEvent& event ) { wxString path; - wxString filename; + wxString filename = m_textCtrlFileName->GetValue(); - if( !m_filename.IsEmpty() ) + if( !filename.IsEmpty() ) { - wxFileName fn( m_filename ); + wxFileName fn( filename ); path = fn.GetPath(); filename = fn.GetFullName(); } @@ -282,16 +192,8 @@ void DIALOG_IMPORT_GFX::onBrowseFiles( wxCommandEvent& event ) wxFileDialog dlg( m_parent, _( "Open File" ), path, filename, wildcardsDesc, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - if( dlg.ShowModal() != wxID_OK ) - return; - - wxString fileName = dlg.GetPath(); - - if( fileName.IsEmpty() ) - return; - - m_filename = fileName; - m_textCtrlFileName->SetValue( fileName ); + if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() ) + m_textCtrlFileName->SetValue( dlg.GetPath() ); } @@ -300,64 +202,49 @@ bool DIALOG_IMPORT_GFX::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) return false; - m_filename = m_textCtrlFileName->GetValue(); - - if( m_filename.IsEmpty() ) + if( m_textCtrlFileName->GetValue().IsEmpty() ) { wxMessageBox( _( "No file selected!" ) ); return false; } - m_originUnits = m_DxfPcbPositionUnits->GetSelection(); - updatePcbImportOffsets_mm(); // Update m_originX and m_originY; - - m_layer = m_SelLayerBox->GetLayerSelection(); - - if( m_layer < 0 ) + if( m_SelLayerBox->GetLayerSelection() < 0 ) { wxMessageBox( _( "Please select a valid layer." ) ); return false; } - m_dxfLineWidthUnits = m_choiceUnitLineWidth->GetSelection(); - m_dxfLineWidth = getDXFDefaultLineWidthMM(); + wxString ext = wxFileName( m_textCtrlFileName->GetValue() ).GetExt(); + double scale = DoubleValueFromString( EDA_UNITS::UNSCALED, m_importScaleCtrl->GetValue() ); + VECTOR2D origin( m_xOrigin.GetValue() / scale, m_yOrigin.GetValue() / scale ); - m_dxfUnits = m_choiceDxfUnits->GetSelection(); - - m_importer->SetLayer( PCB_LAYER_ID( m_layer ) ); - - if( auto plugin = m_gfxImportMgr->GetPluginByExt( wxFileName( m_filename ).GetExt() ) ) + if( std::unique_ptr plugin = m_gfxImportMgr->GetPluginByExt( ext ) ) { - DXF_IMPORT_PLUGIN* dxfPlugin = dynamic_cast( plugin.get() ); - - if( dxfPlugin ) + if( DXF_IMPORT_PLUGIN* dxfPlugin = dynamic_cast( plugin.get() ) ) { auto it = dxfUnitsMap.begin(); - std::advance( it, m_dxfUnits ); + std::advance( it, m_choiceDxfUnits->GetSelection() ); if( it == dxfUnitsMap.end() ) dxfPlugin->SetUnit( DXF_IMPORT_UNITS::DEFAULT ); else dxfPlugin->SetUnit( it->first ); - m_importer->SetLineWidthMM( m_dxfLineWidth ); + m_importer->SetLineWidthMM( Iu2Millimeter( m_defaultLineWidth.GetValue() ) ); } else { m_importer->SetLineWidthMM( 0.0 ); } - // Set coordinates offset for import (offset is given in mm) - m_importer->SetImportOffsetMM( m_origin ); - m_scaleImport = DoubleValueFromString( EDA_UNITS::UNSCALED, - m_textCtrlImportScale->GetValue() ); - m_importer->SetPlugin( std::move( plugin ) ); + m_importer->SetLayer( PCB_LAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); + m_importer->SetImportOffsetMM( { Iu2Millimeter( origin.x ), Iu2Millimeter( origin.y ) } ); LOCALE_IO dummy; // Ensure floats can be read. - if( m_importer->Load( m_filename ) ) - m_importer->Import( m_scaleImport ); + if( m_importer->Load( m_textCtrlFileName->GetValue() ) ) + m_importer->Import( scale ); // Get warning messages: wxString warnings = m_importer->GetMessages(); @@ -371,14 +258,14 @@ bool DIALOG_IMPORT_GFX::TransferDataFromWindow() dlg.AddHTML_Text( warnings ); dlg.ShowModal(); } + + return true; } else { wxMessageBox( _( "There is no plugin to handle this file type." ) ); return false; } - - return true; } @@ -388,21 +275,10 @@ void DIALOG_IMPORT_GFX::originOptionOnUpdateUI( wxUpdateUIEvent& event ) m_rbInteractivePlacement->SetValue( m_placementInteractive ); if( m_rbAbsolutePlacement->GetValue() == m_placementInteractive ) - m_rbAbsolutePlacement->SetValue( not m_placementInteractive ); + m_rbAbsolutePlacement->SetValue( !m_placementInteractive ); - m_DxfPcbPositionUnits->Enable( not m_placementInteractive ); - m_DxfPcbXCoord->Enable( not m_placementInteractive ); - m_DxfPcbYCoord->Enable( not m_placementInteractive ); -} - - -void DIALOG_IMPORT_GFX::updatePcbImportOffsets_mm() -{ - m_origin.x = DoubleValueFromString( EDA_UNITS::UNSCALED, m_DxfPcbXCoord->GetValue() ); - m_origin.y = DoubleValueFromString( EDA_UNITS::UNSCALED, m_DxfPcbYCoord->GetValue() ); - - if( m_originUnits ) // Units are inches - m_origin = m_origin * 25.4; + m_xOrigin.Enable( !m_placementInteractive ); + m_yOrigin.Enable( !m_placementInteractive ); } diff --git a/pcbnew/import_gfx/dialog_import_gfx.h b/pcbnew/import_gfx/dialog_import_gfx.h index 6522fcd022..aba74e89bc 100644 --- a/pcbnew/import_gfx/dialog_import_gfx.h +++ b/pcbnew/import_gfx/dialog_import_gfx.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,6 +25,7 @@ #ifndef __DIALOG_IMPORT_GFX_H__ #define __DIALOG_IMPORT_GFX_H__ +#include #include #include #include "dialog_import_gfx_base.h" @@ -32,6 +33,7 @@ class GRAPHICS_IMPORT_MGR; + class DIALOG_IMPORT_GFX : public DIALOG_IMPORT_GFX_BASE { public: @@ -51,25 +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 m_placementInteractive; - } + bool IsPlacementInteractive() { return m_placementInteractive; } /** * @return true if the items should be added into a group when being placed. */ - bool ShouldGroupItems() - { - return m_shouldGroupItems; - } + bool ShouldGroupItems() { return m_shouldGroupItems; } bool TransferDataFromWindow() override; private: // Virtual event handlers - void onUnitPositionSelection( wxCommandEvent& event ) override; - void onUnitWidthSelection( wxCommandEvent& event ) override; void onBrowseFiles( wxCommandEvent& event ) override; void onFilename( wxCommandEvent& event ); void originOptionOnUpdateUI( wxUpdateUIEvent& event ) override; @@ -89,28 +83,19 @@ private: m_shouldGroupItems = m_groupItems->GetValue(); } - void updatePcbImportOffsets_mm(); - double getDXFDefaultLineWidthMM(); - void showDXFDefaultLineWidth(); - void showPcbImportOffsets(); - - PCB_BASE_FRAME* m_parent; +private: + PCB_BASE_FRAME* m_parent; std::unique_ptr m_importer; std::unique_ptr m_gfxImportMgr; - static int m_originUnits; - VECTOR2D m_origin; // This is the offset to add to imported coordinates - // Always in mm - static wxString m_filename; + UNIT_BINDER m_xOrigin; + UNIT_BINDER m_yOrigin; + UNIT_BINDER m_defaultLineWidth; + static bool m_shouldGroupItems; static bool m_placementInteractive; - static int m_layer; - double m_dxfLineWidth; // always in mm: line width when a line width - // is not specified - static int m_dxfLineWidthUnits; - static double m_scaleImport; // a scale factor to change the size of imported - // items m_scaleImport =1.0 means keep original size - static int m_dxfUnits; + static double m_importScale; // a scale factor to change the size of imported + // items m_importScale =1.0 means keep original size }; #endif // __DIALOG_IMPORT_GFX_H__ diff --git a/pcbnew/import_gfx/dialog_import_gfx_base.cpp b/pcbnew/import_gfx/dialog_import_gfx_base.cpp index d67e47b01f..8710474ab6 100644 --- a/pcbnew/import_gfx/dialog_import_gfx_base.cpp +++ b/pcbnew/import_gfx/dialog_import_gfx_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -21,7 +21,7 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id, wxBoxSizer* bSizerFile; bSizerFile = new wxBoxSizer( wxHORIZONTAL ); - m_staticTextFile = new wxStaticText( this, wxID_ANY, _("File"), wxDefaultPosition, wxDefaultSize, 0 ); + 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.") ); @@ -34,7 +34,7 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id, bSizerFile->Add( m_textCtrlFileName, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_browseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - bSizerFile->Add( m_browseButton, 0, wxALL, 5 ); + bSizerFile->Add( m_browseButton, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); bSizerMain->Add( bSizerFile, 0, wxALL|wxEXPAND, 10 ); @@ -58,51 +58,47 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id, wxBoxSizer* bSizerPosSettings; bSizerPosSettings = new wxBoxSizer( wxHORIZONTAL ); - m_staticTextXpos = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextXpos->Wrap( -1 ); - bSizerPosSettings->Add( m_staticTextXpos, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + m_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_DxfPcbXCoord = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_xCtrl = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); #ifdef __WXGTK__ - if ( !m_DxfPcbXCoord->HasFlag( wxTE_MULTILINE ) ) + if ( !m_xCtrl->HasFlag( wxTE_MULTILINE ) ) { - m_DxfPcbXCoord->SetMaxLength( 10 ); + m_xCtrl->SetMaxLength( 10 ); } #else - m_DxfPcbXCoord->SetMaxLength( 10 ); + m_xCtrl->SetMaxLength( 10 ); #endif - m_DxfPcbXCoord->SetToolTip( _("DXF origin on PCB Grid, X Coordinate") ); + m_xCtrl->SetToolTip( _("DXF origin on PCB Grid, X Coordinate") ); - bSizerPosSettings->Add( m_DxfPcbXCoord, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + bSizerPosSettings->Add( m_xCtrl, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - m_staticTextYpos = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextYpos->Wrap( -1 ); - bSizerPosSettings->Add( m_staticTextYpos, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + m_xUnits = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_xUnits->Wrap( -1 ); + bSizerPosSettings->Add( m_xUnits, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); - m_DxfPcbYCoord = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + 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_DxfPcbYCoord->HasFlag( wxTE_MULTILINE ) ) + if ( !m_yCtrl->HasFlag( wxTE_MULTILINE ) ) { - m_DxfPcbYCoord->SetMaxLength( 10 ); + m_yCtrl->SetMaxLength( 10 ); } #else - m_DxfPcbYCoord->SetMaxLength( 10 ); + m_yCtrl->SetMaxLength( 10 ); #endif - m_DxfPcbYCoord->SetToolTip( _("DXF origin on PCB Grid, Y Coordinate") ); + m_yCtrl->SetToolTip( _("DXF origin on PCB Grid, Y Coordinate") ); - bSizerPosSettings->Add( m_DxfPcbYCoord, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + bSizerPosSettings->Add( m_yCtrl, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - m_staticTextUnits = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Units"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextUnits->Wrap( -1 ); - bSizerPosSettings->Add( m_staticTextUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); - - wxString m_DxfPcbPositionUnitsChoices[] = { _("mm"), _("inch") }; - int m_DxfPcbPositionUnitsNChoices = sizeof( m_DxfPcbPositionUnitsChoices ) / sizeof( wxString ); - m_DxfPcbPositionUnits = new wxChoice( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_DxfPcbPositionUnitsNChoices, m_DxfPcbPositionUnitsChoices, 0 ); - m_DxfPcbPositionUnits->SetSelection( 0 ); - m_DxfPcbPositionUnits->SetToolTip( _("Select PCB grid units") ); - - bSizerPosSettings->Add( m_DxfPcbPositionUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + 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 ); @@ -138,12 +134,12 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id, fgSizerImportSettings->Add( 0, 0, 0, 0, 5 ); - m_staticTextscale = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Import scale:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextscale->Wrap( -1 ); - fgSizerImportSettings->Add( m_staticTextscale, 0, wxALIGN_CENTER_VERTICAL, 5 ); + m_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_textCtrlImportScale = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerImportSettings->Add( m_textCtrlImportScale, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 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, 0, 0, 5 ); @@ -183,18 +179,16 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id, fgDxfImportSettings->SetFlexibleDirection( wxBOTH ); fgDxfImportSettings->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_staticTextLineWidth = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Default line width:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextLineWidth->Wrap( -1 ); - fgDxfImportSettings->Add( m_staticTextLineWidth, 0, wxALIGN_CENTER_VERTICAL, 5 ); + 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_textCtrlLineWidth = new wxTextCtrl( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgDxfImportSettings->Add( m_textCtrlLineWidth, 0, wxEXPAND, 5 ); + m_lineWidthCtrl = new wxTextCtrl( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgDxfImportSettings->Add( m_lineWidthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - wxString m_choiceUnitLineWidthChoices[] = { _("mm"), _("mils"), _("inches") }; - int m_choiceUnitLineWidthNChoices = sizeof( m_choiceUnitLineWidthChoices ) / sizeof( wxString ); - m_choiceUnitLineWidth = new wxChoice( sbSizer3->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceUnitLineWidthNChoices, m_choiceUnitLineWidthChoices, 0 ); - m_choiceUnitLineWidth->SetSelection( 0 ); - fgDxfImportSettings->Add( m_choiceUnitLineWidth, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + m_lineWidthUnits = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lineWidthUnits->Wrap( -1 ); + fgDxfImportSettings->Add( m_lineWidthUnits, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); m_staticTextLineWidth1 = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("Default units:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextLineWidth1->Wrap( -1 ); @@ -239,9 +233,7 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id, m_rbInteractivePlacement->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::originOptionOnUpdateUI ), NULL, this ); m_rbAbsolutePlacement->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onAbsolutePlacement ), NULL, this ); m_rbAbsolutePlacement->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::originOptionOnUpdateUI ), NULL, this ); - m_DxfPcbPositionUnits->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onUnitPositionSelection ), NULL, this ); m_groupItems->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onGroupItems ), NULL, this ); - m_choiceUnitLineWidth->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onUnitWidthSelection ), NULL, this ); } DIALOG_IMPORT_GFX_BASE::~DIALOG_IMPORT_GFX_BASE() @@ -252,8 +244,6 @@ DIALOG_IMPORT_GFX_BASE::~DIALOG_IMPORT_GFX_BASE() m_rbInteractivePlacement->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::originOptionOnUpdateUI ), NULL, this ); m_rbAbsolutePlacement->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onAbsolutePlacement ), NULL, this ); m_rbAbsolutePlacement->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_IMPORT_GFX_BASE::originOptionOnUpdateUI ), NULL, this ); - m_DxfPcbPositionUnits->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onUnitPositionSelection ), NULL, this ); m_groupItems->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onGroupItems ), NULL, this ); - m_choiceUnitLineWidth->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onUnitWidthSelection ), NULL, this ); } diff --git a/pcbnew/import_gfx/dialog_import_gfx_base.fbp b/pcbnew/import_gfx/dialog_import_gfx_base.fbp index 503690ba2b..e96e5c4579 100644 --- a/pcbnew/import_gfx/dialog_import_gfx_base.fbp +++ b/pcbnew/import_gfx/dialog_import_gfx_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_import_gfx_base 1000 none + 1 dialog_dxf_import @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -50,6 +52,7 @@ DIALOG_SHIM; dialog_shim.h Import Vector Graphics File + 0 @@ -99,7 +102,7 @@ 0 0 wxID_ANY - File + File: 0 0 @@ -194,7 +197,7 @@ 5 - wxALL + wxTOP|wxBOTTOM|wxRIGHT 0 1 @@ -205,6 +208,7 @@ + 0 @@ -279,11 +283,11 @@ wxVERTICAL 1 none - + 5 wxEXPAND 0 - + bSizerOptions wxVERTICAL @@ -354,11 +358,11 @@ originOptionOnUpdateUI - + 5 wxEXPAND 0 - + bSizerUserPos wxHORIZONTAL @@ -429,11 +433,11 @@ originOptionOnUpdateUI - + 5 wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP 1 - + bSizerPosSettings wxHORIZONTAL @@ -479,7 +483,7 @@ 0 1 - m_staticTextXpos + m_xLabel 1 @@ -539,7 +543,7 @@ 0 1 - m_DxfPcbXCoord + m_xCtrl 1 @@ -563,6 +567,67 @@ + + 5 + wxTOP|wxBOTTOM|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_xUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + 5 wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT @@ -604,7 +669,7 @@ 0 1 - m_staticTextYpos + m_yLabel 1 @@ -664,7 +729,7 @@ 0 1 - m_DxfPcbYCoord + m_yCtrl 1 @@ -690,7 +755,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -720,7 +785,7 @@ 0 0 wxID_ANY - Units + mm 0 0 @@ -729,7 +794,7 @@ 0 1 - m_staticTextUnits + m_yUnits 1 @@ -749,71 +814,6 @@ -1 - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "mm" "inch" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_DxfPcbPositionUnits - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - - 0 - Select PCB grid units - - wxFILTER_NONE - wxDefaultValidator - - - - - onUnitPositionSelection - - @@ -1036,7 +1036,7 @@ 0 1 - m_staticTextscale + m_importScaleLabel 1 @@ -1096,7 +1096,7 @@ 0 1 - m_textCtrlImportScale + m_importScaleCtrl 1 @@ -1348,7 +1348,7 @@ 0 1 - m_staticTextLineWidth + m_lineWidthLabel 1 @@ -1370,7 +1370,7 @@ 5 - wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND 0 1 @@ -1408,7 +1408,7 @@ 0 1 - m_textCtrlLineWidth + m_lineWidthCtrl 1 @@ -1434,9 +1434,9 @@ 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT + wxTOP|wxBOTTOM|wxRIGHT 0 - + 1 1 1 @@ -1450,7 +1450,6 @@ 1 0 - "mm" "mils" "inches" 1 1 @@ -1465,6 +1464,8 @@ 0 0 wxID_ANY + mm + 0 0 @@ -1472,7 +1473,7 @@ 0 1 - m_choiceUnitLineWidth + m_lineWidthUnits 1 @@ -1480,21 +1481,16 @@ 1 Resizable - 0 1 - + ; ; forward_declare 0 - - wxFILTER_NONE - wxDefaultValidator - - onUnitWidthSelection + -1 diff --git a/pcbnew/import_gfx/dialog_import_gfx_base.h b/pcbnew/import_gfx/dialog_import_gfx_base.h index 8c9ccc51a5..a48bc5eaaa 100644 --- a/pcbnew/import_gfx/dialog_import_gfx_base.h +++ b/pcbnew/import_gfx/dialog_import_gfx_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -28,11 +28,11 @@ class PCB_LAYER_BOX_SELECTOR; #include #include #include -#include #include #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -51,40 +51,39 @@ class DIALOG_IMPORT_GFX_BASE : public DIALOG_SHIM wxBitmapButton* m_browseButton; wxRadioButton* m_rbInteractivePlacement; wxRadioButton* m_rbAbsolutePlacement; - wxStaticText* m_staticTextXpos; - wxTextCtrl* m_DxfPcbXCoord; - wxStaticText* m_staticTextYpos; - wxTextCtrl* m_DxfPcbYCoord; - wxStaticText* m_staticTextUnits; - wxChoice* m_DxfPcbPositionUnits; + wxStaticText* m_xLabel; + wxTextCtrl* m_xCtrl; + wxStaticText* m_xUnits; + wxStaticText* m_yLabel; + wxTextCtrl* m_yCtrl; + wxStaticText* m_yUnits; wxStaticText* m_staticTextBrdlayer; PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; - wxStaticText* m_staticTextscale; - wxTextCtrl* m_textCtrlImportScale; + wxStaticText* m_importScaleLabel; + wxTextCtrl* m_importScaleCtrl; wxStaticLine* m_staticline1; wxCheckBox* m_groupItems; - wxStaticText* m_staticTextLineWidth; - wxTextCtrl* m_textCtrlLineWidth; - wxChoice* m_choiceUnitLineWidth; + 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, overide them in your derived class + // Virtual event handlers, override them in your derived class 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 onUnitPositionSelection( wxCommandEvent& event ) { event.Skip(); } virtual void onGroupItems( wxCommandEvent& event ) { event.Skip(); } - virtual void onUnitWidthSelection( wxCommandEvent& event ) { event.Skip(); } public: DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Import Vector Graphics File"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_IMPORT_GFX_BASE(); };