Commit 431ed318 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew VRML export improvements.

* Improve VRML export dialog lay out.
* Make the OK button the default action in the export dialog.
* Make 3D model export work correctly and avoid redundant file copies.
* Fix embedded path separators in wrl files on windows.
* Fix absolute model file path creation in wrl files.
* Clean up VRML export code.
parent 40468bff
...@@ -934,12 +934,15 @@ public: ...@@ -934,12 +934,15 @@ public:
* @param aMMtoWRMLunit = the VRML scaling factor: * @param aMMtoWRMLunit = the VRML scaling factor:
* 1.0 to export in mm. 0.001 for meters * 1.0 to export in mm. 0.001 for meters
* @param aExport3DFiles = true to copy 3D shapes in the subir a3D_Subdir * @param aExport3DFiles = true to copy 3D shapes in the subir a3D_Subdir
* @param a3D_Subdir = sub directory where 3D shapes files are copied * @param aUseRelativePaths set to true to use relative paths instead of absolute paths
* used only when aExport3DFiles == true * in the board VRML file URLs.
* @param a3D_Subdir = sub directory where 3D shapes files are copied. This is only used
* when aExport3DFiles == true
* @return true if Ok. * @return true if Ok.
*/ */
bool ExportVRML_File( const wxString & aFullFileName, double aMMtoWRMLunit, bool ExportVRML_File( const wxString & aFullFileName, double aMMtoWRMLunit,
bool aExport3DFiles, const wxString & a3D_Subdir ); bool aExport3DFiles, bool aUseRelativePaths,
const wxString & a3D_Subdir );
/** /**
* Function ExportToIDF3 * Function ExportToIDF3
......
...@@ -38,19 +38,19 @@ ...@@ -38,19 +38,19 @@
*/ */
#include <dialog_export_vrml_base.h> // the wxFormBuilder header file #include <dialog_export_vrml_base.h> // the wxFormBuilder header file
#define OPTKEY_OUTPUT_UNIT wxT("VrmlExportUnit" ) #define OPTKEY_OUTPUT_UNIT wxT( "VrmlExportUnit" )
#define OPTKEY_3DFILES_OPT wxT("VrmlExport3DShapeFilesOpt" ) #define OPTKEY_3DFILES_OPT wxT( "VrmlExportCopyFiles" )
#define OPTKEY_USE_ABS_PATHS wxT( "VrmlUseRelativePaths" )
class DIALOG_EXPORT_3DFILE : public DIALOG_EXPORT_3DFILE_BASE class DIALOG_EXPORT_3DFILE : public DIALOG_EXPORT_3DFILE_BASE
{ {
private: private:
PCB_EDIT_FRAME* m_parent; PCB_EDIT_FRAME* m_parent;
wxConfigBase* m_config; wxConfigBase* m_config;
int m_unitsOpt; // to remember last option int m_unitsOpt; // Remember last units option
int m_3DFilesOpt; // to remember last option bool m_copy3DFilesOpt; // Remember last copy model files option
bool m_useRelativePathsOpt; // Remember last use absolut paths option
void OnCancelClick( wxCommandEvent& event ){ EndModal( wxID_CANCEL ); }
void OnOkClick( wxCommandEvent& event ){ EndModal( wxID_OK ); }
public: public:
DIALOG_EXPORT_3DFILE( PCB_EDIT_FRAME* parent ) : DIALOG_EXPORT_3DFILE( PCB_EDIT_FRAME* parent ) :
...@@ -58,30 +58,42 @@ public: ...@@ -58,30 +58,42 @@ public:
{ {
m_parent = parent; m_parent = parent;
m_config = Kiface().KifaceSettings(); m_config = Kiface().KifaceSettings();
SetFocus(); m_filePicker->SetFocus();
m_config->Read( OPTKEY_OUTPUT_UNIT, &m_unitsOpt ); m_config->Read( OPTKEY_OUTPUT_UNIT, &m_unitsOpt );
m_config->Read( OPTKEY_3DFILES_OPT, &m_3DFilesOpt ); m_config->Read( OPTKEY_3DFILES_OPT, &m_copy3DFilesOpt );
m_rbSelectUnits->SetSelection(m_unitsOpt); m_config->Read( OPTKEY_USE_ABS_PATHS, &m_useRelativePathsOpt );
m_rb3DFilesOption->SetSelection(m_3DFilesOpt); m_rbSelectUnits->SetSelection( m_unitsOpt );
m_cbCopyFiles->SetValue( m_copy3DFilesOpt );
m_cbUseAbsolutePaths->SetValue( m_useRelativePathsOpt );
wxButton* okButton = (wxButton*) FindWindowByLabel( wxT( "OK" ) );
if( okButton )
SetDefaultItem( okButton );
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
Centre(); Centre();
Connect( ID_USE_ABS_PATH, wxEVT_UPDATE_UI,
wxUpdateUIEventHandler( DIALOG_EXPORT_3DFILE::OnUpdateUseAbsolutPath ) );
} }
~DIALOG_EXPORT_3DFILE() ~DIALOG_EXPORT_3DFILE()
{ {
m_unitsOpt = GetUnits( ); m_unitsOpt = GetUnits();
m_3DFilesOpt = Get3DFilesOption( ); m_copy3DFilesOpt = GetCopyFilesOption();
m_config->Write( OPTKEY_OUTPUT_UNIT, m_unitsOpt ); m_config->Write( OPTKEY_OUTPUT_UNIT, m_unitsOpt );
m_config->Write( OPTKEY_3DFILES_OPT, m_3DFilesOpt ); m_config->Write( OPTKEY_3DFILES_OPT, m_copy3DFilesOpt );
m_config->Write( OPTKEY_USE_ABS_PATHS, m_useRelativePathsOpt );
}; };
void SetSubdir( const wxString & aDir ) void SetSubdir( const wxString & aDir )
{ {
m_SubdirNameCtrl->SetValue( aDir); m_SubdirNameCtrl->SetValue( aDir );
} }
wxString GetSubdir( ) wxString GetSubdir()
{ {
return m_SubdirNameCtrl->GetValue( ); return m_SubdirNameCtrl->GetValue();
} }
wxFilePickerCtrl* FilePicker() wxFilePickerCtrl* FilePicker()
...@@ -89,26 +101,43 @@ public: ...@@ -89,26 +101,43 @@ public:
return m_filePicker; return m_filePicker;
} }
int GetUnits( ) int GetUnits()
{ {
return m_unitsOpt = m_rbSelectUnits->GetSelection(); return m_unitsOpt = m_rbSelectUnits->GetSelection();
} }
int Get3DFilesOption( ) bool GetCopyFilesOption()
{ {
return m_3DFilesOpt = m_rb3DFilesOption->GetSelection(); return m_copy3DFilesOpt = m_cbCopyFiles->GetValue();
}
bool GetUseAbsolutePathsOption()
{
return m_useRelativePathsOpt = m_cbUseAbsolutePaths->GetValue();
}
void OnUpdateUseAbsolutPath( wxUpdateUIEvent& event )
{
// Making path relative or absolute has no meaning when VRML files are not copied.
event.Enable( m_cbCopyFiles->GetValue() );
} }
}; };
/**
* Function OnExportVRML
* will export the current BOARD to a VRML file.
*/
void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
static wxString subDirFor3Dshapes = wxT("shapes3D"); wxString projectPath;
if( !wxGetEnv( wxT( "KIPRJMOD" ), &projectPath ) )
projectPath = wxFileName::GetCwd();
static wxString subDirFor3Dshapes;
if( subDirFor3Dshapes.IsEmpty() )
{
subDirFor3Dshapes = wxT( "shapes3D" );
}
// The general VRML scale factor // The general VRML scale factor
// Assuming the VRML default unit is the mm // Assuming the VRML default unit is the mm
...@@ -116,9 +145,8 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) ...@@ -116,9 +145,8 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
double scaleList[3] = { 1.0/25.4, 1, 0.001 }; double scaleList[3] = { 1.0/25.4, 1, 0.001 };
// Build default file name // Build default file name
wxString ext = wxT( "wrl" );
fn = GetBoard()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ext ); fn.SetExt( wxT( "wrl" ) );
DIALOG_EXPORT_3DFILE dlg( this ); DIALOG_EXPORT_3DFILE dlg( this );
dlg.FilePicker()->SetPath( fn.GetFullPath() ); dlg.FilePicker()->SetPath( fn.GetFullPath() );
...@@ -127,18 +155,26 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) ...@@ -127,18 +155,26 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; return;
double scale = scaleList[dlg.GetUnits( )]; // final scale export double scale = scaleList[dlg.GetUnits()]; // final scale export
bool export3DFiles = dlg.Get3DFilesOption( ) == 0; bool export3DFiles = dlg.GetCopyFilesOption();
bool useRelativePaths = dlg.GetUseAbsolutePathsOption();
wxString fullFilename = dlg.FilePicker()->GetPath();
wxFileName modelPath = fullFilename;
wxBusyCursor dummy; wxBusyCursor dummy;
wxString fullFilename = dlg.FilePicker()->GetPath(); modelPath.AppendDir( dlg.GetSubdir() );
subDirFor3Dshapes = dlg.GetSubdir(); subDirFor3Dshapes = dlg.GetSubdir();
if( export3DFiles && !wxDirExists( subDirFor3Dshapes ) ) wxLogDebug( wxT( "Exporting enabled=%d to %s." ),
wxMkdir( subDirFor3Dshapes ); export3DFiles, GetChars( subDirFor3Dshapes ) );
if( export3DFiles && !modelPath.DirExists() )
{
modelPath.Mkdir();
}
if( ! ExportVRML_File( fullFilename, scale, export3DFiles, subDirFor3Dshapes ) ) if( !ExportVRML_File( fullFilename, scale, export3DFiles, useRelativePaths,
modelPath.GetPath() ) )
{ {
wxString msg = _( "Unable to create " ) + fullFilename; wxString msg = _( "Unable to create " ) + fullFilename;
wxMessageBox( msg ); wxMessageBox( msg );
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012) // C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -19,15 +19,14 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow ...@@ -19,15 +19,14 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow
wxBoxSizer* bUpperSizer; wxBoxSizer* bUpperSizer;
bUpperSizer = new wxBoxSizer( wxVERTICAL ); bUpperSizer = new wxBoxSizer( wxVERTICAL );
bUpperSizer->SetMinSize( wxSize( 450,-1 ) ); m_staticText1 = new wxStaticText( this, wxID_ANY, _("File Name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Vrml main file filename:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 ); m_staticText1->Wrap( -1 );
bUpperSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bUpperSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_filePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Save VRML Board File"), wxT("*.wrl"), wxDefaultPosition, wxDefaultSize, wxFLP_SAVE|wxFLP_USE_TEXTCTRL ); m_filePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Save VRML Board File"), wxT("*.wrl"), wxDefaultPosition, wxDefaultSize, wxFLP_SAVE|wxFLP_USE_TEXTCTRL );
bUpperSizer->Add( m_filePicker, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bUpperSizer->Add( m_filePicker, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Vrml 3D footprints shapes subdir:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText3 = new wxStaticText( this, wxID_ANY, _("Footprint 3D model path:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->Wrap( -1 ); m_staticText3->Wrap( -1 );
bUpperSizer->Add( m_staticText3, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bUpperSizer->Add( m_staticText3, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
...@@ -36,25 +35,33 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow ...@@ -36,25 +35,33 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow
bUpperSizer->Add( m_SubdirNameCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bUpperSizer->Add( m_SubdirNameCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizer1->Add( bUpperSizer, 0, wxEXPAND, 5 ); bSizer1->Add( bUpperSizer, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bLowerSizer; wxBoxSizer* bLowerSizer;
bLowerSizer = new wxBoxSizer( wxHORIZONTAL ); bLowerSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_cbCopyFiles = new wxCheckBox( this, wxID_ANY, _("Copy 3D model files to 3D model path"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbCopyFiles->SetValue(true);
bSizer4->Add( m_cbCopyFiles, 0, wxALL, 5 );
m_cbUseAbsolutePaths = new wxCheckBox( this, ID_USE_ABS_PATH, _("Use absolute paths to model files in board VRML file"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUseAbsolutePaths->SetValue(true);
bSizer4->Add( m_cbUseAbsolutePaths, 0, wxALL, 5 );
bLowerSizer->Add( bSizer4, 3, wxEXPAND, 5 );
wxString m_rbSelectUnitsChoices[] = { _("Inch"), _("mm"), _("Meter") }; wxString m_rbSelectUnitsChoices[] = { _("Inch"), _("mm"), _("Meter") };
int m_rbSelectUnitsNChoices = sizeof( m_rbSelectUnitsChoices ) / sizeof( wxString ); 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 = new wxRadioBox( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, m_rbSelectUnitsNChoices, m_rbSelectUnitsChoices, 1, wxRA_SPECIFY_COLS );
m_rbSelectUnits->SetSelection( 0 ); m_rbSelectUnits->SetSelection( 0 );
bLowerSizer->Add( m_rbSelectUnits, 1, wxALL|wxEXPAND, 5 ); bLowerSizer->Add( m_rbSelectUnits, 1, wxALL|wxEXPAND, 5 );
wxString m_rb3DFilesOptionChoices[] = { _("Copy 3D Shapes Files in Subdir"), _("Use Absolute Path in Vrml File ") };
int m_rb3DFilesOptionNChoices = sizeof( m_rb3DFilesOptionChoices ) / sizeof( wxString );
m_rb3DFilesOption = new wxRadioBox( this, wxID_ANY, _("3D Shapes Files Option:"), wxDefaultPosition, wxDefaultSize, m_rb3DFilesOptionNChoices, m_rb3DFilesOptionChoices, 1, wxRA_SPECIFY_COLS );
m_rb3DFilesOption->SetSelection( 1 );
bLowerSizer->Add( m_rb3DFilesOption, 1, wxALL|wxEXPAND, 5 );
bSizer1->Add( bLowerSizer, 1, wxEXPAND, 5 ); bSizer1->Add( bLowerSizer, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizer1->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); bSizer1->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
...@@ -71,6 +78,7 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow ...@@ -71,6 +78,7 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow
this->SetSizer( bSizer1 ); this->SetSizer( bSizer1 );
this->Layout(); this->Layout();
bSizer1->Fit( this );
// Connect Events // Connect Events
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnCancelClick ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnCancelClick ), NULL, this );
......
...@@ -20,8 +20,10 @@ ...@@ -20,8 +20,10 @@
<property name="path">.</property> <property name="path">.</property>
<property name="precompiled_header"></property> <property name="precompiled_header"></property>
<property name="relative_path">1</property> <property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property> <property name="skip_php_events">1</property>
<property name="skip_python_events">1</property> <property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">1</property> <property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property> <property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1"> <object class="Dialog" expanded="1">
...@@ -42,10 +44,10 @@ ...@@ -42,10 +44,10 @@
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">DIALOG_EXPORT_3DFILE_BASE</property> <property name="name">DIALOG_EXPORT_3DFILE_BASE</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">370,252</property> <property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Vrml Board Export Options:</property> <property name="title">VRML Export Options</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
...@@ -93,10 +95,10 @@ ...@@ -93,10 +95,10 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size">450,-1</property> <property name="minimum_size">-1,-1</property>
<property name="name">bUpperSizer</property> <property name="name">bUpperSizer</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
...@@ -132,7 +134,7 @@ ...@@ -132,7 +134,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Vrml main file filename:</property> <property name="label">File Name:</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
...@@ -304,7 +306,7 @@ ...@@ -304,7 +306,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Vrml 3D footprints shapes subdir:</property> <property name="label">Footprint 3D model path:</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
...@@ -450,7 +452,7 @@ ...@@ -450,7 +452,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
...@@ -459,92 +461,189 @@ ...@@ -459,92 +461,189 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">3</property>
<object class="wxRadioBox" expanded="1"> <object class="wxBoxSizer" 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="choices">&quot;Inch&quot; &quot;mm&quot; &quot;Meter&quot;</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">Units:</property>
<property name="majorDimension">1</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="minimum_size"></property>
<property name="moveable">1</property> <property name="name">bSizer4</property>
<property name="name">m_rbSelectUnits</property> <property name="orient">wxVERTICAL</property>
<property name="pane_border">1</property> <property name="permission">none</property>
<property name="pane_position"></property> <object class="sizeritem" expanded="1">
<property name="pane_size"></property> <property name="border">5</property>
<property name="permission">protected</property> <property name="flag">wxALL</property>
<property name="pin_button">1</property> <property name="proportion">0</property>
<property name="pos"></property> <object class="wxCheckBox" expanded="1">
<property name="resize">Resizable</property> <property name="BottomDockable">1</property>
<property name="selection">0</property> <property name="LeftDockable">1</property>
<property name="show">1</property> <property name="RightDockable">1</property>
<property name="size"></property> <property name="TopDockable">1</property>
<property name="style">wxRA_SPECIFY_COLS</property> <property name="aui_layer"></property>
<property name="subclass"></property> <property name="aui_name"></property>
<property name="toolbar_pane">0</property> <property name="aui_position"></property>
<property name="tooltip"></property> <property name="aui_row"></property>
<property name="validator_data_type"></property> <property name="best_size"></property>
<property name="validator_style">wxFILTER_NONE</property> <property name="bg"></property>
<property name="validator_type">wxDefaultValidator</property> <property name="caption"></property>
<property name="validator_variable"></property> <property name="caption_visible">1</property>
<property name="window_extra_style"></property> <property name="center_pane">0</property>
<property name="window_name"></property> <property name="checked">1</property>
<property name="window_style"></property> <property name="close_button">1</property>
<event name="OnChar"></event> <property name="context_help"></property>
<event name="OnEnterWindow"></event> <property name="context_menu">1</property>
<event name="OnEraseBackground"></event> <property name="default_pane">0</property>
<event name="OnKeyDown"></event> <property name="dock">Dock</property>
<event name="OnKeyUp"></event> <property name="dock_fixed">0</property>
<event name="OnKillFocus"></event> <property name="docking">Left</property>
<event name="OnLeaveWindow"></event> <property name="enabled">1</property>
<event name="OnLeftDClick"></event> <property name="fg"></property>
<event name="OnLeftDown"></event> <property name="floatable">1</property>
<event name="OnLeftUp"></event> <property name="font"></property>
<event name="OnMiddleDClick"></event> <property name="gripper">0</property>
<event name="OnMiddleDown"></event> <property name="hidden">0</property>
<event name="OnMiddleUp"></event> <property name="id">wxID_ANY</property>
<event name="OnMotion"></event> <property name="label">Copy 3D model files to 3D model path</property>
<event name="OnMouseEvents"></event> <property name="max_size"></property>
<event name="OnMouseWheel"></event> <property name="maximize_button">0</property>
<event name="OnPaint"></event> <property name="maximum_size"></property>
<event name="OnRadioBox"></event> <property name="min_size"></property>
<event name="OnRightDClick"></event> <property name="minimize_button">0</property>
<event name="OnRightDown"></event> <property name="minimum_size"></property>
<event name="OnRightUp"></event> <property name="moveable">1</property>
<event name="OnSetFocus"></event> <property name="name">m_cbCopyFiles</property>
<event name="OnSize"></event> <property name="pane_border">1</property>
<event name="OnUpdateUI"></event> <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"></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="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">1</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">ID_USE_ABS_PATH</property>
<property name="label">Use absolute paths to model files in board VRML file</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_cbUseAbsolutePaths</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"></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> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
...@@ -565,7 +664,7 @@ ...@@ -565,7 +664,7 @@
<property name="caption"></property> <property name="caption"></property>
<property name="caption_visible">1</property> <property name="caption_visible">1</property>
<property name="center_pane">0</property> <property name="center_pane">0</property>
<property name="choices">&quot;Copy 3D Shapes Files in Subdir&quot; &quot;Use Absolute Path in Vrml File &quot;</property> <property name="choices">&quot;Inch&quot; &quot;mm&quot; &quot;Meter&quot;</property>
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
...@@ -580,7 +679,7 @@ ...@@ -580,7 +679,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">3D Shapes Files Option:</property> <property name="label">Units:</property>
<property name="majorDimension">1</property> <property name="majorDimension">1</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
...@@ -589,7 +688,7 @@ ...@@ -589,7 +688,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_rb3DFilesOption</property> <property name="name">m_rbSelectUnits</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
...@@ -597,7 +696,7 @@ ...@@ -597,7 +696,7 @@
<property name="pin_button">1</property> <property name="pin_button">1</property>
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="selection">1</property> <property name="selection">0</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property> <property name="style">wxRA_SPECIFY_COLS</property>
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012) // C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -23,6 +23,7 @@ class DIALOG_SHIM; ...@@ -23,6 +23,7 @@ class DIALOG_SHIM;
#include <wx/filepicker.h> #include <wx/filepicker.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/radiobox.h> #include <wx/radiobox.h>
#include <wx/statline.h> #include <wx/statline.h>
#include <wx/button.h> #include <wx/button.h>
...@@ -38,12 +39,18 @@ class DIALOG_EXPORT_3DFILE_BASE : public DIALOG_SHIM ...@@ -38,12 +39,18 @@ class DIALOG_EXPORT_3DFILE_BASE : public DIALOG_SHIM
private: private:
protected: protected:
enum
{
ID_USE_ABS_PATH = 1000
};
wxStaticText* m_staticText1; wxStaticText* m_staticText1;
wxFilePickerCtrl* m_filePicker; wxFilePickerCtrl* m_filePicker;
wxStaticText* m_staticText3; wxStaticText* m_staticText3;
wxTextCtrl* m_SubdirNameCtrl; wxTextCtrl* m_SubdirNameCtrl;
wxCheckBox* m_cbCopyFiles;
wxCheckBox* m_cbUseAbsolutePaths;
wxRadioBox* m_rbSelectUnits; wxRadioBox* m_rbSelectUnits;
wxRadioBox* m_rb3DFilesOption;
wxStaticLine* m_staticline1; wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer1; wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1OK;
...@@ -56,7 +63,7 @@ class DIALOG_EXPORT_3DFILE_BASE : public DIALOG_SHIM ...@@ -56,7 +63,7 @@ class DIALOG_EXPORT_3DFILE_BASE : public DIALOG_SHIM
public: public:
DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Vrml Board Export Options:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 370,252 ), 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( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EXPORT_3DFILE_BASE(); ~DIALOG_EXPORT_3DFILE_BASE();
}; };
......
...@@ -59,11 +59,6 @@ ...@@ -59,11 +59,6 @@
// offset for art layers, mm (silk, paste, etc) // offset for art layers, mm (silk, paste, etc)
#define ART_OFFSET 0.025 #define ART_OFFSET 0.025
/* helper function:
* some characters cannot be used in names,
* this function change them to "_"
*/
static void ChangeIllegalCharacters( wxString& aFileName, bool aDirSepIsIllegal );
struct VRML_COLOR struct VRML_COLOR
{ {
...@@ -122,6 +117,7 @@ struct VRML_COLOR ...@@ -122,6 +117,7 @@ struct VRML_COLOR
} }
}; };
enum VRML_COLOR_INDEX enum VRML_COLOR_INDEX
{ {
VRML_COLOR_PCB = 0, VRML_COLOR_PCB = 0,
...@@ -139,10 +135,9 @@ private: ...@@ -139,10 +135,9 @@ private:
VRML_COLOR colors[VRML_COLOR_LAST]; VRML_COLOR colors[VRML_COLOR_LAST];
int iMaxSeg; // max. sides to a small circle int iMaxSeg; // max. sides to a small circle
double arcMinLen, arcMaxLen; // min and max lengths of an arc chord double arcMinLen, arcMaxLen; // min and max lengths of an arc chord
public: public:
VRML_LAYER holes; VRML_LAYER holes;
VRML_LAYER board; VRML_LAYER board;
VRML_LAYER top_copper; VRML_LAYER top_copper;
...@@ -185,7 +180,7 @@ public: ...@@ -185,7 +180,7 @@ public:
colors[ VRML_COLOR_SILK ] = VRML_COLOR( .9, .9, .9, .9, .9, .9, colors[ VRML_COLOR_SILK ] = VRML_COLOR( .9, .9, .9, .9, .9, .9,
0, 0, 0, 1, 0, 0.2 ); 0, 0, 0, 1, 0, 0.2 );
// pad silver // pad silver
colors[ VRML_COLOR_TIN ] = VRML_COLOR( .749, .756, .761, .749, .756, .761, colors[ VRML_COLOR_TIN ] = VRML_COLOR( .749, .756, .761, .749, .756, .761,
0, 0, 0, 0.8, 0, 0.8 ); 0, 0, 0, 0.8, 0, 0.8 );
precision = 5; precision = 5;
...@@ -268,6 +263,7 @@ public: ...@@ -268,6 +263,7 @@ public:
// static var. for dealing with text // static var. for dealing with text
static MODEL_VRML* model_vrml; static MODEL_VRML* model_vrml;
// select the VRML layer object to draw on; return true if // select the VRML layer object to draw on; return true if
// a layer has been selected. // a layer has been selected.
static bool GetLayer( MODEL_VRML& aModel, LAYER_NUM layer, VRML_LAYER** vlayer ) static bool GetLayer( MODEL_VRML& aModel, LAYER_NUM layer, VRML_LAYER** vlayer )
...@@ -299,8 +295,8 @@ static bool GetLayer( MODEL_VRML& aModel, LAYER_NUM layer, VRML_LAYER** vlayer ) ...@@ -299,8 +295,8 @@ static bool GetLayer( MODEL_VRML& aModel, LAYER_NUM layer, VRML_LAYER** vlayer )
static void write_triangle_bag( std::ofstream& output_file, VRML_COLOR& color, static void write_triangle_bag( std::ofstream& output_file, VRML_COLOR& color,
VRML_LAYER* layer, bool plane, bool top, VRML_LAYER* layer, bool plane, bool top,
double top_z, double bottom_z, int aPrecision ) double top_z, double bottom_z, int aPrecision )
{ {
/* A lot of nodes are not required, but blender sometimes chokes /* A lot of nodes are not required, but blender sometimes chokes
* without them */ * without them */
...@@ -405,27 +401,26 @@ static void write_layers( MODEL_VRML& aModel, std::ofstream& output_file, BOARD* ...@@ -405,27 +401,26 @@ static void write_layers( MODEL_VRML& aModel, std::ofstream& output_file, BOARD*
double brdz = aModel.board_thickness / 2.0 double brdz = aModel.board_thickness / 2.0
- ( Millimeter2iu( ART_OFFSET / 2.0 ) ) * aModel.scale; - ( Millimeter2iu( ART_OFFSET / 2.0 ) ) * aModel.scale;
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_PCB ), write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_PCB ),
&aModel.board, false, false, brdz, -brdz, aModel.precision ); &aModel.board, false, false, brdz, -brdz, aModel.precision );
// VRML_LAYER top_copper; // VRML_LAYER top_copper;
aModel.top_copper.Tesselate( &aModel.holes ); aModel.top_copper.Tesselate( &aModel.holes );
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TRACK ), write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TRACK ),
&aModel.top_copper, true, true, &aModel.top_copper, true, true,
aModel.GetLayerZ( F_Cu ), 0, aModel.precision ); aModel.GetLayerZ( F_Cu ), 0, aModel.precision );
// VRML_LAYER top_tin; // VRML_LAYER top_tin;
aModel.top_tin.Tesselate( &aModel.holes ); aModel.top_tin.Tesselate( &aModel.holes );
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ), write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ),
&aModel.top_tin, true, true, &aModel.top_tin, true, true,
aModel.GetLayerZ( F_Cu ) aModel.GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale,
+ Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale, 0, aModel.precision );
0, aModel.precision );
// VRML_LAYER bot_copper; // VRML_LAYER bot_copper;
aModel.bot_copper.Tesselate( &aModel.holes ); aModel.bot_copper.Tesselate( &aModel.holes );
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TRACK ), write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TRACK ),
&aModel.bot_copper, true, false, &aModel.bot_copper, true, false,
aModel.GetLayerZ( B_Cu ), 0, aModel.precision ); aModel.GetLayerZ( B_Cu ), 0, aModel.precision );
// VRML_LAYER bot_tin; // VRML_LAYER bot_tin;
aModel.bot_tin.Tesselate( &aModel.holes ); aModel.bot_tin.Tesselate( &aModel.holes );
...@@ -439,23 +434,19 @@ static void write_layers( MODEL_VRML& aModel, std::ofstream& output_file, BOARD* ...@@ -439,23 +434,19 @@ static void write_layers( MODEL_VRML& aModel, std::ofstream& output_file, BOARD*
aModel.plated_holes.Tesselate( NULL, true ); aModel.plated_holes.Tesselate( NULL, true );
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ), write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ),
&aModel.plated_holes, false, false, &aModel.plated_holes, false, false,
aModel.GetLayerZ( F_Cu ) aModel.GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale,
+ Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale, aModel.GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale,
aModel.GetLayerZ( B_Cu )
- Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale,
aModel.precision ); aModel.precision );
// VRML_LAYER top_silk; // VRML_LAYER top_silk;
aModel.top_silk.Tesselate( &aModel.holes ); aModel.top_silk.Tesselate( &aModel.holes );
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_SILK ), write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_SILK ), &aModel.top_silk,
&aModel.top_silk, true, true, true, true, aModel.GetLayerZ( F_SilkS ), 0, aModel.precision );
aModel.GetLayerZ( F_SilkS ), 0, aModel.precision );
// VRML_LAYER bot_silk; // VRML_LAYER bot_silk;
aModel.bot_silk.Tesselate( &aModel.holes ); aModel.bot_silk.Tesselate( &aModel.holes );
write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_SILK ), write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_SILK ), &aModel.bot_silk,
&aModel.bot_silk, true, false, true, false, aModel.GetLayerZ( B_SilkS ), 0, aModel.precision );
aModel.GetLayerZ( B_SilkS ), 0, aModel.precision );
} }
...@@ -498,8 +489,8 @@ static void compute_layer_Zs( MODEL_VRML& aModel, BOARD* pcb ) ...@@ -498,8 +489,8 @@ static void compute_layer_Zs( MODEL_VRML& aModel, BOARD* pcb )
static void export_vrml_line( MODEL_VRML& aModel, LAYER_NUM layer, static void export_vrml_line( MODEL_VRML& aModel, LAYER_NUM layer,
double startx, double starty, double startx, double starty,
double endx, double endy, double width ) double endx, double endy, double width )
{ {
VRML_LAYER* vlayer; VRML_LAYER* vlayer;
...@@ -523,8 +514,8 @@ static void export_vrml_line( MODEL_VRML& aModel, LAYER_NUM layer, ...@@ -523,8 +514,8 @@ static void export_vrml_line( MODEL_VRML& aModel, LAYER_NUM layer,
static void export_vrml_circle( MODEL_VRML& aModel, LAYER_NUM layer, static void export_vrml_circle( MODEL_VRML& aModel, LAYER_NUM layer,
double startx, double starty, double startx, double starty,
double endx, double endy, double width ) double endx, double endy, double width )
{ {
VRML_LAYER* vlayer; VRML_LAYER* vlayer;
...@@ -554,9 +545,9 @@ static void export_vrml_circle( MODEL_VRML& aModel, LAYER_NUM layer, ...@@ -554,9 +545,9 @@ static void export_vrml_circle( MODEL_VRML& aModel, LAYER_NUM layer,
static void export_vrml_arc( MODEL_VRML& aModel, LAYER_NUM layer, static void export_vrml_arc( MODEL_VRML& aModel, LAYER_NUM layer,
double centerx, double centery, double centerx, double centery,
double arc_startx, double arc_starty, double arc_startx, double arc_starty,
double width, double arc_angle ) double width, double arc_angle )
{ {
VRML_LAYER* vlayer; VRML_LAYER* vlayer;
...@@ -569,8 +560,7 @@ static void export_vrml_arc( MODEL_VRML& aModel, LAYER_NUM layer, ...@@ -569,8 +560,7 @@ static void export_vrml_arc( MODEL_VRML& aModel, LAYER_NUM layer,
centery = -centery; centery = -centery;
arc_starty = -arc_starty; arc_starty = -arc_starty;
if( !vlayer->AddArc( centerx, centery, arc_startx, arc_starty, if( !vlayer->AddArc( centerx, centery, arc_startx, arc_starty, width, arc_angle, false ) )
width, arc_angle, false ) )
throw( std::runtime_error( vlayer->GetError() ) ); throw( std::runtime_error( vlayer->GetError() ) );
} }
...@@ -593,11 +583,11 @@ static void export_vrml_drawsegment( MODEL_VRML& aModel, DRAWSEGMENT* drawseg ) ...@@ -593,11 +583,11 @@ static void export_vrml_drawsegment( MODEL_VRML& aModel, DRAWSEGMENT* drawseg )
{ {
case S_ARC: case S_ARC:
export_vrml_arc( aModel, layer, export_vrml_arc( aModel, layer,
(double) drawseg->GetCenter().x, (double) drawseg->GetCenter().x,
(double) drawseg->GetCenter().y, (double) drawseg->GetCenter().y,
(double) drawseg->GetArcStart().x, (double) drawseg->GetArcStart().x,
(double) drawseg->GetArcStart().y, (double) drawseg->GetArcStart().y,
w, drawseg->GetAngle() / 10 ); w, drawseg->GetAngle() / 10 );
break; break;
case S_CIRCLE: case S_CIRCLE:
...@@ -620,9 +610,9 @@ static void vrml_text_callback( int x0, int y0, int xf, int yf ) ...@@ -620,9 +610,9 @@ static void vrml_text_callback( int x0, int y0, int xf, int yf )
double scale = model_vrml->scale; double scale = model_vrml->scale;
export_vrml_line( *model_vrml, s_text_layer, export_vrml_line( *model_vrml, s_text_layer,
x0 * scale, y0 * scale, x0 * scale, y0 * scale,
xf * scale, yf * scale, xf * scale, yf * scale,
s_text_width * scale ); s_text_width * scale );
} }
...@@ -708,8 +698,7 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb ) ...@@ -708,8 +698,7 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb )
// Build a polygon from edge cut items // Build a polygon from edge cut items
wxString msg; wxString msg;
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
allLayerHoles, &msg ) )
{ {
msg << wxT( "\n\n" ) << msg << wxT( "\n\n" ) <<
_( "Unable to calculate the board outlines;\n" _( "Unable to calculate the board outlines;\n"
...@@ -744,7 +733,7 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb ) ...@@ -744,7 +733,7 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb )
break; break;
aModel.board.AddVertex( seg, bufferPcbOutlines[i].x * scale, aModel.board.AddVertex( seg, bufferPcbOutlines[i].x * scale,
-(bufferPcbOutlines[i].y * scale ) ); -(bufferPcbOutlines[i].y * scale ) );
++i; ++i;
} }
...@@ -776,7 +765,7 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb ) ...@@ -776,7 +765,7 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb )
break; break;
aModel.holes.AddVertex( seg, allLayerHoles[i].x * scale, aModel.holes.AddVertex( seg, allLayerHoles[i].x * scale,
-(allLayerHoles[i].y * scale ) ); -( allLayerHoles[i].y * scale ) );
++i; ++i;
} }
...@@ -788,9 +777,9 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb ) ...@@ -788,9 +777,9 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb )
static void export_round_padstack( MODEL_VRML& aModel, BOARD* pcb, static void export_round_padstack( MODEL_VRML& aModel, BOARD* pcb,
double x, double y, double r, double x, double y, double r,
LAYER_NUM bottom_layer, LAYER_NUM top_layer, LAYER_NUM bottom_layer, LAYER_NUM top_layer,
double hole ) double hole )
{ {
LAYER_NUM layer = top_layer; LAYER_NUM layer = top_layer;
bool thru = true; bool thru = true;
...@@ -809,7 +798,7 @@ static void export_round_padstack( MODEL_VRML& aModel, BOARD* pcb, ...@@ -809,7 +798,7 @@ static void export_round_padstack( MODEL_VRML& aModel, BOARD* pcb,
aModel.bot_copper.AddCircle( x, -y, r ); aModel.bot_copper.AddCircle( x, -y, r );
if( hole > 0 && !thru ) if( hole > 0 && !thru )
aModel.bot_copper.AddCircle( x, -y, hole, true ); aModel.bot_copper.AddCircle( x, -y, hole, true );
} }
else if( layer == F_Cu ) else if( layer == F_Cu )
...@@ -859,11 +848,11 @@ static void export_vrml_tracks( MODEL_VRML& aModel, BOARD* pcb ) ...@@ -859,11 +848,11 @@ static void export_vrml_tracks( MODEL_VRML& aModel, BOARD* pcb )
} }
else if( track->GetLayer() == B_Cu || track->GetLayer() == F_Cu ) else if( track->GetLayer() == B_Cu || track->GetLayer() == F_Cu )
export_vrml_line( aModel, track->GetLayer(), export_vrml_line( aModel, track->GetLayer(),
track->GetStart().x * aModel.scale, track->GetStart().x * aModel.scale,
track->GetStart().y * aModel.scale, track->GetStart().y * aModel.scale,
track->GetEnd().x * aModel.scale, track->GetEnd().x * aModel.scale,
track->GetEnd().y * aModel.scale, track->GetEnd().y * aModel.scale,
track->GetWidth() * aModel.scale ); track->GetWidth() * aModel.scale );
} }
} }
...@@ -888,8 +877,8 @@ static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb ) ...@@ -888,8 +877,8 @@ static void export_vrml_zones( MODEL_VRML& aModel, BOARD* aPcb )
zone->SetFillMode( 0 ); // use filled polygons zone->SetFillMode( 0 ); // use filled polygons
zone->BuildFilledSolidAreasPolygons( aPcb ); zone->BuildFilledSolidAreasPolygons( aPcb );
} }
const CPOLYGONS_LIST& poly = zone->GetFilledPolysList();
const CPOLYGONS_LIST& poly = zone->GetFilledPolysList();
int nvert = poly.GetCornersCount(); int nvert = poly.GetCornersCount();
int i = 0; int i = 0;
...@@ -941,11 +930,11 @@ static void export_vrml_text_module( TEXTE_MODULE* module ) ...@@ -941,11 +930,11 @@ static void export_vrml_text_module( TEXTE_MODULE* module )
model_vrml->s_text_width = module->GetThickness(); model_vrml->s_text_width = module->GetThickness();
DrawGraphicText( NULL, NULL, module->GetTextPosition(), BLACK, DrawGraphicText( NULL, NULL, module->GetTextPosition(), BLACK,
module->GetShownText(), module->GetDrawRotation(), size, module->GetShownText(), module->GetDrawRotation(), size,
module->GetHorizJustify(), module->GetVertJustify(), module->GetHorizJustify(), module->GetVertJustify(),
module->GetThickness(), module->IsItalic(), module->GetThickness(), module->IsItalic(),
true, true,
vrml_text_callback ); vrml_text_callback );
} }
} }
...@@ -1053,45 +1042,46 @@ static void export_vrml_padshape( MODEL_VRML& aModel, VRML_LAYER* aTinLayer, D_P ...@@ -1053,45 +1042,46 @@ static void export_vrml_padshape( MODEL_VRML& aModel, VRML_LAYER* aTinLayer, D_P
pad_dy = 0; pad_dy = 0;
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
{
double coord[8] =
{ {
double coord[8] = -pad_w + pad_dy, -pad_h - pad_dx,
{ -pad_w - pad_dy, pad_h + pad_dx,
-pad_w + pad_dy, -pad_h - pad_dx, +pad_w - pad_dy, -pad_h + pad_dx,
-pad_w - pad_dy, pad_h + pad_dx, +pad_w + pad_dy, pad_h - pad_dx
+pad_w - pad_dy, -pad_h + pad_dx, };
+pad_w + pad_dy, pad_h - pad_dx
};
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
RotatePoint( &coord[i * 2], &coord[i * 2 + 1], aPad->GetOrientation() ); RotatePoint( &coord[i * 2], &coord[i * 2 + 1], aPad->GetOrientation() );
coord[i * 2] += pad_x; coord[i * 2] += pad_x;
coord[i * 2 + 1] += pad_y; coord[i * 2 + 1] += pad_y;
} }
int lines; int lines;
lines = aTinLayer->NewContour(); lines = aTinLayer->NewContour();
if( lines < 0 ) if( lines < 0 )
throw( std::runtime_error( aTinLayer->GetError() ) ); throw( std::runtime_error( aTinLayer->GetError() ) );
if( !aTinLayer->AddVertex( lines, coord[0], -coord[1] ) ) if( !aTinLayer->AddVertex( lines, coord[0], -coord[1] ) )
throw( std::runtime_error( aTinLayer->GetError() ) ); throw( std::runtime_error( aTinLayer->GetError() ) );
if( !aTinLayer->AddVertex( lines, coord[4], -coord[5] ) ) if( !aTinLayer->AddVertex( lines, coord[4], -coord[5] ) )
throw( std::runtime_error( aTinLayer->GetError() ) ); throw( std::runtime_error( aTinLayer->GetError() ) );
if( !aTinLayer->AddVertex( lines, coord[6], -coord[7] ) ) if( !aTinLayer->AddVertex( lines, coord[6], -coord[7] ) )
throw( std::runtime_error( aTinLayer->GetError() ) ); throw( std::runtime_error( aTinLayer->GetError() ) );
if( !aTinLayer->AddVertex( lines, coord[2], -coord[3] ) ) if( !aTinLayer->AddVertex( lines, coord[2], -coord[3] ) )
throw( std::runtime_error( aTinLayer->GetError() ) ); throw( std::runtime_error( aTinLayer->GetError() ) );
if( !aTinLayer->EnsureWinding( lines, false ) )
throw( std::runtime_error( aTinLayer->GetError() ) );
if( !aTinLayer->EnsureWinding( lines, false ) )
throw( std::runtime_error( aTinLayer->GetError() ) );
}
break; break;
}
default: default:
break; break;
...@@ -1103,9 +1093,9 @@ static void export_vrml_pad( MODEL_VRML& aModel, BOARD* pcb, D_PAD* aPad ) ...@@ -1103,9 +1093,9 @@ static void export_vrml_pad( MODEL_VRML& aModel, BOARD* pcb, D_PAD* aPad )
{ {
double hole_drill_w = (double) aPad->GetDrillSize().x * aModel.scale / 2.0; double hole_drill_w = (double) aPad->GetDrillSize().x * aModel.scale / 2.0;
double hole_drill_h = (double) aPad->GetDrillSize().y * aModel.scale / 2.0; double hole_drill_h = (double) aPad->GetDrillSize().y * aModel.scale / 2.0;
double hole_drill = std::min( hole_drill_w, hole_drill_h ); double hole_drill = std::min( hole_drill_w, hole_drill_h );
double hole_x = aPad->GetPosition().x * aModel.scale; double hole_x = aPad->GetPosition().x * aModel.scale;
double hole_y = aPad->GetPosition().y * aModel.scale; double hole_y = aPad->GetPosition().y * aModel.scale;
// Export the hole on the edge layer // Export the hole on the edge layer
if( hole_drill > 0 ) if( hole_drill > 0 )
...@@ -1119,7 +1109,7 @@ static void export_vrml_pad( MODEL_VRML& aModel, BOARD* pcb, D_PAD* aPad ) ...@@ -1119,7 +1109,7 @@ static void export_vrml_pad( MODEL_VRML& aModel, BOARD* pcb, D_PAD* aPad )
{ {
// Oblong hole (slot) // Oblong hole (slot)
aModel.holes.AddSlot( hole_x, -hole_y, hole_drill_w * 2.0, hole_drill_h * 2.0, aModel.holes.AddSlot( hole_x, -hole_y, hole_drill_w * 2.0, hole_drill_h * 2.0,
aPad->GetOrientation()/10.0, true, pth ); aPad->GetOrientation()/10.0, true, pth );
if( pth ) if( pth )
aModel.plated_holes.AddSlot( hole_x, -hole_y, aModel.plated_holes.AddSlot( hole_x, -hole_y,
...@@ -1194,9 +1184,9 @@ static void compose_quat( double q1[4], double q2[4], double qr[4] ) ...@@ -1194,9 +1184,9 @@ static void compose_quat( double q1[4], double q2[4], double qr[4] )
static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule, static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule,
std::ofstream& aOutputFile, std::ofstream& aOutputFile, double aVRMLModelsToBiu,
double aVRMLModelsToBiu, bool aExport3DFiles, bool aUseRelativePaths,
bool aExport3DFiles, const wxString& a3D_Subdir ) const wxString& a3D_Subdir )
{ {
// Reference and value // Reference and value
if( aModule->Reference().IsVisible() ) if( aModule->Reference().IsVisible() )
...@@ -1236,119 +1226,121 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule ...@@ -1236,119 +1226,121 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
if( !vrmlm->Is3DType( S3D_MASTER::FILE3D_VRML ) ) if( !vrmlm->Is3DType( S3D_MASTER::FILE3D_VRML ) )
continue; continue;
wxString fname = vrmlm->GetShape3DFullFilename(); wxFileName modelFileName = vrmlm->GetShape3DFullFilename();
wxFileName destFileName( a3D_Subdir, modelFileName.GetName(), modelFileName.GetExt() );
fname.Replace( wxT( "\\" ), wxT( "/" ) ); // Only copy VRML files.
wxString source_fname = fname; if( modelFileName.FileExists() && modelFileName.GetExt() == wxT( "wrl" ) )
if( aExport3DFiles )
{ {
// Change illegal characters in filenames if( aExport3DFiles )
ChangeIllegalCharacters( fname, true ); {
fname = a3D_Subdir + wxT( "/" ) + fname; wxDateTime srcModTime = modelFileName.GetModificationTime();
wxDateTime destModTime = srcModTime;
if( !wxFileExists( fname ) )
wxCopyFile( source_fname, fname );
}
/* Calculate 3D shape rotation:
* this is the rotation parameters, with an additional 180 deg rotation
* for footprints that are flipped
* When flipped, axis rotation is the horizontal axis (X axis)
*/
double rotx = -vrmlm->m_MatRotation.x;
double roty = -vrmlm->m_MatRotation.y;
double rotz = -vrmlm->m_MatRotation.z;
if( isFlipped ) destModTime.SetToCurrent();
{
rotx += 180.0;
NEGATE( roty );
NEGATE( rotz );
}
// Do some quaternion munching if( destFileName.FileExists() )
double q1[4], q2[4], rot[4]; destModTime = destFileName.GetModificationTime();
build_quat( 1, 0, 0, DEG2RAD( rotx ), q1 );
build_quat( 0, 1, 0, DEG2RAD( roty ), q2 );
compose_quat( q1, q2, q1 );
build_quat( 0, 0, 1, DEG2RAD( rotz ), q2 );
compose_quat( q1, q2, q1 );
// Note here aModule->GetOrientation() is in 0.1 degrees, // Only copy the file if it doesn't exist or has been modified. This eliminates
// so module rotation has to be converted to radians // the redundant file copies.
build_quat( 0, 0, 1, DECIDEG2RAD( aModule->GetOrientation() ), q2 ); if( srcModTime != destModTime )
compose_quat( q1, q2, q1 ); {
from_quat( q1, rot ); wxLogDebug( wxT( "Copying 3D model %s to %s." ),
GetChars( modelFileName.GetFullPath() ),
GetChars( destFileName.GetFullPath() ) );
aOutputFile << "Transform {\n"; if( !wxCopyFile( modelFileName.GetFullPath(), destFileName.GetFullPath() ) )
continue;
}
}
// A null rotation would fail the acos! /* Calculate 3D shape rotation:
if( rot[3] != 0.0 ) * this is the rotation parameters, with an additional 180 deg rotation
{ * for footprints that are flipped
aOutputFile << " rotation " << std::setprecision( 3 ); * When flipped, axis rotation is the horizontal axis (X axis)
aOutputFile << rot[0] << " " << rot[1] << " " << rot[2] << " " << rot[3] << "\n"; */
} double rotx = -vrmlm->m_MatRotation.x;
double roty = -vrmlm->m_MatRotation.y;
double rotz = -vrmlm->m_MatRotation.z;
// adjust 3D shape local offset position if( isFlipped )
// they are given in inch, so they are converted in board IU. {
double offsetx = vrmlm->m_MatPosition.x * IU_PER_MILS * 1000.0; rotx += 180.0;
double offsety = vrmlm->m_MatPosition.y * IU_PER_MILS * 1000.0; NEGATE( roty );
double offsetz = vrmlm->m_MatPosition.z * IU_PER_MILS * 1000.0; NEGATE( rotz );
}
if( isFlipped ) // Do some quaternion munching
NEGATE( offsetz ); double q1[4], q2[4], rot[4];
else // In normal mode, Y axis is reversed in Pcbnew. build_quat( 1, 0, 0, DEG2RAD( rotx ), q1 );
NEGATE( offsety ); build_quat( 0, 1, 0, DEG2RAD( roty ), q2 );
compose_quat( q1, q2, q1 );
build_quat( 0, 0, 1, DEG2RAD( rotz ), q2 );
compose_quat( q1, q2, q1 );
RotatePoint( &offsetx, &offsety, aModule->GetOrientation() ); // Note here aModule->GetOrientation() is in 0.1 degrees,
// so module rotation has to be converted to radians
build_quat( 0, 0, 1, DECIDEG2RAD( aModule->GetOrientation() ), q2 );
compose_quat( q1, q2, q1 );
from_quat( q1, rot );
aOutputFile << " translation " << std::setprecision( aModel.precision ); aOutputFile << "Transform {\n";
aOutputFile << (( offsetx + aModule->GetPosition().x) * aModel.scale + aModel.tx ) << " ";
aOutputFile << ( -(offsety + aModule->GetPosition().y) * aModel.scale - aModel.ty ) << " ";
aOutputFile << ( (offsetz * aModel.scale ) + aModel.GetLayerZ( aModule->GetLayer() ) ) << "\n";
aOutputFile << " scale "; // A null rotation would fail the acos!
aOutputFile << ( vrmlm->m_MatScale.x * aVRMLModelsToBiu ) << " "; if( rot[3] != 0.0 )
aOutputFile << ( vrmlm->m_MatScale.y * aVRMLModelsToBiu ) << " "; {
aOutputFile << ( vrmlm->m_MatScale.z * aVRMLModelsToBiu ) << "\n"; aOutputFile << " rotation " << std::setprecision( 3 );
aOutputFile << rot[0] << " " << rot[1] << " " << rot[2] << " " << rot[3] << "\n";
}
if( fname.EndsWith( wxT( "x3d" ) ) ) // adjust 3D shape local offset position
{ // they are given in inch, so they are converted in board IU.
X3D_MODEL_PARSER* parser = new X3D_MODEL_PARSER( vrmlm ); double offsetx = vrmlm->m_MatPosition.x * IU_PER_MILS * 1000.0;
double offsety = vrmlm->m_MatPosition.y * IU_PER_MILS * 1000.0;
double offsetz = vrmlm->m_MatPosition.z * IU_PER_MILS * 1000.0;
if( isFlipped )
NEGATE( offsetz );
else // In normal mode, Y axis is reversed in Pcbnew.
NEGATE( offsety );
RotatePoint( &offsetx, &offsety, aModule->GetOrientation() );
aOutputFile << " translation " << std::setprecision( aModel.precision );
aOutputFile << ( ( offsetx + aModule->GetPosition().x ) *
aModel.scale + aModel.tx ) << " ";
aOutputFile << ( -(offsety + aModule->GetPosition().y) *
aModel.scale - aModel.ty ) << " ";
aOutputFile << ( (offsetz * aModel.scale ) +
aModel.GetLayerZ( aModule->GetLayer() ) ) << "\n";
aOutputFile << " scale ";
aOutputFile << ( vrmlm->m_MatScale.x * aVRMLModelsToBiu ) << " ";
aOutputFile << ( vrmlm->m_MatScale.y * aVRMLModelsToBiu ) << " ";
aOutputFile << ( vrmlm->m_MatScale.z * aVRMLModelsToBiu ) << "\n";
aOutputFile << " children [\n Inline {\n url \"";
if( parser ) if( aUseRelativePaths )
{ {
// embed x3d model in vrml format wxFileName tmp = destFileName;
double vrml_to_x3d = aVRMLModelsToBiu; tmp.SetExt( wxT( "" ) );
parser->Load( fname, vrml_to_x3d ); tmp.SetName( wxT( "" ) );
tmp.RemoveLastDir();
try destFileName.MakeRelativeTo( tmp.GetPath() );
{
aOutputFile << " children [\n ";
aOutputFile << TO_UTF8( parser->VRML2_representation() ) << " ]\n";
aOutputFile << " }\n";
}
catch( const std::exception& e )
{
delete parser;
throw;
}
} }
}
else wxString fn = destFileName.GetFullPath();
{ fn.Replace( wxT( "\\" ), wxT( "/" ) );
aOutputFile << " children [\n Inline {\n url \""; aOutputFile << TO_UTF8( fn ) << "\"\n } ]\n";
aOutputFile << TO_UTF8( fname ) << "\"\n } ]\n";
aOutputFile << " }\n"; aOutputFile << " }\n";
} }
} }
} }
bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMtoWRMLunit,
double aMMtoWRMLunit, bool aExport3DFiles, bool aExport3DFiles, bool aUseRelativePaths,
const wxString& a3D_Subdir ) const wxString& a3D_Subdir )
{ {
wxString msg; wxString msg;
BOARD* pcb = GetBoard(); BOARD* pcb = GetBoard();
...@@ -1368,14 +1360,11 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, ...@@ -1368,14 +1360,11 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName,
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
// Begin with the usual VRML boilerplate // Begin with the usual VRML boilerplate
wxString name = aFullFileName; wxString fn = aFullFileName;
fn.Replace( wxT( "\\" ), wxT( "/" ) );
name.Replace( wxT( "\\" ), wxT( "/" ) );
ChangeIllegalCharacters( name, false );
output_file << "#VRML V2.0 utf8\n"; output_file << "#VRML V2.0 utf8\n";
output_file << "WorldInfo {\n"; output_file << "WorldInfo {\n";
output_file << " title \"" << TO_UTF8( name ) << " - Generated by Pcbnew\"\n"; output_file << " title \"" << TO_UTF8( fn ) << " - Generated by Pcbnew\"\n";
output_file << "}\n"; output_file << "}\n";
// Set the VRML world scale factor // Set the VRML world scale factor
...@@ -1387,8 +1376,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, ...@@ -1387,8 +1376,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName,
// XXX - NOTE: we should allow the user a GUI option to specify the offset // XXX - NOTE: we should allow the user a GUI option to specify the offset
EDA_RECT bbbox = pcb->ComputeBoundingBox(); EDA_RECT bbbox = pcb->ComputeBoundingBox();
model3d.SetOffset( -model3d.scale * bbbox.Centre().x, model3d.SetOffset( -model3d.scale * bbbox.Centre().x, model3d.scale * bbbox.Centre().y );
model3d.scale * bbbox.Centre().y );
output_file << " children [\n"; output_file << " children [\n";
...@@ -1417,9 +1405,8 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, ...@@ -1417,9 +1405,8 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName,
// Export footprints // Export footprints
for( MODULE* module = pcb->m_Modules; module != 0; module = module->Next() ) for( MODULE* module = pcb->m_Modules; module != 0; module = module->Next() )
export_vrml_module( model3d, pcb, module, output_file, export_vrml_module( model3d, pcb, module, output_file, wrml_3D_models_scaling_factor,
wrml_3D_models_scaling_factor, aExport3DFiles, aUseRelativePaths, a3D_Subdir );
aExport3DFiles, a3D_Subdir );
// write out the board and all layers // write out the board and all layers
write_layers( model3d, output_file, pcb ); write_layers( model3d, output_file, pcb );
...@@ -1443,17 +1430,3 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, ...@@ -1443,17 +1430,3 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName,
return ok; return ok;
} }
/*
* some characters cannot be used in filenames,
* this function change them to "_"
*/
static void ChangeIllegalCharacters( wxString& aFileName, bool aDirSepIsIllegal )
{
if( aDirSepIsIllegal )
aFileName.Replace( wxT( "/" ), wxT( "_" ) );
aFileName.Replace( wxT( " " ), wxT( "_" ) );
aFileName.Replace( wxT( ":" ), wxT( "_" ) );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment