Pcbnew: restore automatic calculation of reference position when exporting to IDF.
This commit is contained in:
parent
adca4d55f0
commit
33a9f7ecc8
|
@ -29,11 +29,13 @@
|
|||
#include <kiface_i.h>
|
||||
#include <pcbnew.h>
|
||||
#include <class_board.h>
|
||||
#include <convert_from_iu.h>
|
||||
|
||||
// IDF export header generated by wxFormBuilder
|
||||
#include <dialog_export_idf_base.h>
|
||||
|
||||
#define OPTKEY_IDF_THOU wxT( "IDFExportThou" )
|
||||
#define OPTKEY_IDF_REF_AUTOADJ wxT( "IDFRefAutoAdj" )
|
||||
#define OPTKEY_IDF_REF_UNITS wxT( "IDFRefUnits" )
|
||||
#define OPTKEY_IDF_REF_X wxT( "IDFRefX" )
|
||||
#define OPTKEY_IDF_REF_Y wxT( "IDFRefY" )
|
||||
|
@ -60,6 +62,7 @@ private:
|
|||
PCB_EDIT_FRAME* m_parent;
|
||||
wxConfigBase* m_config;
|
||||
bool m_idfThouOpt; // remember last preference for units in THOU
|
||||
bool m_AutoAdjust; // remember last Reference Point AutoAdjust setting
|
||||
int m_RefUnits; // remember last units for Reference Point
|
||||
double m_XRef; // remember last X Reference Point
|
||||
double m_YRef; // remember last Y Reference Point
|
||||
|
@ -74,10 +77,14 @@ public:
|
|||
m_idfThouOpt = false;
|
||||
m_config->Read( OPTKEY_IDF_THOU, &m_idfThouOpt );
|
||||
m_rbUnitSelection->SetSelection( m_idfThouOpt ? 1 : 0 );
|
||||
m_config->Read( OPTKEY_IDF_REF_AUTOADJ, &m_AutoAdjust, false );
|
||||
m_config->Read( OPTKEY_IDF_REF_UNITS, &m_RefUnits, 0 );
|
||||
m_config->Read( OPTKEY_IDF_REF_X, &m_XRef, 0.0 );
|
||||
m_config->Read( OPTKEY_IDF_REF_Y, &m_YRef, 0.0 );
|
||||
|
||||
m_cbAutoAdjustOffset->SetValue( m_AutoAdjust );
|
||||
m_cbAutoAdjustOffset->Bind( wxEVT_CHECKBOX, &DIALOG_EXPORT_IDF3::OnAutoAdjustOffset, this );
|
||||
|
||||
m_IDF_RefUnitChoice->SetSelection( m_RefUnits );
|
||||
wxString tmpStr;
|
||||
tmpStr << m_XRef;
|
||||
|
@ -86,6 +93,19 @@ public:
|
|||
tmpStr << m_YRef;
|
||||
m_IDF_Yref->SetValue( tmpStr );
|
||||
|
||||
if( m_AutoAdjust )
|
||||
{
|
||||
m_IDF_RefUnitChoice->Enable( false );
|
||||
m_IDF_Xref->Enable( false );
|
||||
m_IDF_Yref->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IDF_RefUnitChoice->Enable( true );
|
||||
m_IDF_Xref->Enable( true );
|
||||
m_IDF_Yref->Enable( true );
|
||||
}
|
||||
|
||||
wxWindow* button = FindWindowByLabel( wxT( "OK" ) );
|
||||
|
||||
if( button )
|
||||
|
@ -99,6 +119,7 @@ public:
|
|||
{
|
||||
m_idfThouOpt = m_rbUnitSelection->GetSelection() == 1;
|
||||
m_config->Write( OPTKEY_IDF_THOU, m_idfThouOpt );
|
||||
m_config->Write( OPTKEY_IDF_REF_AUTOADJ, GetAutoAdjustOffset() );
|
||||
m_config->Write( OPTKEY_IDF_REF_UNITS, m_IDF_RefUnitChoice->GetSelection() );
|
||||
m_config->Write( OPTKEY_IDF_REF_X, m_IDF_Xref->GetValue() );
|
||||
m_config->Write( OPTKEY_IDF_REF_Y, m_IDF_Yref->GetValue() );
|
||||
|
@ -129,6 +150,29 @@ public:
|
|||
return DoubleValueFromString( UNSCALED_UNITS, m_IDF_Yref->GetValue() );
|
||||
}
|
||||
|
||||
bool GetAutoAdjustOffset()
|
||||
{
|
||||
return m_cbAutoAdjustOffset->GetValue();
|
||||
}
|
||||
|
||||
void OnAutoAdjustOffset( wxCommandEvent& event )
|
||||
{
|
||||
if( GetAutoAdjustOffset() )
|
||||
{
|
||||
m_IDF_RefUnitChoice->Enable( false );
|
||||
m_IDF_Xref->Enable( false );
|
||||
m_IDF_Yref->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IDF_RefUnitChoice->Enable( true );
|
||||
m_IDF_Xref->Enable( true );
|
||||
m_IDF_Yref->Enable( true );
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -151,8 +195,20 @@ void PCB_EDIT_FRAME::ExportToIDF3( wxCommandEvent& event )
|
|||
return;
|
||||
|
||||
bool thou = dlg.GetThouOption();
|
||||
double aXRef = dlg.GetXRef();
|
||||
double aYRef = dlg.GetYRef();
|
||||
double aXRef;
|
||||
double aYRef;
|
||||
|
||||
if( dlg.GetAutoAdjustOffset() )
|
||||
{
|
||||
EDA_RECT bbox = GetBoard()->ComputeBoundingBox( true );
|
||||
|
||||
aXRef = bbox.Centre().x * MM_PER_IU;
|
||||
aYRef = bbox.Centre().y * MM_PER_IU;
|
||||
}
|
||||
else
|
||||
{
|
||||
aXRef = dlg.GetXRef();
|
||||
aYRef = dlg.GetYRef();
|
||||
|
||||
if( dlg.GetRefUnitsChoice() == 1 )
|
||||
{
|
||||
|
@ -161,6 +217,8 @@ void PCB_EDIT_FRAME::ExportToIDF3( wxCommandEvent& event )
|
|||
aYRef *= 25.4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wxBusyCursor dummy;
|
||||
|
||||
wxString fullFilename = dlg.FilePicker()->GetPath();
|
||||
|
|
|
@ -33,6 +33,9 @@ DIALOG_EXPORT_IDF3_BASE::DIALOG_EXPORT_IDF3_BASE( wxWindow* parent, wxWindowID i
|
|||
m_staticText2->Wrap( -1 );
|
||||
bSizer3->Add( m_staticText2, 0, wxALL, 5 );
|
||||
|
||||
m_cbAutoAdjustOffset = new wxCheckBox( this, wxID_ANY, _("Auto Adjust"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
||||
bSizer3->Add( m_cbAutoAdjustOffset, 0, wxALL, 5 );
|
||||
|
||||
wxBoxSizer* bSizer6;
|
||||
bSizer6 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
|
@ -83,7 +86,7 @@ DIALOG_EXPORT_IDF3_BASE::DIALOG_EXPORT_IDF3_BASE( wxWindow* parent, wxWindowID i
|
|||
wxString m_rbUnitSelectionChoices[] = { _("Millimeters"), _("Mils") };
|
||||
int m_rbUnitSelectionNChoices = sizeof( m_rbUnitSelectionChoices ) / sizeof( wxString );
|
||||
m_rbUnitSelection = new wxRadioBox( this, wxID_ANY, _("Output Units:"), wxDefaultPosition, wxDefaultSize, m_rbUnitSelectionNChoices, m_rbUnitSelectionChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_rbUnitSelection->SetSelection( 1 );
|
||||
m_rbUnitSelection->SetSelection( 0 );
|
||||
bSizer2->Add( m_rbUnitSelection, 0, wxALL, 5 );
|
||||
|
||||
|
||||
|
|
|
@ -366,6 +366,94 @@
|
|||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Auto Adjust</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_cbAutoAdjustOffset</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxCHK_2STATE</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnCheckBox"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
|
@ -970,7 +1058,7 @@
|
|||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="selection">1</property>
|
||||
<property name="selection">0</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxRA_SPECIFY_COLS</property>
|
||||
|
|
|
@ -21,6 +21,7 @@ class DIALOG_SHIM;
|
|||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/filepicker.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/textctrl.h>
|
||||
|
@ -43,6 +44,7 @@ class DIALOG_EXPORT_IDF3_BASE : public DIALOG_SHIM
|
|||
wxStaticText* m_txtBrdFile;
|
||||
wxFilePickerCtrl* m_filePickerIDF;
|
||||
wxStaticText* m_staticText2;
|
||||
wxCheckBox* m_cbAutoAdjustOffset;
|
||||
wxStaticText* m_staticText5;
|
||||
wxChoice* m_IDF_RefUnitChoice;
|
||||
wxStaticText* m_staticText3;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <idf_parser.h>
|
||||
#include <3d_struct.h>
|
||||
#include <build_version.h>
|
||||
#include <convert_from_iu.h>
|
||||
|
||||
#ifndef PCBNEW
|
||||
#define PCBNEW // needed to define the right value of Millimeter2iu(x)
|
||||
|
@ -540,7 +541,7 @@ bool Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, bool aUseThou,
|
|||
SetLocaleTo_C_standard();
|
||||
|
||||
bool ok = true;
|
||||
double scale = 1e-6; // we must scale internal units to mm for IDF
|
||||
double scale = MM_PER_IU; // we must scale internal units to mm for IDF
|
||||
IDF3::IDF_UNIT idfUnit;
|
||||
|
||||
if( aUseThou )
|
||||
|
|
Loading…
Reference in New Issue