From 37742627b4eb1be10fa0095f42f9a64201d567cb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Aug 2015 15:13:34 +0200 Subject: [PATCH] Restore Meter option to VRML export + other changes * Adds a "Grid Reference Point" to the VRML export; this allows a user to specify the (X,Y) coordinate which will be the origin point on the output * Adds a "Grid Reference Point" to the IDF export; this is similar in purpose to the corresponding VRML export feature. --- include/wxPcbStruct.h | 5 +- pcbnew/dialogs/dialog_export_idf.cpp | 63 +- pcbnew/dialogs/dialog_export_idf_base.cpp | 70 +- pcbnew/dialogs/dialog_export_idf_base.fbp | 847 ++++++++++++++++-- pcbnew/dialogs/dialog_export_idf_base.h | 14 +- pcbnew/dialogs/dialog_export_vrml.cpp | 49 +- pcbnew/dialogs/dialog_export_vrml_base.cpp | 80 +- pcbnew/dialogs/dialog_export_vrml_base.fbp | 954 ++++++++++++++++++--- pcbnew/dialogs/dialog_export_vrml_base.h | 18 +- pcbnew/exporters/export_idf.cpp | 9 +- pcbnew/exporters/export_vrml.cpp | 10 +- 11 files changed, 1873 insertions(+), 246 deletions(-) diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 8253bf91e8..253d484ad2 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -986,11 +986,14 @@ public: * converted to a STEP model. * @param a3D_Subdir = sub directory where 3D shapes files are copied. This is only used * when aExport3DFiles == true + * @param aXRef = X value of PCB (0,0) reference point + * @param aYRef = Y value of PCB (0,0) reference point * @return true if Ok. */ bool ExportVRML_File( const wxString & aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles, bool aUseRelativePaths, - bool aUsePlainPCB, const wxString & a3D_Subdir ); + bool aUsePlainPCB, const wxString & a3D_Subdir, + double aXRef, double aYRef ); /** * Function ExportToIDF3 diff --git a/pcbnew/dialogs/dialog_export_idf.cpp b/pcbnew/dialogs/dialog_export_idf.cpp index b2631f677d..1f76b71d5b 100644 --- a/pcbnew/dialogs/dialog_export_idf.cpp +++ b/pcbnew/dialogs/dialog_export_idf.cpp @@ -34,9 +34,24 @@ #include #define OPTKEY_IDF_THOU wxT( "IDFExportThou" ) +#define OPTKEY_IDF_REF_UNITS wxT( "IDFRefUnits" ) +#define OPTKEY_IDF_REF_X wxT( "IDFRefX" ) +#define OPTKEY_IDF_REF_Y wxT( "IDFRefY" ) -bool Export_IDF3( BOARD *aPcb, const wxString & aFullFileName, bool aUseThou ); +/** + * Function Export_IDF3 + * Creates an IDF3 compliant BOARD (*.emn) and LIBRARY (*.emp) file. + * + * @param aPcb = a pointer to the board to be exported to IDF + * @param aFullFileName = the full filename of the export file + * @param aUseThou = set to true if the desired IDF unit is thou (mil) + * @param aXRef = the board Reference Point in mm, X value + * @param aYRef = the board Reference Point in mm, Y value + * @return true if OK + */ +bool Export_IDF3( BOARD *aPcb, const wxString & aFullFileName, bool aUseThou, + double aXRef, double aYRef ); class DIALOG_EXPORT_IDF3: public DIALOG_EXPORT_IDF3_BASE @@ -44,7 +59,10 @@ class DIALOG_EXPORT_IDF3: public DIALOG_EXPORT_IDF3_BASE private: PCB_EDIT_FRAME* m_parent; wxConfigBase* m_config; - bool m_idfThouOpt; // remember last preference for units in THOU + bool m_idfThouOpt; // remember last preference for units in THOU + 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 public: DIALOG_EXPORT_IDF3( PCB_EDIT_FRAME* parent ) : @@ -56,6 +74,17 @@ 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_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_IDF_RefUnitChoice->SetSelection( m_RefUnits ); + wxString tmpStr; + tmpStr << m_XRef; + m_IDF_Xref->SetValue( tmpStr ); + tmpStr = wxT( "" ); + tmpStr << m_YRef; + m_IDF_Yref->SetValue( tmpStr ); wxWindow* button = FindWindowByLabel( wxT( "OK" ) ); @@ -70,6 +99,9 @@ public: { m_idfThouOpt = m_rbUnitSelection->GetSelection() == 1; m_config->Write( OPTKEY_IDF_THOU, m_idfThouOpt ); + 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() ); } bool GetThouOption() @@ -81,6 +113,22 @@ public: { return m_filePickerIDF; } + + int GetRefUnitsChoice() + { + return m_IDF_RefUnitChoice->GetSelection(); + } + + double GetXRef() + { + return DoubleValueFromString( UNSCALED_UNITS, m_IDF_Xref->GetValue() ); + } + + double GetYRef() + { + return DoubleValueFromString( UNSCALED_UNITS, m_IDF_Yref->GetValue() ); + } + }; @@ -103,12 +151,21 @@ void PCB_EDIT_FRAME::ExportToIDF3( wxCommandEvent& event ) return; bool thou = dlg.GetThouOption(); + double aXRef = dlg.GetXRef(); + double aYRef = dlg.GetYRef(); + + if( dlg.GetRefUnitsChoice() == 1 ) + { + // selected reference unit is in inches + aXRef *= 25.4; + aYRef *= 25.4; + } wxBusyCursor dummy; wxString fullFilename = dlg.FilePicker()->GetPath(); - if( !Export_IDF3( GetBoard(), fullFilename, thou ) ) + if( !Export_IDF3( GetBoard(), fullFilename, thou, aXRef, aYRef ) ) { wxString msg = _( "Unable to create " ) + fullFilename; wxMessageBox( msg ); diff --git a/pcbnew/dialogs/dialog_export_idf_base.cpp b/pcbnew/dialogs/dialog_export_idf_base.cpp index ba8cbcab95..c27052ffc3 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.cpp +++ b/pcbnew/dialogs/dialog_export_idf_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Aug 17 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -23,14 +23,74 @@ DIALOG_EXPORT_IDF3_BASE::DIALOG_EXPORT_IDF3_BASE( wxWindow* parent, wxWindowID i m_filePickerIDF = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Select an IDF export filename"), wxT("*.emn"), wxDefaultPosition, wxSize( 450,-1 ), wxFLP_OVERWRITE_PROMPT|wxFLP_SAVE|wxFLP_USE_TEXTCTRL ); bSizerIDFFile->Add( m_filePickerIDF, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxVERTICAL ); + + m_staticText2 = new wxStaticText( this, wxID_ANY, _("Grid Reference Point:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText2->Wrap( -1 ); + bSizer3->Add( m_staticText2, 0, wxALL, 5 ); + + wxBoxSizer* bSizer6; + bSizer6 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText5 = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText5->Wrap( -1 ); + bSizer6->Add( m_staticText5, 0, wxALL, 5 ); + + wxString m_IDF_RefUnitChoiceChoices[] = { _("mm"), _("inch") }; + int m_IDF_RefUnitChoiceNChoices = sizeof( m_IDF_RefUnitChoiceChoices ) / sizeof( wxString ); + m_IDF_RefUnitChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_IDF_RefUnitChoiceNChoices, m_IDF_RefUnitChoiceChoices, 0 ); + m_IDF_RefUnitChoice->SetSelection( 0 ); + bSizer6->Add( m_IDF_RefUnitChoice, 0, wxALL, 5 ); + + + bSizer3->Add( bSizer6, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText3 = new wxStaticText( this, wxID_ANY, _("X ref:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText3->Wrap( -1 ); + bSizer4->Add( m_staticText3, 0, wxALL, 5 ); + + m_IDF_Xref = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + m_IDF_Xref->SetMaxLength( 8 ); + bSizer4->Add( m_IDF_Xref, 0, wxALL, 5 ); + + + bSizer3->Add( bSizer4, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText4 = new wxStaticText( this, wxID_ANY, _("Y Ref:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText4->Wrap( -1 ); + bSizer5->Add( m_staticText4, 0, wxALL, 5 ); + + m_IDF_Yref = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + m_IDF_Yref->SetMaxLength( 8 ); + bSizer5->Add( m_IDF_Yref, 0, wxALL, 5 ); + + + bSizer3->Add( bSizer5, 1, wxEXPAND, 5 ); + + + bSizer2->Add( bSizer3, 1, wxEXPAND, 5 ); + wxString m_rbUnitSelectionChoices[] = { _("Millimeters"), _("Mils") }; int m_rbUnitSelectionNChoices = sizeof( m_rbUnitSelectionChoices ) / sizeof( wxString ); - m_rbUnitSelection = new wxRadioBox( this, wxID_ANY, _("Units"), wxDefaultPosition, wxDefaultSize, m_rbUnitSelectionNChoices, m_rbUnitSelectionChoices, 1, wxRA_SPECIFY_COLS ); - m_rbUnitSelection->SetSelection( 0 ); - bSizerIDFFile->Add( m_rbUnitSelection, 0, wxALL, 5 ); + m_rbUnitSelection = new wxRadioBox( this, wxID_ANY, _("Output Units:"), wxDefaultPosition, wxDefaultSize, m_rbUnitSelectionNChoices, m_rbUnitSelectionChoices, 1, wxRA_SPECIFY_COLS ); + m_rbUnitSelection->SetSelection( 1 ); + bSizer2->Add( m_rbUnitSelection, 0, wxALL, 5 ); - bSizerIDFFile->Add( 0, 0, 1, 0, 5 ); + bSizer2->Add( 0, 0, 1, wxEXPAND, 5 ); + + + bSizerIDFFile->Add( bSizer2, 1, wxEXPAND, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizerIDFFile->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); diff --git a/pcbnew/dialogs/dialog_export_idf_base.fbp b/pcbnew/dialogs/dialog_export_idf_base.fbp index 434d92339d..0837b482bb 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.fbp +++ b/pcbnew/dialogs/dialog_export_idf_base.fbp @@ -267,102 +267,759 @@ 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Millimeters" "Mils" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Units - 1 - - 0 - - - 0 - - 1 - m_rbUnitSelection - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - + wxEXPAND 1 - - 0 - protected - 0 + + + bSizer2 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizer3 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Grid Reference Point: + + 0 + + + 0 + + 1 + m_staticText2 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer6 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Units: + + 0 + + + 0 + + 1 + m_staticText5 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 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_IDF_RefUnitChoice + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer4 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + X ref: + + 0 + + + 0 + + 1 + m_staticText3 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 8 + + 0 + + 1 + m_IDF_Xref + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NUMERIC + wxTextValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer5 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Y Ref: + + 0 + + + 0 + + 1 + m_staticText4 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 8 + + 0 + + 1 + m_IDF_Yref + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NUMERIC + wxTextValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Millimeters" "Mils" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Output Units: + 1 + + 0 + + + 0 + + 1 + m_rbUnitSelection + 1 + + + protected + 1 + + Resizable + 1 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + diff --git a/pcbnew/dialogs/dialog_export_idf_base.h b/pcbnew/dialogs/dialog_export_idf_base.h index 8a67803936..89e6d03ba4 100644 --- a/pcbnew/dialogs/dialog_export_idf_base.h +++ b/pcbnew/dialogs/dialog_export_idf_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Aug 17 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -21,9 +21,12 @@ class DIALOG_SHIM; #include #include #include +#include +#include +#include +#include #include #include -#include #include #include @@ -39,6 +42,13 @@ class DIALOG_EXPORT_IDF3_BASE : public DIALOG_SHIM protected: wxStaticText* m_txtBrdFile; wxFilePickerCtrl* m_filePickerIDF; + wxStaticText* m_staticText2; + wxStaticText* m_staticText5; + wxChoice* m_IDF_RefUnitChoice; + wxStaticText* m_staticText3; + wxTextCtrl* m_IDF_Xref; + wxStaticText* m_staticText4; + wxTextCtrl* m_IDF_Yref; wxRadioBox* m_rbUnitSelection; wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_sdbSizer1; diff --git a/pcbnew/dialogs/dialog_export_vrml.cpp b/pcbnew/dialogs/dialog_export_vrml.cpp index a1e5a61469..a56eed304a 100644 --- a/pcbnew/dialogs/dialog_export_vrml.cpp +++ b/pcbnew/dialogs/dialog_export_vrml.cpp @@ -42,6 +42,9 @@ #define OPTKEY_3DFILES_OPT wxT( "VrmlExportCopyFiles" ) #define OPTKEY_USE_RELATIVE_PATHS wxT( "VrmlUseRelativePaths" ) #define OPTKEY_USE_PLAIN_PCB wxT( "VrmlUsePlainPCB" ) +#define OPTKEY_VRML_REF_UNITS wxT( "VrmlRefUnits" ) +#define OPTKEY_VRML_REF_X wxT( "VrmlRefX" ) +#define OPTKEY_VRML_REF_Y wxT( "VrmlRefY" ) class DIALOG_EXPORT_3DFILE : public DIALOG_EXPORT_3DFILE_BASE @@ -53,6 +56,9 @@ private: bool m_copy3DFilesOpt; // Remember last copy model files option bool m_useRelativePathsOpt; // Remember last use absolut paths option bool m_usePlainPCBOpt; // Remember last Plain Board option + 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 public: DIALOG_EXPORT_3DFILE( PCB_EDIT_FRAME* parent ) : @@ -65,10 +71,20 @@ public: m_config->Read( OPTKEY_3DFILES_OPT, &m_copy3DFilesOpt, false ); m_config->Read( OPTKEY_USE_RELATIVE_PATHS, &m_useRelativePathsOpt, false ); m_config->Read( OPTKEY_USE_PLAIN_PCB, &m_usePlainPCBOpt, false ); + m_config->Read( OPTKEY_VRML_REF_UNITS, &m_RefUnits, 0 ); + m_config->Read( OPTKEY_VRML_REF_X, &m_XRef, 0.0 ); + m_config->Read( OPTKEY_VRML_REF_Y, &m_YRef, 0.0 ); m_rbSelectUnits->SetSelection( m_unitsOpt ); m_cbCopyFiles->SetValue( m_copy3DFilesOpt ); m_cbUseRelativePaths->SetValue( m_useRelativePathsOpt ); m_cbPlainPCB->SetValue( m_usePlainPCBOpt ); + m_VRML_RefUnitChoice->SetSelection( m_RefUnits ); + wxString tmpStr; + tmpStr << m_XRef; + m_VRML_Xref->SetValue( tmpStr ); + tmpStr = wxT( "" ); + tmpStr << m_YRef; + m_VRML_Yref->SetValue( tmpStr ); wxButton* okButton = (wxButton*) FindWindowByLabel( wxT( "OK" ) ); if( okButton ) @@ -89,6 +105,9 @@ public: m_config->Write( OPTKEY_3DFILES_OPT, m_copy3DFilesOpt ); m_config->Write( OPTKEY_USE_RELATIVE_PATHS, m_useRelativePathsOpt ); m_config->Write( OPTKEY_USE_PLAIN_PCB, m_usePlainPCBOpt ); + m_config->Write( OPTKEY_VRML_REF_UNITS, m_VRML_RefUnitChoice->GetSelection() ); + m_config->Write( OPTKEY_VRML_REF_X, m_VRML_Xref->GetValue() ); + m_config->Write( OPTKEY_VRML_REF_Y, m_VRML_Yref->GetValue() ); }; void SetSubdir( const wxString & aDir ) @@ -106,6 +125,21 @@ public: return m_filePicker; } + int GetRefUnitsChoice() + { + return m_VRML_RefUnitChoice->GetSelection(); + } + + double GetXRef() + { + return DoubleValueFromString( UNSCALED_UNITS, m_VRML_Xref->GetValue() ); + } + + double GetYRef() + { + return DoubleValueFromString( UNSCALED_UNITS, m_VRML_Yref->GetValue() ); + } + int GetUnits() { return m_unitsOpt = m_rbSelectUnits->GetSelection(); @@ -152,7 +186,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) // The general VRML scale factor // Assuming the VRML default unit is the mm // this is the mm to VRML scaling factor for mm, 0.1 inch, and inch - double scaleList[3] = { 1.0, 10.0/25.4, 1.0/25.4 }; + double scaleList[4] = { 1.0, 0.001, 10.0/25.4, 1.0/25.4 }; // Build default file name fn = GetBoard()->GetFileName(); @@ -165,6 +199,16 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) if( dlg.ShowModal() != wxID_OK ) return; + double aXRef = dlg.GetXRef(); + double aYRef = dlg.GetYRef(); + + if( dlg.GetRefUnitsChoice() == 1 ) + { + // selected reference unit is in inches + aXRef *= 25.4; + aYRef *= 25.4; + } + double scale = scaleList[dlg.GetUnits()]; // final scale export bool export3DFiles = dlg.GetCopyFilesOption(); bool useRelativePaths = dlg.GetUseRelativePathsOption(); @@ -185,7 +229,8 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) } if( !ExportVRML_File( fullFilename, scale, export3DFiles, useRelativePaths, - usePlainPCB, modelPath.GetPath() ) ) + usePlainPCB, modelPath.GetPath(), + aXRef, aYRef ) ) { wxString msg = _( "Unable to create " ) + fullFilename; wxMessageBox( msg ); diff --git a/pcbnew/dialogs/dialog_export_vrml_base.cpp b/pcbnew/dialogs/dialog_export_vrml_base.cpp index 9e448a272c..936cbbe12f 100644 --- a/pcbnew/dialogs/dialog_export_vrml_base.cpp +++ b/pcbnew/dialogs/dialog_export_vrml_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 17 2014) +// C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -37,6 +37,73 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow bSizer1->Add( bUpperSizer, 0, wxALL|wxEXPAND, 5 ); + wxBoxSizer* bSizer12; + bSizer12 = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxVERTICAL ); + + m_panel1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer9; + bSizer9 = new wxBoxSizer( wxVERTICAL ); + + m_staticText6 = new wxStaticText( m_panel1, wxID_ANY, _("Grid Reference Point:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText6->Wrap( -1 ); + bSizer9->Add( m_staticText6, 0, wxALL, 5 ); + + wxFlexGridSizer* fgSizerOptions; + fgSizerOptions = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizerOptions->AddGrowableCol( 1 ); + fgSizerOptions->SetFlexibleDirection( wxBOTH ); + fgSizerOptions->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText61 = new wxStaticText( m_panel1, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText61->Wrap( -1 ); + fgSizerOptions->Add( m_staticText61, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + wxString m_VRML_RefUnitChoiceChoices[] = { _("mm"), _("inch") }; + int m_VRML_RefUnitChoiceNChoices = sizeof( m_VRML_RefUnitChoiceChoices ) / sizeof( wxString ); + m_VRML_RefUnitChoice = new wxChoice( m_panel1, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_VRML_RefUnitChoiceNChoices, m_VRML_RefUnitChoiceChoices, 0 ); + m_VRML_RefUnitChoice->SetSelection( 0 ); + fgSizerOptions->Add( m_VRML_RefUnitChoice, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_staticText4 = new wxStaticText( m_panel1, wxID_ANY, _("X Ref:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText4->Wrap( -1 ); + fgSizerOptions->Add( m_staticText4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_VRML_Xref = new wxTextCtrl( m_panel1, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + m_VRML_Xref->SetMaxLength( 8 ); + fgSizerOptions->Add( m_VRML_Xref, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + + m_staticText5 = new wxStaticText( m_panel1, wxID_ANY, _("Y Ref:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText5->Wrap( -1 ); + fgSizerOptions->Add( m_staticText5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_VRML_Yref = new wxTextCtrl( m_panel1, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + m_VRML_Yref->SetMaxLength( 8 ); + fgSizerOptions->Add( m_VRML_Yref, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizer9->Add( fgSizerOptions, 1, wxEXPAND, 5 ); + + + m_panel1->SetSizer( bSizer9 ); + m_panel1->Layout(); + bSizer9->Fit( m_panel1 ); + bSizer5->Add( m_panel1, 1, wxEXPAND | wxALL, 5 ); + + + bSizer12->Add( bSizer5, 1, wxEXPAND, 5 ); + + wxString m_rbSelectUnitsChoices[] = { _("mm"), _("meter"), _("0.1 Inch"), _("Inch") }; + int m_rbSelectUnitsNChoices = sizeof( m_rbSelectUnitsChoices ) / sizeof( wxString ); + m_rbSelectUnits = new wxRadioBox( this, wxID_ANY, _("Output Units:"), wxDefaultPosition, wxDefaultSize, m_rbSelectUnitsNChoices, m_rbSelectUnitsChoices, 1, wxRA_SPECIFY_COLS ); + m_rbSelectUnits->SetSelection( 0 ); + bSizer12->Add( m_rbSelectUnits, 1, wxALL|wxEXPAND, 5 ); + + + bSizer1->Add( bSizer12, 0, wxEXPAND, 5 ); + wxBoxSizer* bLowerSizer; bLowerSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -56,16 +123,10 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow bSizer4->Add( m_cbPlainPCB, 0, wxALL, 5 ); - bLowerSizer->Add( bSizer4, 3, wxEXPAND, 5 ); - - wxString m_rbSelectUnitsChoices[] = { _("mm"), _("0.1 Inch"), _("Inch") }; - int m_rbSelectUnitsNChoices = sizeof( m_rbSelectUnitsChoices ) / sizeof( wxString ); - m_rbSelectUnits = new wxRadioBox( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, m_rbSelectUnitsNChoices, m_rbSelectUnitsChoices, 1, wxRA_SPECIFY_COLS ); - m_rbSelectUnits->SetSelection( 0 ); - bLowerSizer->Add( m_rbSelectUnits, 1, wxALL|wxEXPAND, 5 ); + bLowerSizer->Add( bSizer4, 2, wxEXPAND, 5 ); - bSizer1->Add( bLowerSizer, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizer1->Add( bLowerSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizer1->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); @@ -82,7 +143,6 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow this->SetSizer( bSizer1 ); this->Layout(); - bSizer1->Fit( this ); // Connect Events m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnCancelClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_export_vrml_base.fbp b/pcbnew/dialogs/dialog_export_vrml_base.fbp index 410bbea5e2..53a2e67eb6 100644 --- a/pcbnew/dialogs/dialog_export_vrml_base.fbp +++ b/pcbnew/dialogs/dialog_export_vrml_base.fbp @@ -44,7 +44,7 @@ DIALOG_EXPORT_3DFILE_BASE - -1,-1 + 384,370 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h VRML Export Options @@ -93,20 +93,20 @@ bSizer1 wxVERTICAL none - + 5 wxALL|wxEXPAND 0 - + -1,-1 bUpperSizer wxVERTICAL none - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -185,11 +185,11 @@ - + 5 wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND 0 - + 1 1 1 @@ -274,11 +274,11 @@ - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -357,11 +357,11 @@ - + 5 wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -450,10 +450,828 @@ + + 5 + wxEXPAND + 0 + + + bSizer12 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizer5 + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panel1 + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer9 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Grid Reference Point: + + 0 + + + 0 + + 1 + m_staticText6 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 2 + wxBOTH + 1 + + 0 + + fgSizerOptions + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Units: + + 0 + + + 0 + + 1 + m_staticText61 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND + 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_VRML_RefUnitChoice + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + X Ref: + + 0 + + + 0 + + 1 + m_staticText4 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 8 + + 0 + + 1 + m_VRML_Xref + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NUMERIC + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Y Ref: + + 0 + + + 0 + + 1 + m_staticText5 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 8 + + 0 + + 1 + m_VRML_Yref + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NUMERIC + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "mm" "meter" "0.1 Inch" "Inch" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Output Units: + 1 + + 0 + + + 0 + + 1 + m_rbSelectUnits + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 1 + 0 bLowerSizer @@ -462,17 +1280,17 @@ 5 wxEXPAND - 3 + 2 bSizer4 wxVERTICAL none - + 5 wxALL 0 - + 1 1 1 @@ -556,11 +1374,11 @@ - + 5 wxALL 0 - + 1 1 1 @@ -644,11 +1462,11 @@ - + 5 wxALL 0 - + 1 1 1 @@ -734,103 +1552,13 @@ - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "mm" "0.1 Inch" "Inch" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Units: - 1 - - 0 - - - 0 - - 1 - m_rbSelectUnits - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 5 wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -907,11 +1635,11 @@ - + 5 wxEXPAND|wxALL 0 - + 0 1 0 diff --git a/pcbnew/dialogs/dialog_export_vrml_base.h b/pcbnew/dialogs/dialog_export_vrml_base.h index 1c1b3fe924..bd6cac053e 100644 --- a/pcbnew/dialogs/dialog_export_vrml_base.h +++ b/pcbnew/dialogs/dialog_export_vrml_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 17 2014) +// C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -23,8 +23,10 @@ class DIALOG_SHIM; #include #include #include -#include +#include +#include #include +#include #include #include #include @@ -48,10 +50,18 @@ class DIALOG_EXPORT_3DFILE_BASE : public DIALOG_SHIM wxFilePickerCtrl* m_filePicker; wxStaticText* m_staticText3; wxTextCtrl* m_SubdirNameCtrl; + wxPanel* m_panel1; + wxStaticText* m_staticText6; + wxStaticText* m_staticText61; + wxChoice* m_VRML_RefUnitChoice; + wxStaticText* m_staticText4; + wxTextCtrl* m_VRML_Xref; + wxStaticText* m_staticText5; + wxTextCtrl* m_VRML_Yref; + wxRadioBox* m_rbSelectUnits; wxCheckBox* m_cbCopyFiles; wxCheckBox* m_cbUseRelativePaths; wxCheckBox* m_cbPlainPCB; - wxRadioBox* m_rbSelectUnits; wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; @@ -64,7 +74,7 @@ class DIALOG_EXPORT_3DFILE_BASE : public DIALOG_SHIM public: - DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("VRML Export Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("VRML Export Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 384,370 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EXPORT_3DFILE_BASE(); }; diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp index 3b834c7100..51ab61738e 100644 --- a/pcbnew/exporters/export_idf.cpp +++ b/pcbnew/exporters/export_idf.cpp @@ -532,7 +532,8 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, * generates IDFv3 compliant board (*.emn) and library (*.emp) * files representing the user's PCB design. */ -bool Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, bool aUseThou ) +bool Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, bool aUseThou, + double aXRef, double aYRef ) { IDF3_BOARD idfBoard( IDF3::CAD_ELEC ); @@ -567,10 +568,8 @@ bool Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, bool aUseThou ) try { - // set up the global offsets - EDA_RECT bbox = aPcb->ComputeBoundingBox( true ); - idfBoard.SetUserOffset( -bbox.Centre().x * scale, - bbox.Centre().y * scale ); + // set up the board reference point + idfBoard.SetUserOffset( -aXRef, aYRef ); // Export the board outline idf_export_outline( aPcb, idfBoard ); diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 40dba6eaaa..558fc89061 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -1313,7 +1313,8 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles, bool aUseRelativePaths, - bool aUsePlainPCB, const wxString& a3D_Subdir ) + bool aUsePlainPCB, const wxString& a3D_Subdir, + double aXRef, double aYRef ) { wxString msg; BOARD* pcb = GetBoard(); @@ -1346,11 +1347,8 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMt output_file << "Transform {\n"; - // compute the offset to center the board on (0, 0, 0) - // XXX - NOTE: we should allow the user a GUI option to specify the offset - EDA_RECT bbbox = pcb->ComputeBoundingBox(); - - model3d.SetOffset( -model3d.scale * bbbox.Centre().x, model3d.scale * bbbox.Centre().y ); + // board reference point + model3d.SetOffset( -aXRef, aYRef ); output_file << " children [\n";