2013-10-26 07:03:06 +00:00
|
|
|
/**
|
|
|
|
* @file dialog_dxf_import.cpp
|
|
|
|
* @brief Dialog to import a dxf file on a given board layer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2017-11-12 00:31:38 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-10-26 07:03:06 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
#include <dialog_dxf_import.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <kiface_i.h>
|
2016-06-05 11:49:25 +00:00
|
|
|
#include <convert_to_biu.h>
|
2013-10-26 07:03:06 +00:00
|
|
|
#include <class_pcb_layer_box_selector.h>
|
2017-11-12 00:31:38 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
#include <class_board.h>
|
2014-07-09 13:02:56 +00:00
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <class_text_mod.h>
|
|
|
|
#include <class_pcb_text.h>
|
2013-10-24 16:44:38 +00:00
|
|
|
|
2013-10-28 08:06:38 +00:00
|
|
|
// Keys to store setup in config
|
2017-11-04 20:34:17 +00:00
|
|
|
#define DXF_IMPORT_LAYER_OPTION_KEY "DxfImportBrdLayer"
|
|
|
|
#define DXF_IMPORT_COORD_ORIGIN_KEY "DxfImportCoordOrigin"
|
|
|
|
#define DXF_IMPORT_LAST_FILE_KEY "DxfImportLastFile"
|
|
|
|
#define DXF_IMPORT_IMPORT_UNITS_KEY "DxfImportOffsetUnits"
|
|
|
|
#define DXF_IMPORT_IMPORT_OFFSET_X_KEY "DxfImportOffsetX"
|
|
|
|
#define DXF_IMPORT_IMPORT_OFFSET_Y_KEY "DxfImportOffsetY"
|
|
|
|
#define DXF_IMPORT_LINEWIDTH_UNITS_KEY "DxfImportLineWidthUnits"
|
|
|
|
#define DXF_IMPORT_LINEWIDTH_KEY "DxfImportLineWidth"
|
2015-08-27 18:10:28 +00:00
|
|
|
|
2013-10-28 08:06:38 +00:00
|
|
|
|
2013-10-26 07:03:06 +00:00
|
|
|
// Static members of DIALOG_DXF_IMPORT, to remember
|
|
|
|
// the user's choices during the session
|
|
|
|
wxString DIALOG_DXF_IMPORT::m_dxfFilename;
|
2015-08-27 18:10:28 +00:00
|
|
|
int DIALOG_DXF_IMPORT::m_offsetSelection = 0;
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_NUM DIALOG_DXF_IMPORT::m_layer = Dwgs_User;
|
2013-10-26 07:03:06 +00:00
|
|
|
|
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent, bool aImportAsFootprintGraphic )
|
2014-07-09 13:02:56 +00:00
|
|
|
: DIALOG_DXF_IMPORT_BASE( aParent )
|
2013-10-26 07:03:06 +00:00
|
|
|
{
|
|
|
|
m_parent = aParent;
|
2017-11-04 20:34:17 +00:00
|
|
|
m_dxfImporter.ImportAsFootprintGraphic( aImportAsFootprintGraphic );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
m_config = Kiface().KifaceSettings();
|
2017-11-04 20:34:17 +00:00
|
|
|
m_PcbImportUnits = 0;
|
|
|
|
m_PcbImportOffsetX = 0.0; // always in mm
|
|
|
|
m_PcbImportOffsetY = 0.0; // always in mm
|
2017-12-04 09:20:05 +00:00
|
|
|
m_PCBdefaultLineWidth = 0.2; // in mm
|
|
|
|
m_PCBLineWidthUnits = 0;
|
2013-10-28 08:06:38 +00:00
|
|
|
|
|
|
|
if( m_config )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
m_layer = m_config->Read( DXF_IMPORT_LAYER_OPTION_KEY, (long)Dwgs_User );
|
2015-08-27 18:10:28 +00:00
|
|
|
m_offsetSelection = m_config->Read( DXF_IMPORT_COORD_ORIGIN_KEY, (long)0 );
|
2013-10-28 08:06:38 +00:00
|
|
|
m_dxfFilename = m_config->Read( DXF_IMPORT_LAST_FILE_KEY, wxEmptyString );
|
2017-11-04 20:34:17 +00:00
|
|
|
m_config->Read( DXF_IMPORT_IMPORT_UNITS_KEY, &m_PcbImportUnits, 0 );
|
|
|
|
m_config->Read( DXF_IMPORT_IMPORT_OFFSET_X_KEY, &m_PcbImportOffsetX, 0.0 );
|
|
|
|
m_config->Read( DXF_IMPORT_IMPORT_OFFSET_Y_KEY, &m_PcbImportOffsetY, 0.0 );
|
|
|
|
m_config->Read( DXF_IMPORT_LINEWIDTH_UNITS_KEY, &m_PCBLineWidthUnits, 0 );
|
|
|
|
m_config->Read( DXF_IMPORT_LINEWIDTH_KEY, &m_PCBdefaultLineWidth, 0.2 );
|
2013-10-28 08:06:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
m_choiceUnitLineWidth->SetSelection( m_PCBLineWidthUnits );
|
|
|
|
showPCBdefaultLineWidth();
|
|
|
|
m_dxfImporter.SetDefaultLineWidthMM( m_PCBdefaultLineWidth );
|
|
|
|
|
|
|
|
m_DxfPcbPositionUnits->SetSelection( m_PcbImportUnits );
|
|
|
|
showPcbImportOffsets();
|
2015-08-27 18:10:28 +00:00
|
|
|
|
2013-10-26 07:03:06 +00:00
|
|
|
m_textCtrlFileName->SetValue( m_dxfFilename );
|
|
|
|
m_rbOffsetOption->SetSelection( m_offsetSelection );
|
|
|
|
|
|
|
|
// Configure the layers list selector
|
2014-06-24 16:17:18 +00:00
|
|
|
m_SelLayerBox->SetLayersHotkeys( false ); // Do not display hotkeys
|
|
|
|
m_SelLayerBox->SetLayerSet( LSET::AllCuMask() ); // Do not use copper layers
|
2013-10-26 07:03:06 +00:00
|
|
|
m_SelLayerBox->SetBoardFrame( m_parent );
|
|
|
|
m_SelLayerBox->Resync();
|
2013-10-28 08:06:38 +00:00
|
|
|
|
2013-10-26 07:03:06 +00:00
|
|
|
if( m_SelLayerBox->SetLayerSelection( m_layer ) < 0 )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
m_layer = Dwgs_User;
|
2013-10-26 07:03:06 +00:00
|
|
|
m_SelLayerBox->SetLayerSelection( m_layer );
|
|
|
|
}
|
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
2013-10-26 07:03:06 +00:00
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_DXF_IMPORT::~DIALOG_DXF_IMPORT()
|
|
|
|
{
|
|
|
|
m_offsetSelection = m_rbOffsetOption->GetSelection();
|
2017-11-04 20:34:17 +00:00
|
|
|
getPcbImportOffsets();
|
2013-10-26 07:03:06 +00:00
|
|
|
m_layer = m_SelLayerBox->GetLayerSelection();
|
2013-10-28 08:06:38 +00:00
|
|
|
|
|
|
|
if( m_config )
|
|
|
|
{
|
|
|
|
m_config->Write( DXF_IMPORT_LAYER_OPTION_KEY, (long)m_layer );
|
|
|
|
m_config->Write( DXF_IMPORT_COORD_ORIGIN_KEY, m_offsetSelection );
|
|
|
|
m_config->Write( DXF_IMPORT_LAST_FILE_KEY, m_dxfFilename );
|
2015-08-27 18:10:28 +00:00
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
m_config->Write( DXF_IMPORT_IMPORT_UNITS_KEY, m_PcbImportUnits );
|
|
|
|
m_config->Write( DXF_IMPORT_IMPORT_OFFSET_X_KEY, m_PcbImportOffsetX );
|
|
|
|
m_config->Write( DXF_IMPORT_IMPORT_OFFSET_Y_KEY, m_PcbImportOffsetY );
|
|
|
|
|
|
|
|
m_config->Write( DXF_IMPORT_LINEWIDTH_UNITS_KEY, m_PCBLineWidthUnits );
|
|
|
|
m_PCBLineWidthUnits = getPCBdefaultLineWidthMM();
|
|
|
|
m_config->Write( DXF_IMPORT_LINEWIDTH_KEY, m_PCBdefaultLineWidth );
|
2013-10-28 08:06:38 +00:00
|
|
|
}
|
2013-10-26 07:03:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
void DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT::onUnitPositionSelection( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Collect last entered values:
|
|
|
|
getPcbImportOffsets();
|
|
|
|
|
|
|
|
m_PcbImportUnits = m_DxfPcbPositionUnits->GetSelection();;
|
|
|
|
showPcbImportOffsets();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double DIALOG_DXF_IMPORT::getPCBdefaultLineWidthMM()
|
|
|
|
{
|
|
|
|
double value = DoubleValueFromString( UNSCALED_UNITS, m_textCtrlLineWidth->GetValue() );
|
|
|
|
|
|
|
|
switch( m_PCBLineWidthUnits )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: // display units = mm
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // display units = mil
|
|
|
|
value *= 25.4 / 1000;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // display units = inch
|
|
|
|
value *= 25.4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value; // value is in mm
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DXF_IMPORT::onUnitWidthSelection( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
m_PCBdefaultLineWidth = getPCBdefaultLineWidthMM();
|
|
|
|
|
|
|
|
// Switch to new units
|
|
|
|
m_PCBLineWidthUnits = m_choiceUnitLineWidth->GetSelection();
|
|
|
|
showPCBdefaultLineWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DXF_IMPORT::showPcbImportOffsets()
|
|
|
|
{
|
|
|
|
// Display m_PcbImportOffsetX and m_PcbImportOffsetY values according to
|
|
|
|
// the unit selection:
|
|
|
|
double xoffset = m_PcbImportOffsetX;
|
|
|
|
double yoffset = m_PcbImportOffsetY;
|
|
|
|
|
|
|
|
if( m_PcbImportUnits ) // Units are inches
|
|
|
|
{
|
|
|
|
xoffset /= 25.4;
|
|
|
|
yoffset /= 25.4;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_DxfPcbXCoord->SetValue( wxString::Format( "%f", xoffset ) );
|
|
|
|
m_DxfPcbYCoord->SetValue( wxString::Format( "%f", yoffset ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DXF_IMPORT::showPCBdefaultLineWidth()
|
|
|
|
{
|
|
|
|
double value;
|
|
|
|
|
|
|
|
switch( m_PCBLineWidthUnits )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: // display units = mm
|
|
|
|
value = m_PCBdefaultLineWidth;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // display units = mil
|
|
|
|
value = m_PCBdefaultLineWidth / 25.4 * 1000;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // display units = inch
|
|
|
|
value = m_PCBdefaultLineWidth / 25.4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_textCtrlLineWidth->SetValue( wxString::Format( "%f", value ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-26 07:03:06 +00:00
|
|
|
void DIALOG_DXF_IMPORT::OnBrowseDxfFiles( wxCommandEvent& event )
|
|
|
|
{
|
2013-10-28 08:06:38 +00:00
|
|
|
wxString path;
|
2014-07-09 13:02:56 +00:00
|
|
|
wxString filename;
|
2013-10-28 08:06:38 +00:00
|
|
|
|
|
|
|
if( !m_dxfFilename.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxFileName fn( m_dxfFilename );
|
|
|
|
path = fn.GetPath();
|
2014-07-09 13:02:56 +00:00
|
|
|
filename = fn.GetFullName();
|
2013-10-28 08:06:38 +00:00
|
|
|
}
|
2015-08-27 18:10:28 +00:00
|
|
|
|
2013-10-26 07:03:06 +00:00
|
|
|
wxFileDialog dlg( m_parent,
|
2015-08-27 18:10:28 +00:00
|
|
|
_( "Open File" ),
|
2014-07-09 13:02:56 +00:00
|
|
|
path, filename,
|
2017-11-12 00:31:38 +00:00
|
|
|
DxfFileWildcard(),
|
2013-10-24 16:44:38 +00:00
|
|
|
wxFD_OPEN|wxFD_FILE_MUST_EXIST );
|
2015-02-27 14:33:13 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
2013-10-24 16:44:38 +00:00
|
|
|
|
|
|
|
wxString fileName = dlg.GetPath();
|
|
|
|
|
2013-10-26 07:03:06 +00:00
|
|
|
if( fileName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_dxfFilename = fileName;
|
|
|
|
m_textCtrlFileName->SetValue( fileName );
|
|
|
|
}
|
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
bool DIALOG_DXF_IMPORT::TransferDataFromWindow()
|
2013-10-26 07:03:06 +00:00
|
|
|
{
|
|
|
|
m_dxfFilename = m_textCtrlFileName->GetValue();
|
|
|
|
|
|
|
|
if( m_dxfFilename.IsEmpty() )
|
2017-11-04 20:34:17 +00:00
|
|
|
{
|
|
|
|
wxMessageBox( _( "Error: No DXF filename!" ) );
|
|
|
|
return false;
|
|
|
|
}
|
2013-10-26 07:03:06 +00:00
|
|
|
|
|
|
|
double offsetX = 0;
|
|
|
|
double offsetY = 0;
|
|
|
|
|
|
|
|
m_offsetSelection = m_rbOffsetOption->GetSelection();
|
2015-08-27 18:10:28 +00:00
|
|
|
|
2013-10-26 07:03:06 +00:00
|
|
|
switch( m_offsetSelection )
|
2013-10-24 16:44:38 +00:00
|
|
|
{
|
2015-08-27 18:10:28 +00:00
|
|
|
case 0:
|
|
|
|
offsetX = m_parent->GetPageSizeIU().x * MM_PER_IU / 2;
|
|
|
|
offsetY = m_parent->GetPageSizeIU().y * MM_PER_IU / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
break;
|
2013-10-26 07:03:06 +00:00
|
|
|
|
2015-08-27 18:10:28 +00:00
|
|
|
case 2:
|
|
|
|
offsetY = m_parent->GetPageSizeIU().y * MM_PER_IU / 2;
|
|
|
|
break;
|
2013-10-26 07:03:06 +00:00
|
|
|
|
2015-08-27 18:10:28 +00:00
|
|
|
case 3:
|
|
|
|
offsetY = m_parent->GetPageSizeIU().y * MM_PER_IU;
|
|
|
|
break;
|
2013-10-26 07:03:06 +00:00
|
|
|
|
2015-08-27 18:10:28 +00:00
|
|
|
case 4:
|
2017-11-04 20:34:17 +00:00
|
|
|
getPcbImportOffsets();
|
|
|
|
offsetX = m_PcbImportOffsetX;
|
|
|
|
offsetY = m_PcbImportOffsetY;
|
2015-08-27 18:10:28 +00:00
|
|
|
break;
|
2013-10-24 16:44:38 +00:00
|
|
|
}
|
|
|
|
|
2013-10-26 07:03:06 +00:00
|
|
|
// Set coordinates offset for import (offset is given in mm)
|
2014-07-09 13:02:56 +00:00
|
|
|
m_dxfImporter.SetOffset( offsetX, offsetY );
|
2013-10-26 07:03:06 +00:00
|
|
|
m_layer = m_SelLayerBox->GetLayerSelection();
|
2014-07-09 13:02:56 +00:00
|
|
|
m_dxfImporter.SetBrdLayer( m_layer );
|
2017-11-04 20:34:17 +00:00
|
|
|
m_PCBdefaultLineWidth = getPCBdefaultLineWidthMM();
|
|
|
|
m_dxfImporter.SetDefaultLineWidthMM( m_PCBdefaultLineWidth );
|
2013-10-30 12:14:45 +00:00
|
|
|
|
|
|
|
// Read dxf file:
|
2014-07-09 13:02:56 +00:00
|
|
|
m_dxfImporter.ImportDxfFile( m_dxfFilename );
|
2013-10-30 12:14:45 +00:00
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
return true;
|
2013-10-26 07:03:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
bool InvokeDXFDialogBoardImport( PCB_BASE_FRAME* aCaller )
|
2013-10-26 07:03:06 +00:00
|
|
|
{
|
|
|
|
DIALOG_DXF_IMPORT dlg( aCaller );
|
2014-07-09 13:02:56 +00:00
|
|
|
bool success = ( dlg.ShowModal() == wxID_OK );
|
2013-10-26 07:03:06 +00:00
|
|
|
|
|
|
|
if( success )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
|
|
|
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
|
|
|
|
PICKED_ITEMS_LIST picklist;
|
|
|
|
BOARD* board = aCaller->GetBoard();
|
|
|
|
|
|
|
|
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
|
|
|
|
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = *it;
|
|
|
|
board->Add( item );
|
|
|
|
|
|
|
|
ITEM_PICKER itemWrapper( item, UR_NEW );
|
|
|
|
picklist.PushItem( itemWrapper );
|
|
|
|
}
|
|
|
|
|
|
|
|
aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
|
2013-10-26 07:03:06 +00:00
|
|
|
aCaller->OnModify();
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
2013-10-26 07:03:06 +00:00
|
|
|
|
|
|
|
return success;
|
2013-10-24 16:44:38 +00:00
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
|
|
|
|
{
|
2014-11-02 16:25:04 +00:00
|
|
|
wxASSERT( aModule );
|
|
|
|
|
2016-10-08 01:10:51 +00:00
|
|
|
DIALOG_DXF_IMPORT dlg( aCaller, true );
|
2014-07-09 13:02:56 +00:00
|
|
|
bool success = ( dlg.ShowModal() == wxID_OK );
|
|
|
|
|
|
|
|
if( success )
|
|
|
|
{
|
|
|
|
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
|
|
|
|
|
2016-05-25 09:52:43 +00:00
|
|
|
aCaller->SaveCopyInUndoList( aModule, UR_CHANGED );
|
2014-07-09 13:02:56 +00:00
|
|
|
aCaller->OnModify();
|
|
|
|
|
|
|
|
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
|
2015-08-27 18:10:28 +00:00
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
|
|
|
|
{
|
2016-10-08 01:10:51 +00:00
|
|
|
aModule->Add( *it );
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
2015-08-27 18:10:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DXF_IMPORT::OriginOptionOnUpdateUI( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
bool enable = m_rbOffsetOption->GetSelection() == 4;
|
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
m_DxfPcbPositionUnits->Enable( enable );
|
|
|
|
m_DxfPcbXCoord->Enable( enable );
|
|
|
|
m_DxfPcbYCoord->Enable( enable );
|
2015-08-27 18:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
void DIALOG_DXF_IMPORT::getPcbImportOffsets()
|
2015-08-27 18:10:28 +00:00
|
|
|
{
|
2017-11-04 20:34:17 +00:00
|
|
|
m_PcbImportOffsetX = DoubleValueFromString( UNSCALED_UNITS, m_DxfPcbXCoord->GetValue() );
|
|
|
|
m_PcbImportOffsetY = DoubleValueFromString( UNSCALED_UNITS, m_DxfPcbYCoord->GetValue() );
|
2015-08-27 18:10:28 +00:00
|
|
|
|
2017-11-04 20:34:17 +00:00
|
|
|
if( m_PcbImportUnits ) // Units are inches
|
|
|
|
{
|
|
|
|
m_PcbImportOffsetX *= 25.4;
|
|
|
|
m_PcbImportOffsetY *= 25.4;
|
|
|
|
}
|
2016-10-08 01:10:51 +00:00
|
|
|
|
2015-08-27 18:10:28 +00:00
|
|
|
return;
|
|
|
|
}
|