Pcbnew: Added VRML export, from the patch sent by Lorenzo Marcantonio ( october 2009, 11)

This commit is contained in:
jean-pierre charras 2010-04-19 13:38:57 +02:00
parent 8dd76c53a6
commit b448040808
5 changed files with 76 additions and 66 deletions

View File

@ -6,7 +6,7 @@
#endif
#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2010-04-13 BZR 23xx)"
#define KICAD_BUILD_VERSION "(2010-04-19 BZR 23xx)"
#endif
#define VERSION_STABILITY "unstable"

View File

@ -20,14 +20,14 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow
bUpperSizer = new wxBoxSizer( wxVERTICAL );
bUpperSizer->SetMinSize( wxSize( 450,-1 ) );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Wrml main file filename:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Vrml main file filename:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
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_DEFAULT_STYLE|wxFLP_SAVE );
bUpperSizer->Add( m_filePicker, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Wrml 3D footprints shapes subdir:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Vrml 3D footprints shapes subdir:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->Wrap( -1 );
bUpperSizer->Add( m_staticText3, 0, wxTOP|wxRIGHT|wxLEFT, 5 );

View File

@ -35,7 +35,7 @@
<property name="size">370,252</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title"></property>
<property name="title">Vrml Board Export Options:</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
@ -96,7 +96,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Wrml main file filename:</property>
<property name="label">Vrml main file filename:</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticText1</property>
@ -200,7 +200,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Wrml 3D footprints shapes subdir:</property>
<property name="label">Vrml 3D footprints shapes subdir:</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticText3</property>

View File

@ -51,7 +51,7 @@ class DIALOG_EXPORT_3DFILE_BASE : public wxDialog
public:
DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, 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 Board Export Options:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 370,252 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EXPORT_3DFILE_BASE();
};

View File

@ -14,6 +14,73 @@
#include <cmath>
/* the dialog to create VRML files, derived from DIALOG_EXPORT_3DFILE_BASE,
* created by wxFormBuilder
*/
#include "dialog_export_3Dfiles_base.h" // the wxFormBuilder header file
#define OPTKEY_OUTPUT_UNIT wxT("VrmlExportUnit" )
#define OPTKEY_3DFILES_OPT wxT("VrmlExport3DShapeFilesOpt" )
class DIALOG_EXPORT_3DFILE : public DIALOG_EXPORT_3DFILE_BASE
{
private:
WinEDA_PcbFrame* m_parent;
wxConfig* m_config;
int m_unitsOpt; // to remember last option
int m_3DFilesOpt; // to remember last option
virtual void OnCancelClick( wxCommandEvent& event ){ EndModal( wxID_CANCEL ); }
virtual void OnOkClick( wxCommandEvent& event ){ EndModal( wxID_OK ); }
public:
DIALOG_EXPORT_3DFILE( WinEDA_PcbFrame* parent ) :
DIALOG_EXPORT_3DFILE_BASE( parent )
{
m_parent = parent;
m_config = wxGetApp().m_EDA_Config;
SetFocus();
m_config->Read( OPTKEY_OUTPUT_UNIT, &m_unitsOpt );
m_config->Read( OPTKEY_3DFILES_OPT, &m_3DFilesOpt );
m_rbSelectUnits->SetSelection(m_unitsOpt);
m_rb3DFilesOption->SetSelection(m_3DFilesOpt);
GetSizer()->SetSizeHints( this );
Centre();
}
~DIALOG_EXPORT_3DFILE()
{
m_unitsOpt = GetUnits( );
m_3DFilesOpt = Get3DFilesOption( );
m_config->Write( OPTKEY_OUTPUT_UNIT, m_unitsOpt );
m_config->Write( OPTKEY_3DFILES_OPT, m_3DFilesOpt );
};
void SetSubdir( const wxString & aDir )
{
m_SubdirNameCtrl->SetValue( aDir);
}
wxString GetSubdir( )
{
return m_SubdirNameCtrl->GetValue( );
}
wxFilePickerCtrl* FilePicker()
{
return m_filePicker;
}
int GetUnits( )
{
return m_unitsOpt = m_rbSelectUnits->GetSelection();
}
int Get3DFilesOption( )
{
return m_3DFilesOpt = m_rb3DFilesOption->GetSelection();
}
};
/* I use this a lot... */
static const double PI2 = M_PI / 2;
@ -1037,63 +1104,6 @@ static void write_and_empty_triangle_bag( FILE* output_file,
}
/* the dialog to create VRML files, derived from DIALOG_EXPORT_3DFILE_BASE,
* created by wxFormBuilder
*/
#include "dialog_export_3Dfiles_base.h" // the wxFormBuilder header file
class DIALOG_EXPORT_3DFILE : public DIALOG_EXPORT_3DFILE_BASE
{
private:
static int m_UnitsOpt; // to remember last option
static int m_3DFilesOpt; // to remember last option
virtual void OnCancelClick( wxCommandEvent& event ){ EndModal( wxID_CANCEL ); }
virtual void OnOkClick( wxCommandEvent& event ){ EndModal( wxID_OK ); }
public:
DIALOG_EXPORT_3DFILE( wxWindow* parent ) :
DIALOG_EXPORT_3DFILE_BASE( parent )
{
SetFocus();
m_rbSelectUnits->SetSelection(m_UnitsOpt);
m_rb3DFilesOption->SetSelection(m_3DFilesOpt);
GetSizer()->SetSizeHints( this );
Centre();
}
~DIALOG_EXPORT_3DFILE()
{
m_UnitsOpt = GetUnits( );
m_3DFilesOpt = Get3DFilesOption( );
};
void SetSubdir( const wxString & aDir )
{
m_SubdirNameCtrl->SetValue( aDir);
}
wxString GetSubdir( )
{
return m_SubdirNameCtrl->GetValue( );
}
wxFilePickerCtrl* FilePicker()
{
return m_filePicker;
}
int GetUnits( )
{
return m_UnitsOpt = m_rbSelectUnits->GetSelection();
}
int Get3DFilesOption( )
{
return m_3DFilesOpt = m_rb3DFilesOption->GetSelection();
}
};
int DIALOG_EXPORT_3DFILE::m_UnitsOpt = 0; // to remember last option
int DIALOG_EXPORT_3DFILE::m_3DFilesOpt = 1; // to remember last option
/**
* Function OnExportVRML
* will export the current BOARD to a VRML file.
@ -1186,8 +1196,8 @@ bool WinEDA_PcbFrame::ExportVRML_File( const wxString & aFullFileName,
* more easy for rotations...
*/
pcb->ComputeBoundaryBox();
double dx = board_scaling_factor * pcb->m_BoundaryBox.Centre().x;
double dy = board_scaling_factor * pcb->m_BoundaryBox.Centre().y;
double dx = board_scaling_factor * pcb->m_BoundaryBox.Centre().x * aScale;
double dy = board_scaling_factor * pcb->m_BoundaryBox.Centre().y * aScale;
fprintf(output_file, " translation %g %g 0.0\n", -dx, dy );
fprintf(output_file, " children [\n" );