Pcbnew: fix import graphics dialog issues.
Improve padding, spacing and alignment of dialog layout.
Fix title capitalization.
Make file dialog wildcard string translatable.
Remove fixed initial dialog size to allow sizers to work their magic.
Replace OK button event handler with TransferDataFromWindow.
Remember last line width units between dialog instances and sessions.
Save configuration file settings in a separate group and remove GfxImport
prefix from the entry names.
Add fencing to dialog header file to prevent nested includes.
Fixes lp:1822568
https://bugs.launchpad.net/kicad/+bug/1822568
(cherry picked from commit d2cb0ca75f
)
This commit is contained in:
parent
b2e54a432b
commit
43aa94dcfc
|
@ -41,22 +41,28 @@
|
|||
#include <class_text_mod.h>
|
||||
#include <class_pcb_text.h>
|
||||
|
||||
// Keys to store setup in config
|
||||
#define IMPORT_GFX_LAYER_OPTION_KEY "GfxImportBrdLayer"
|
||||
#define IMPORT_GFX_PLACEMENT_INTERACTIVE_KEY "GfxImportPlacementInteractive"
|
||||
#define IMPORT_GFX_LAST_FILE_KEY "GfxImportLastFile"
|
||||
#define IMPORT_GFX_POSITION_UNITS_KEY "GfxImportPositionUnits"
|
||||
#define IMPORT_GFX_POSITION_X_KEY "GfxImportPositionX"
|
||||
#define IMPORT_GFX_POSITION_Y_KEY "GfxImportPositionY"
|
||||
#define IMPORT_GFX_LINEWIDTH_UNITS_KEY "GfxImportLineWidthUnits"
|
||||
#define IMPORT_GFX_LINEWIDTH_KEY "GfxImportLineWidth"
|
||||
// Configuration path (group) to store entry keys below.
|
||||
#define IMPORT_GFX_GROUP "ImportGraphics"
|
||||
|
||||
// Static members of DIALOG_IMPORT_GFX, to remember
|
||||
// the user's choices during the session
|
||||
// Entry keys to store setup in config
|
||||
#define IMPORT_GFX_LAYER_OPTION_KEY "BoardLayer"
|
||||
#define IMPORT_GFX_PLACEMENT_INTERACTIVE_KEY "InteractivePlacement"
|
||||
#define IMPORT_GFX_LAST_FILE_KEY "LastFile"
|
||||
#define IMPORT_GFX_POSITION_UNITS_KEY "PositionUnits"
|
||||
#define IMPORT_GFX_POSITION_X_KEY "PositionX"
|
||||
#define IMPORT_GFX_POSITION_Y_KEY "PositionY"
|
||||
#define IMPORT_GFX_LINEWIDTH_UNITS_KEY "LineWidthUnits"
|
||||
#define IMPORT_GFX_LINEWIDTH_KEY "LineWidth"
|
||||
|
||||
|
||||
// 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;
|
||||
LAYER_NUM 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_lineWidthUnits = 0; // millimeter
|
||||
|
||||
|
||||
DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFootprintGraphic )
|
||||
: DIALOG_IMPORT_GFX_BASE( aParent )
|
||||
|
@ -79,27 +85,31 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFoo
|
|||
}
|
||||
|
||||
m_config = Kiface().KifaceSettings();
|
||||
m_originImportUnits = 0;
|
||||
m_importOrigin.x = 0.0; // always in mm
|
||||
m_importOrigin.y = 0.0; // always in mm
|
||||
m_default_lineWidth = 0.2; // always in mm
|
||||
m_lineWidthImportUnits = 0;
|
||||
m_originUnits = 0;
|
||||
m_origin.x = 0.0; // always in mm
|
||||
m_origin.y = 0.0; // always in mm
|
||||
m_lineWidth = 0.2; // always in mm
|
||||
m_lineWidthUnits = 0;
|
||||
|
||||
if( m_config )
|
||||
{
|
||||
wxString tmp = m_config->GetPath();
|
||||
m_config->SetPath( IMPORT_GFX_GROUP );
|
||||
m_layer = m_config->Read( IMPORT_GFX_LAYER_OPTION_KEY, (long)Dwgs_User );
|
||||
m_placementInteractive = m_config->Read( IMPORT_GFX_PLACEMENT_INTERACTIVE_KEY, true );
|
||||
m_filename = m_config->Read( IMPORT_GFX_LAST_FILE_KEY, wxEmptyString );
|
||||
m_config->Read( IMPORT_GFX_LINEWIDTH_KEY, &m_default_lineWidth, 0.2 );
|
||||
m_config->Read( IMPORT_GFX_POSITION_UNITS_KEY, &m_originImportUnits, 0 );
|
||||
m_config->Read( IMPORT_GFX_POSITION_X_KEY, &m_importOrigin.x, 0.0 );
|
||||
m_config->Read( IMPORT_GFX_POSITION_Y_KEY, &m_importOrigin.y, 0.0 );
|
||||
m_config->Read( IMPORT_GFX_LINEWIDTH_KEY, &m_lineWidth, 0.2 );
|
||||
m_config->Read( IMPORT_GFX_LINEWIDTH_UNITS_KEY, &m_lineWidthUnits, 0 );
|
||||
m_config->Read( IMPORT_GFX_POSITION_UNITS_KEY, &m_originUnits, 0 );
|
||||
m_config->Read( IMPORT_GFX_POSITION_X_KEY, &m_origin.x, 0.0 );
|
||||
m_config->Read( IMPORT_GFX_POSITION_Y_KEY, &m_origin.y, 0.0 );
|
||||
m_config->SetPath( tmp );
|
||||
}
|
||||
|
||||
m_choiceUnitLineWidth->SetSelection( m_lineWidthImportUnits );
|
||||
m_choiceUnitLineWidth->SetSelection( m_lineWidthUnits );
|
||||
showPCBdefaultLineWidth();
|
||||
|
||||
m_DxfPcbPositionUnits->SetSelection( m_originImportUnits );
|
||||
m_DxfPcbPositionUnits->SetSelection( m_originUnits );
|
||||
showPcbImportOffsets();
|
||||
|
||||
m_textCtrlFileName->SetValue( m_filename );
|
||||
|
@ -120,6 +130,7 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFoo
|
|||
m_SelLayerBox->SetLayerSelection( m_layer );
|
||||
}
|
||||
|
||||
SetInitialFocus( m_textCtrlFileName );
|
||||
m_sdbSizerOK->SetDefault();
|
||||
GetSizer()->Fit( this );
|
||||
GetSizer()->SetSizeHints( this );
|
||||
|
@ -129,22 +140,21 @@ DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aImportAsFoo
|
|||
|
||||
DIALOG_IMPORT_GFX::~DIALOG_IMPORT_GFX()
|
||||
{
|
||||
updatePcbImportOffsets_mm();
|
||||
m_layer = m_SelLayerBox->GetLayerSelection();
|
||||
|
||||
if( m_config )
|
||||
{
|
||||
wxString tmp = m_config->GetPath();
|
||||
m_config->SetPath( IMPORT_GFX_GROUP );
|
||||
m_config->Write( IMPORT_GFX_LAYER_OPTION_KEY, (long)m_layer );
|
||||
m_config->Write( IMPORT_GFX_PLACEMENT_INTERACTIVE_KEY, m_placementInteractive );
|
||||
m_config->Write( IMPORT_GFX_LAST_FILE_KEY, m_filename );
|
||||
|
||||
m_config->Write( IMPORT_GFX_POSITION_UNITS_KEY, m_originImportUnits );
|
||||
m_config->Write( IMPORT_GFX_POSITION_X_KEY, m_importOrigin.x );
|
||||
m_config->Write( IMPORT_GFX_POSITION_Y_KEY, m_importOrigin.y );
|
||||
m_config->Write( IMPORT_GFX_POSITION_UNITS_KEY, m_originUnits );
|
||||
m_config->Write( IMPORT_GFX_POSITION_X_KEY, m_origin.x );
|
||||
m_config->Write( IMPORT_GFX_POSITION_Y_KEY, m_origin.y );
|
||||
|
||||
m_lineWidthImportUnits = getPCBdefaultLineWidthMM();
|
||||
m_config->Write( IMPORT_GFX_LINEWIDTH_KEY, m_default_lineWidth );
|
||||
m_config->Write( IMPORT_GFX_LINEWIDTH_UNITS_KEY, m_lineWidthImportUnits );
|
||||
m_config->Write( IMPORT_GFX_LINEWIDTH_KEY, m_lineWidth );
|
||||
m_config->Write( IMPORT_GFX_LINEWIDTH_UNITS_KEY, m_lineWidthUnits );
|
||||
m_config->SetPath( tmp );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +164,7 @@ void DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX::onUnitPositionSelection( wxCommandEve
|
|||
// Collect last entered values:
|
||||
updatePcbImportOffsets_mm();
|
||||
|
||||
m_originImportUnits = m_DxfPcbPositionUnits->GetSelection();;
|
||||
m_originUnits = m_DxfPcbPositionUnits->GetSelection();;
|
||||
showPcbImportOffsets();
|
||||
}
|
||||
|
||||
|
@ -163,7 +173,7 @@ double DIALOG_IMPORT_GFX::getPCBdefaultLineWidthMM()
|
|||
{
|
||||
double value = DoubleValueFromString( UNSCALED_UNITS, m_textCtrlLineWidth->GetValue() );
|
||||
|
||||
switch( m_lineWidthImportUnits )
|
||||
switch( m_lineWidthUnits )
|
||||
{
|
||||
default:
|
||||
case 0: // display units = mm
|
||||
|
@ -184,21 +194,21 @@ double DIALOG_IMPORT_GFX::getPCBdefaultLineWidthMM()
|
|||
|
||||
void DIALOG_IMPORT_GFX::onUnitWidthSelection( wxCommandEvent& event )
|
||||
{
|
||||
m_default_lineWidth = getPCBdefaultLineWidthMM();
|
||||
m_lineWidth = getPCBdefaultLineWidthMM();
|
||||
|
||||
// Switch to new units
|
||||
m_lineWidthImportUnits = m_choiceUnitLineWidth->GetSelection();
|
||||
m_lineWidthUnits = m_choiceUnitLineWidth->GetSelection();
|
||||
showPCBdefaultLineWidth();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMPORT_GFX::showPcbImportOffsets()
|
||||
{
|
||||
// Display m_importOrigin value according to the unit selection:
|
||||
VECTOR2D offset = m_importOrigin;
|
||||
// Display m_origin value according to the unit selection:
|
||||
VECTOR2D offset = m_origin;
|
||||
|
||||
if( m_originImportUnits ) // Units are inches
|
||||
offset = m_importOrigin / 25.4;
|
||||
if( m_originUnits ) // Units are inches
|
||||
offset = m_origin / 25.4;
|
||||
|
||||
m_DxfPcbXCoord->SetValue( wxString::Format( "%f", offset.x ) );
|
||||
m_DxfPcbYCoord->SetValue( wxString::Format( "%f", offset.y ) );
|
||||
|
@ -210,19 +220,19 @@ void DIALOG_IMPORT_GFX::showPCBdefaultLineWidth()
|
|||
{
|
||||
double value;
|
||||
|
||||
switch( m_lineWidthImportUnits )
|
||||
switch( m_lineWidthUnits )
|
||||
{
|
||||
default:
|
||||
case 0: // display units = mm
|
||||
value = m_default_lineWidth;
|
||||
value = m_lineWidth;
|
||||
break;
|
||||
|
||||
case 1: // display units = mil
|
||||
value = m_default_lineWidth / 25.4 * 1000;
|
||||
value = m_lineWidth / 25.4 * 1000;
|
||||
break;
|
||||
|
||||
case 2: // display units = inch
|
||||
value = m_default_lineWidth / 25.4;
|
||||
value = m_lineWidth / 25.4;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -255,7 +265,7 @@ void DIALOG_IMPORT_GFX::onBrowseFiles( wxCommandEvent& event )
|
|||
allWildcards += wildcards + ";";
|
||||
}
|
||||
|
||||
wildcardsDesc = "All supported formats|" + allWildcards + wildcardsDesc;
|
||||
wildcardsDesc = _( "All supported formats|" ) + allWildcards + wildcardsDesc;
|
||||
|
||||
wxFileDialog dlg( m_parent, _( "Open File" ), path, filename,
|
||||
wildcardsDesc, wxFD_OPEN|wxFD_FILE_MUST_EXIST );
|
||||
|
@ -273,28 +283,34 @@ void DIALOG_IMPORT_GFX::onBrowseFiles( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_IMPORT_GFX::onOKClick( wxCommandEvent& event )
|
||||
bool DIALOG_IMPORT_GFX::TransferDataFromWindow()
|
||||
{
|
||||
if( !wxDialog::TransferDataFromWindow() )
|
||||
return false;
|
||||
|
||||
m_filename = m_textCtrlFileName->GetValue();
|
||||
|
||||
if( m_filename.IsEmpty() )
|
||||
{
|
||||
wxMessageBox( _( "Error: No DXF filename!" ) );
|
||||
return;
|
||||
wxMessageBox( _( "No file selected!" ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
updatePcbImportOffsets_mm(); // Update m_importOriginX and m_importOriginY;
|
||||
m_originUnits = m_DxfPcbPositionUnits->GetSelection();
|
||||
updatePcbImportOffsets_mm(); // Update m_originX and m_originY;
|
||||
|
||||
m_layer = m_SelLayerBox->GetLayerSelection();
|
||||
|
||||
if( m_layer < 0 )
|
||||
{
|
||||
wxMessageBox( _( "Please, select a valid layer" ) );
|
||||
return;
|
||||
wxMessageBox( _( "Please select a valid layer." ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_default_lineWidth = getPCBdefaultLineWidthMM();
|
||||
m_lineWidthUnits = m_choiceUnitLineWidth->GetSelection();
|
||||
m_lineWidth = getPCBdefaultLineWidthMM();
|
||||
|
||||
wxLogDebug( "Default line width = %fmm", m_lineWidth );
|
||||
m_importer->SetLayer( PCB_LAYER_ID( m_layer ) );
|
||||
|
||||
auto plugin = m_gfxImportMgr->GetPluginByExt( wxFileName( m_filename ).GetExt() );
|
||||
|
@ -302,10 +318,10 @@ void DIALOG_IMPORT_GFX::onOKClick( wxCommandEvent& event )
|
|||
if( plugin )
|
||||
{
|
||||
// Set coordinates offset for import (offset is given in mm)
|
||||
m_importer->SetImportOffsetMM( m_importOrigin );
|
||||
m_importer->SetImportOffsetMM( m_origin );
|
||||
m_scaleImport = DoubleValueFromString( UNSCALED_UNITS, m_textCtrlImportScale->GetValue() );
|
||||
|
||||
m_importer->SetLineWidthMM( m_default_lineWidth );
|
||||
m_importer->SetLineWidthMM( m_lineWidth );
|
||||
m_importer->SetPlugin( std::move( plugin ) );
|
||||
|
||||
LOCALE_IO dummy; // Ensure floats can be read.
|
||||
|
@ -316,15 +332,45 @@ void DIALOG_IMPORT_GFX::onOKClick( wxCommandEvent& event )
|
|||
// Get warning messages:
|
||||
const std::string& warnings = m_importer->GetMessages();
|
||||
|
||||
// This isn't a fatal error so allow the dialog to close with wxID_OK.
|
||||
if( !warnings.empty() )
|
||||
wxMessageBox( warnings.c_str(), _( "Not Handled Items" ) );
|
||||
|
||||
event.Skip();
|
||||
wxMessageBox( warnings.c_str(), _( "Items Not Handled" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxMessageBox( _( "There is no plugin to handle this file type" ) );
|
||||
wxMessageBox( _( "There is no plugin to handle this file type." ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMPORT_GFX::originOptionOnUpdateUI( wxUpdateUIEvent& event )
|
||||
{
|
||||
if( m_rbInteractivePlacement->GetValue() != m_placementInteractive )
|
||||
m_rbInteractivePlacement->SetValue( m_placementInteractive );
|
||||
|
||||
if( m_rbAbsolutePlacement->GetValue() == m_placementInteractive )
|
||||
m_rbAbsolutePlacement->SetValue( not 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( UNSCALED_UNITS, m_DxfPcbXCoord->GetValue() );
|
||||
m_origin.y = DoubleValueFromString( UNSCALED_UNITS, m_DxfPcbYCoord->GetValue() );
|
||||
|
||||
if( m_originUnits ) // Units are inches
|
||||
{
|
||||
m_origin = m_origin * 25.4;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -341,7 +387,7 @@ bool InvokeDialogImportGfxBoard( PCB_BASE_FRAME* aCaller )
|
|||
// Ensure the list is not empty:
|
||||
if( list.empty() )
|
||||
{
|
||||
wxMessageBox( _( "No graphic items found in file to import") );
|
||||
wxMessageBox( _( "No graphic items found in file to import." ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -356,7 +402,7 @@ bool InvokeDialogImportGfxBoard( PCB_BASE_FRAME* aCaller )
|
|||
BLOCK_SELECTOR& blockmove = aCaller->GetScreen()->m_BlockLocate;
|
||||
|
||||
if( dlg.IsPlacementInteractive() )
|
||||
aCaller->HandleBlockBegin( NULL, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0) );
|
||||
aCaller->HandleBlockBegin( NULL, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0 ) );
|
||||
|
||||
PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems();
|
||||
|
||||
|
@ -418,7 +464,7 @@ bool InvokeDialogImportGfxModule( PCB_BASE_FRAME* aCaller, MODULE* aModule )
|
|||
// Ensure the list is not empty:
|
||||
if( list.empty() )
|
||||
{
|
||||
wxMessageBox( _( "No graphic items found in file to import") );
|
||||
wxMessageBox( _( "No graphic items found in file to import" ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -434,7 +480,7 @@ bool InvokeDialogImportGfxModule( PCB_BASE_FRAME* aCaller, MODULE* aModule )
|
|||
BLOCK_SELECTOR& blockmove = aCaller->GetScreen()->m_BlockLocate;
|
||||
|
||||
if( dlg.IsPlacementInteractive() )
|
||||
aCaller->HandleBlockBegin( nullptr, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0) );
|
||||
aCaller->HandleBlockBegin( nullptr, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0 ) );
|
||||
|
||||
PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems();
|
||||
|
||||
|
@ -472,31 +518,3 @@ bool InvokeDialogImportGfxModule( PCB_BASE_FRAME* aCaller, MODULE* aModule )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_IMPORT_GFX::originOptionOnUpdateUI( wxUpdateUIEvent& event )
|
||||
{
|
||||
if( m_rbInteractivePlacement->GetValue() != m_placementInteractive )
|
||||
m_rbInteractivePlacement->SetValue( m_placementInteractive );
|
||||
|
||||
if( m_rbAbsolutePlacement->GetValue() == m_placementInteractive )
|
||||
m_rbAbsolutePlacement->SetValue( not 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_importOrigin.x = DoubleValueFromString( UNSCALED_UNITS, m_DxfPcbXCoord->GetValue() );
|
||||
m_importOrigin.y = DoubleValueFromString( UNSCALED_UNITS, m_DxfPcbYCoord->GetValue() );
|
||||
|
||||
if( m_originImportUnits ) // Units are inches
|
||||
{
|
||||
m_importOrigin = m_importOrigin * 25.4;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 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
|
||||
|
@ -22,6 +22,9 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __DIALOG_IMPORT_GFX_H__
|
||||
#define __DIALOG_IMPORT_GFX_H__
|
||||
|
||||
#include <pcb_edit_frame.h>
|
||||
#include "dialog_import_gfx_base.h"
|
||||
#include <import_gfx/graphics_importer_pcbnew.h>
|
||||
|
@ -34,9 +37,7 @@ public:
|
|||
DIALOG_IMPORT_GFX( PCB_BASE_FRAME* aParent, bool aUseModuleItems = false );
|
||||
~DIALOG_IMPORT_GFX();
|
||||
|
||||
|
||||
/**
|
||||
* Function GetImportedItems()
|
||||
* @return a list of items imported from a vector graphics file.
|
||||
*/
|
||||
std::list<std::unique_ptr<EDA_ITEM>>& GetImportedItems()
|
||||
|
@ -44,7 +45,8 @@ public:
|
|||
return m_importer->GetItems();
|
||||
}
|
||||
|
||||
/** @return true if the placement is interactive, i.e. all imported
|
||||
/**
|
||||
* @return true if the placement is interactive, i.e. all imported
|
||||
* 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.
|
||||
*/
|
||||
|
@ -53,33 +55,37 @@ public:
|
|||
return m_placementInteractive;
|
||||
}
|
||||
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
private:
|
||||
PCB_BASE_FRAME* m_parent;
|
||||
wxConfigBase* m_config; // Current config
|
||||
std::unique_ptr<GRAPHICS_IMPORTER_PCBNEW> m_importer;
|
||||
std::unique_ptr<GRAPHICS_IMPORT_MGR> m_gfxImportMgr;
|
||||
int m_originImportUnits;
|
||||
VECTOR2D m_importOrigin; // This is the offset to add to imported coordinates
|
||||
static int m_originUnits;
|
||||
VECTOR2D m_origin; // This is the offset to add to imported coordinates
|
||||
// Always in mm
|
||||
|
||||
static wxString m_filename;
|
||||
static bool m_placementInteractive;
|
||||
static LAYER_NUM m_layer;
|
||||
double m_default_lineWidth; // always in mm: line width when a line width is not specified
|
||||
int m_lineWidthImportUnits;
|
||||
static double m_scaleImport; // a scale factor to change the size of imported items
|
||||
// m_scaleImport =1.0 means keep original size
|
||||
double m_lineWidth; // always in mm: line width when a line width
|
||||
// is not specified
|
||||
static int m_lineWidthUnits;
|
||||
static double m_scaleImport; // a scale factor to change the size of imported
|
||||
// items m_scaleImport =1.0 means keep original size
|
||||
|
||||
// Virtual event handlers
|
||||
void onOKClick( wxCommandEvent& event ) override;
|
||||
void onUnitPositionSelection( wxCommandEvent& event ) override;
|
||||
void onUnitWidthSelection( wxCommandEvent& event ) override;
|
||||
void onBrowseFiles( wxCommandEvent& event ) override;
|
||||
void originOptionOnUpdateUI( wxUpdateUIEvent& event ) override;
|
||||
|
||||
void onInteractivePlacement( wxCommandEvent& event ) override
|
||||
{
|
||||
m_placementInteractive = true;
|
||||
}
|
||||
|
||||
void onAbsolutePlacement( wxCommandEvent& event ) override
|
||||
{
|
||||
m_placementInteractive = false;
|
||||
|
@ -90,3 +96,5 @@ private:
|
|||
void showPCBdefaultLineWidth();
|
||||
void showPcbImportOffsets();
|
||||
};
|
||||
|
||||
#endif // __DIALOG_IMPORT_GFX_H__
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 23 2018)
|
||||
// C++ code generated with wxFormBuilder (version Mar 20 2019)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -23,15 +23,15 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
|
||||
m_staticTextFile = new wxStaticText( this, wxID_ANY, _("File:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextFile->Wrap( -1 );
|
||||
bSizerFile->Add( m_staticTextFile, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
bSizerFile->Add( m_staticTextFile, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
m_textCtrlFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_textCtrlFileName->SetMinSize( wxSize( 300,-1 ) );
|
||||
|
||||
bSizerFile->Add( m_textCtrlFileName, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 );
|
||||
bSizerFile->Add( m_textCtrlFileName, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerFile->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 );
|
||||
bSizerFile->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( bSizerFile, 0, wxALL|wxEXPAND, 5 );
|
||||
|
@ -46,27 +46,27 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
m_staticTextPlacement->Wrap( -1 );
|
||||
m_staticTextPlacement->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
|
||||
bSizerPlacement->Add( m_staticTextPlacement, 0, wxALL, 5 );
|
||||
bSizerPlacement->Add( m_staticTextPlacement, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
wxBoxSizer* bSizerOptions;
|
||||
bSizerOptions = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_rbInteractivePlacement = new wxRadioButton( this, wxID_ANY, _("Interactive placement"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
||||
m_rbInteractivePlacement = new wxRadioButton( this, wxID_ANY, _("Interactive placement"), wxDefaultPosition, wxDefaultSize, wxRB_SINGLE );
|
||||
m_rbInteractivePlacement->SetValue( true );
|
||||
bSizerOptions->Add( m_rbInteractivePlacement, 0, wxALL, 5 );
|
||||
bSizerOptions->Add( m_rbInteractivePlacement, 0, wxBOTTOM|wxEXPAND|wxTOP, 5 );
|
||||
|
||||
wxBoxSizer* bSizerUserPos;
|
||||
bSizerUserPos = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_rbAbsolutePlacement = new wxRadioButton( this, wxID_ANY, _("At"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerUserPos->Add( m_rbAbsolutePlacement, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
m_rbAbsolutePlacement = new wxRadioButton( this, wxID_ANY, _("At"), wxDefaultPosition, wxDefaultSize, wxRB_SINGLE );
|
||||
bSizerUserPos->Add( m_rbAbsolutePlacement, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
wxBoxSizer* bSizerPosSettings;
|
||||
bSizerPosSettings = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_staticTextXpos = new wxStaticText( this, wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextXpos->Wrap( -1 );
|
||||
bSizerPosSettings->Add( m_staticTextXpos, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
|
||||
bSizerPosSettings->Add( m_staticTextXpos, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
m_DxfPcbXCoord = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
#ifdef __WXGTK__
|
||||
|
@ -79,11 +79,11 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
#endif
|
||||
m_DxfPcbXCoord->SetToolTip( _("DXF origin on PCB Grid, X Coordinate") );
|
||||
|
||||
bSizerPosSettings->Add( m_DxfPcbXCoord, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
bSizerPosSettings->Add( m_DxfPcbXCoord, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
m_staticTextYpos = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextYpos->Wrap( -1 );
|
||||
bSizerPosSettings->Add( m_staticTextYpos, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
|
||||
bSizerPosSettings->Add( m_staticTextYpos, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
m_DxfPcbYCoord = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
#ifdef __WXGTK__
|
||||
|
@ -96,11 +96,11 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
#endif
|
||||
m_DxfPcbYCoord->SetToolTip( _("DXF origin on PCB Grid, Y Coordinate") );
|
||||
|
||||
bSizerPosSettings->Add( m_DxfPcbYCoord, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
bSizerPosSettings->Add( m_DxfPcbYCoord, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
m_staticTextUnits = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextUnits->Wrap( -1 );
|
||||
bSizerPosSettings->Add( m_staticTextUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
bSizerPosSettings->Add( m_staticTextUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
wxString m_DxfPcbPositionUnitsChoices[] = { _("mm"), _("inch") };
|
||||
int m_DxfPcbPositionUnitsNChoices = sizeof( m_DxfPcbPositionUnitsChoices ) / sizeof( wxString );
|
||||
|
@ -108,10 +108,10 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
m_DxfPcbPositionUnits->SetSelection( 0 );
|
||||
m_DxfPcbPositionUnits->SetToolTip( _("Select PCB grid units") );
|
||||
|
||||
bSizerPosSettings->Add( m_DxfPcbPositionUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
|
||||
bSizerPosSettings->Add( m_DxfPcbPositionUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
|
||||
bSizerUserPos->Add( bSizerPosSettings, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
|
||||
bSizerUserPos->Add( bSizerPosSettings, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxTOP, 5 );
|
||||
|
||||
|
||||
bSizerOptions->Add( bSizerUserPos, 0, wxEXPAND, 5 );
|
||||
|
@ -132,7 +132,7 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
m_staticTextPrms->Wrap( -1 );
|
||||
m_staticTextPrms->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
|
||||
bSizerLayer->Add( m_staticTextPrms, 0, wxALL, 5 );
|
||||
bSizerLayer->Add( m_staticTextPrms, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer7;
|
||||
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
@ -141,58 +141,58 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
bSizer7->Add( 0, 0, 0, wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
wxFlexGridSizer* fgSizerImportSettings;
|
||||
fgSizerImportSettings = new wxFlexGridSizer( 0, 3, 0, 0 );
|
||||
fgSizerImportSettings = new wxFlexGridSizer( 0, 3, 5, 5 );
|
||||
fgSizerImportSettings->AddGrowableCol( 1 );
|
||||
fgSizerImportSettings->SetFlexibleDirection( wxBOTH );
|
||||
fgSizerImportSettings->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_staticTextLineWidth = new wxStaticText( this, wxID_ANY, _("Line width (DXF import):"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextLineWidth->Wrap( -1 );
|
||||
fgSizerImportSettings->Add( m_staticTextLineWidth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
fgSizerImportSettings->Add( m_staticTextLineWidth, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_textCtrlLineWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizerImportSettings->Add( m_textCtrlLineWidth, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
fgSizerImportSettings->Add( m_textCtrlLineWidth, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
wxString m_choiceUnitLineWidthChoices[] = { _("mm"), _("mils"), _("inches") };
|
||||
int m_choiceUnitLineWidthNChoices = sizeof( m_choiceUnitLineWidthChoices ) / sizeof( wxString );
|
||||
m_choiceUnitLineWidth = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceUnitLineWidthNChoices, m_choiceUnitLineWidthChoices, 0 );
|
||||
m_choiceUnitLineWidth->SetSelection( 0 );
|
||||
fgSizerImportSettings->Add( m_choiceUnitLineWidth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
fgSizerImportSettings->Add( m_choiceUnitLineWidth, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_staticTextBrdlayer = new wxStaticText( this, wxID_ANY, _("Graphic layer:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextBrdlayer->Wrap( -1 );
|
||||
fgSizerImportSettings->Add( m_staticTextBrdlayer, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxTOP, 5 );
|
||||
fgSizerImportSettings->Add( m_staticTextBrdlayer, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
||||
fgSizerImportSettings->Add( m_SelLayerBox, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
|
||||
fgSizerImportSettings->Add( m_SelLayerBox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
fgSizerImportSettings->Add( 0, 0, 0, 0, 5 );
|
||||
|
||||
m_staticTextscale = new wxStaticText( this, wxID_ANY, _("Import scale:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextscale->Wrap( -1 );
|
||||
fgSizerImportSettings->Add( m_staticTextscale, 0, wxALL, 5 );
|
||||
fgSizerImportSettings->Add( m_staticTextscale, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_textCtrlImportScale = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizerImportSettings->Add( m_textCtrlImportScale, 0, wxALL|wxEXPAND, 5 );
|
||||
fgSizerImportSettings->Add( m_textCtrlImportScale, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
fgSizerImportSettings->Add( 0, 0, 0, 0, 5 );
|
||||
|
||||
|
||||
bSizer7->Add( fgSizerImportSettings, 1, wxEXPAND, 5 );
|
||||
bSizer7->Add( fgSizerImportSettings, 1, wxEXPAND|wxRIGHT|wxTOP, 5 );
|
||||
|
||||
|
||||
bSizerLayer->Add( bSizer7, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( bSizerLayer, 0, wxALL|wxEXPAND, 5 );
|
||||
bSizerMain->Add( bSizerLayer, 0, wxBOTTOM|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
bSizerMain->Add( 0, 0, 0, wxEXPAND, 5 );
|
||||
|
||||
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
bSizerMain->Add( m_staticline, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
|
||||
bSizerMain->Add( m_staticline, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_sdbSizer = new wxStdDialogButtonSizer();
|
||||
m_sdbSizerOK = new wxButton( this, wxID_OK );
|
||||
|
@ -206,6 +206,7 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
|
||||
this->SetSizer( bSizerMain );
|
||||
this->Layout();
|
||||
bSizerMain->Fit( this );
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
|
@ -217,7 +218,6 @@ DIALOG_IMPORT_GFX_BASE::DIALOG_IMPORT_GFX_BASE( wxWindow* parent, wxWindowID id,
|
|||
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_choiceUnitLineWidth->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onUnitWidthSelection ), NULL, this );
|
||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onOKClick ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_IMPORT_GFX_BASE::~DIALOG_IMPORT_GFX_BASE()
|
||||
|
@ -230,6 +230,5 @@ DIALOG_IMPORT_GFX_BASE::~DIALOG_IMPORT_GFX_BASE()
|
|||
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_choiceUnitLineWidth->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onUnitWidthSelection ), NULL, this );
|
||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_GFX_BASE::onOKClick ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 23 2018)
|
||||
// C++ code generated with wxFormBuilder (version Mar 20 2019)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -77,12 +77,11 @@ class DIALOG_IMPORT_GFX_BASE : public DIALOG_SHIM
|
|||
virtual void onAbsolutePlacement( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onUnitPositionSelection( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onUnitWidthSelection( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onOKClick( 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( 500,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
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();
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue