More removal of open-coded dialog state saving.

This commit is contained in:
Jeff Young 2025-08-10 15:57:20 +01:00
parent 2909e984b6
commit 44bd29d592
26 changed files with 1690 additions and 2015 deletions

View File

@ -72,9 +72,6 @@ PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.netlist",
&m_PcbLastPath[LAST_PATH_NETLIST], "" ) );
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.step",
&m_PcbLastPath[LAST_PATH_STEP], "" ) );
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.idf",
&m_PcbLastPath[LAST_PATH_IDF], "" ) );
@ -84,15 +81,6 @@ PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.specctra_dsn",
&m_PcbLastPath[LAST_PATH_SPECCTRADSN], "" ) );
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.gencad",
&m_PcbLastPath[LAST_PATH_GENCAD], "" ) );
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.pos_files",
&m_PcbLastPath[LAST_PATH_POS_FILES], "" ) );
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.svg",
&m_PcbLastPath[LAST_PATH_SVG], "" ) );
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.plot",
&m_PcbLastPath[LAST_PATH_PLOT], "" ) );

View File

@ -50,16 +50,11 @@ enum LAST_PATH_TYPE : unsigned int
{
LAST_PATH_FIRST = 0,
LAST_PATH_NETLIST = LAST_PATH_FIRST,
LAST_PATH_STEP,
LAST_PATH_IDF,
LAST_PATH_VRML,
LAST_PATH_SPECCTRADSN,
LAST_PATH_GENCAD,
LAST_PATH_POS_FILES,
LAST_PATH_SVG,
LAST_PATH_PLOT,
LAST_PATH_2581,
LAST_PATH_ODBPP,
LAST_PATH_SIZE
};

View File

@ -156,10 +156,7 @@ DIALOG_DRC::~DIALOG_DRC()
g_lastIgnored.clear();
for( int ii = 0; ii < m_ignoredList->GetItemCount(); ++ii )
{
g_lastIgnored.push_back( { m_ignoredList->GetItemText( ii ),
m_ignoredList->GetItemData( ii ) } );
}
g_lastIgnored.push_back( { m_ignoredList->GetItemText( ii ), m_ignoredList->GetItemData( ii ) } );
m_markersTreeModel->DecRef();
m_unconnectedTreeModel->DecRef();
@ -178,8 +175,8 @@ void DIALOG_DRC::OnActivateDlg( wxActivateEvent& aEvent )
{
if( m_currentBoard != m_frame->GetBoard() )
{
// If m_currentBoard is not the current board, (for instance because a new board
// was loaded), close the dialog, because many pointers are now invalid in lists
// If m_currentBoard is not the current board, (for instance because a new board was loaded),
// close the dialog, because many pointers are now invalid in lists
SetReturnCode( wxID_CANCEL );
Close();
@ -616,8 +613,7 @@ void DIALOG_DRC::OnDRCItemDClick( wxDataViewEvent& aEvent )
Show( false );
}
// Do not skip aEvent here: this is not useful, and Pcbnew crashes
// if skipped (at least on Windows)
// Do not skip aEvent here: this is not useful, and Pcbnew crashes if skipped (at least on MSW)
}

View File

@ -109,14 +109,14 @@ int BOARD_EDITOR_CONTROL::ExportIDF( const TOOL_EVENT& aEvent )
if( dlg.GetSetBoardReferencePoint() )
{
BOX2I bbox = board->GetBoardEdgesBoundingBox();
aXRef = bbox.Centre().x * pcbIUScale.MM_PER_IU;
aYRef = bbox.Centre().y * pcbIUScale.MM_PER_IU;
aXRef = dlg.GetXRefMM();
aYRef = dlg.GetYRefMM();
}
else
{
aXRef = dlg.GetXRefMM();
aYRef = dlg.GetYRefMM();
BOX2I bbox = board->GetBoardEdgesBoundingBox();
aXRef = bbox.Centre().x * pcbIUScale.MM_PER_IU;
aYRef = bbox.Centre().y * pcbIUScale.MM_PER_IU;
}
wxString fullFilename = dlg.FilePicker()->GetPath();

View File

@ -30,7 +30,6 @@
#include <pgm_base.h>
#include <progress_reporter.h>
#include <project.h>
#include <project/board_project_settings.h>
#include <project/project_file.h>
#include <settings/settings_manager.h>
#include <widgets/std_bitmap_button.h>
@ -49,7 +48,6 @@
#include <wx/tarstrm.h>
#include <wx/zstream.h>
static wxString s_oemColumn = wxEmptyString;
DIALOG_EXPORT_ODBPP::DIALOG_EXPORT_ODBPP( PCB_EDIT_FRAME* aParent ) :
DIALOG_EXPORT_ODBPP_BASE( aParent ),
@ -60,22 +58,9 @@ DIALOG_EXPORT_ODBPP::DIALOG_EXPORT_ODBPP( PCB_EDIT_FRAME* aParent ) :
SetupStandardButtons();
wxString path = m_parent->GetLastPath( LAST_PATH_ODBPP );
if( path.IsEmpty() )
{
wxFileName brdFile( m_parent->GetBoard()->GetFileName() );
wxFileName odbFile( brdFile.GetPath(),
wxString::Format( wxS( "%s-odb" ), brdFile.GetName() ),
FILEEXT::ArchiveFileExtension );
path = odbFile.GetFullPath();
}
m_outputFileName->SetValue( path );
// Fill wxChoice (and others) items with data before calling finishDialogSettings()
// to calculate suitable widgets sizes
Init();
// DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
// non-job versions.
m_hash_key = TO_UTF8( GetTitle() );
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();
@ -92,17 +77,43 @@ DIALOG_EXPORT_ODBPP::DIALOG_EXPORT_ODBPP( JOB_EXPORT_PCB_ODB* aJob, PCB_EDIT_FRA
SetupStandardButtons();
m_outputFileName->SetValue( m_job->GetConfiguredOutputPath() );
// Fill wxChoice (and others) items with data before calling finishDialogSettings()
// to calculate suitable widgets sizes
Init();
// DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
// non-job versions.
m_hash_key = TO_UTF8( GetTitle() );
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();
}
bool DIALOG_EXPORT_ODBPP::TransferDataToWindow()
{
if( !m_job )
{
if( m_outputFileName->GetValue().IsEmpty() )
{
wxFileName brdFile( m_parent->GetBoard()->GetFileName() );
wxFileName odbFile( brdFile.GetPath(), wxString::Format( wxS( "%s-odb" ), brdFile.GetName() ),
FILEEXT::ArchiveFileExtension );
m_outputFileName->SetValue( odbFile.GetFullPath() );
OnFmtChoiceOptionChanged();
}
}
else
{
SetTitle( m_job->GetSettingsDialogTitle() );
m_choiceUnits->SetSelection( static_cast<int>( m_job->m_units ) );
m_precision->SetValue( m_job->m_precision );
m_choiceCompress->SetSelection( static_cast<int>( m_job->m_compressionMode ) );
m_outputFileName->SetValue( m_job->GetConfiguredOutputPath() );
}
return true;
}
void DIALOG_EXPORT_ODBPP::onBrowseClicked( wxCommandEvent& event )
{
// clang-format off
@ -120,8 +131,7 @@ void DIALOG_EXPORT_ODBPP::onBrowseClicked( wxCommandEvent& event )
wxString fileDialogName( wxString::Format( wxS( "%s-odb" ), brdFile.GetName() ) );
wxFileDialog dlg( this, _( "Export ODB++ File" ), fn.GetPath(), fileDialogName, filter,
wxFD_SAVE );
wxFileDialog dlg( this, _( "Export ODB++ File" ), fn.GetPath(), fileDialogName, filter, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
@ -132,30 +142,26 @@ void DIALOG_EXPORT_ODBPP::onBrowseClicked( wxCommandEvent& event )
if( fn.GetExt().Lower() == "zip" )
{
m_choiceCompress->SetSelection(
static_cast<int>( JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP ) );
m_choiceCompress->SetSelection( static_cast<int>( JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP ) );
}
else if( fn.GetExt().Lower() == "tgz" )
{
m_choiceCompress->SetSelection(
static_cast<int>( JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ ) );
m_choiceCompress->SetSelection( static_cast<int>( JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ ) );
}
else if( path.EndsWith( "/" ) || path.EndsWith( "\\" ) )
{
m_choiceCompress->SetSelection(
static_cast<int>( JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE ) );
m_choiceCompress->SetSelection( static_cast<int>( JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE ) );
}
else
{
wxString msg;
msg.Printf( _( "The selected output file name is not a supported archive format." ) );
DisplayErrorMessage( this, msg );
DisplayErrorMessage( this, _( "The selected output file name is not a supported archive format." ) );
return;
}
m_outputFileName->SetValue( path );
}
void DIALOG_EXPORT_ODBPP::onFormatChoice( wxCommandEvent& event )
{
OnFmtChoiceOptionChanged();
@ -168,8 +174,7 @@ void DIALOG_EXPORT_ODBPP::OnFmtChoiceOptionChanged()
wxFileName fileName( fn );
auto compressionMode =
static_cast<JOB_EXPORT_PCB_ODB::ODB_COMPRESSION>( m_choiceCompress->GetSelection() );
auto compressionMode = static_cast<JOB_EXPORT_PCB_ODB::ODB_COMPRESSION>( m_choiceCompress->GetSelection() );
int sepIdx = std::max( fn.Find( '/', true ), fn.Find( '\\', true ) );
int dotIdx = fn.Find( '.', true );
@ -184,9 +189,14 @@ void DIALOG_EXPORT_ODBPP::OnFmtChoiceOptionChanged()
case JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP:
fn = fn + '.' + FILEEXT::ArchiveFileExtension;
break;
case JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ: fn += ".tgz"; break;
case JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE: fn = wxFileName( fn, "" ).GetFullPath(); break;
default: break;
case JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ:
fn += ".tgz";
break;
case JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE:
fn = wxFileName( fn, "" ).GetFullPath();
break;
default:
break;
};
m_outputFileName->SetValue( fn );
@ -200,14 +210,11 @@ void DIALOG_EXPORT_ODBPP::onOKClick( wxCommandEvent& event )
if( fn.IsEmpty() )
{
wxString msg;
msg.Printf( _( "Output file name cannot be empty." ) );
DisplayErrorMessage( this, msg );
DisplayErrorMessage( this, _( "Output file name cannot be empty." ) );
return;
}
auto compressionMode = static_cast<JOB_EXPORT_PCB_ODB::ODB_COMPRESSION>(
m_choiceCompress->GetSelection() );
auto compressionMode = static_cast<JOB_EXPORT_PCB_ODB::ODB_COMPRESSION>( m_choiceCompress->GetSelection() );
wxFileName fileName( fn );
bool isDirectory = fileName.IsDir();
@ -215,65 +222,20 @@ void DIALOG_EXPORT_ODBPP::onOKClick( wxCommandEvent& event )
if( ( compressionMode == JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::NONE && !isDirectory )
|| ( compressionMode == JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::ZIP && extension != "zip" )
|| ( compressionMode == JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ
&& extension != "tgz" ) )
|| ( compressionMode == JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ && extension != "tgz" ) )
{
wxString msg;
msg.Printf(
_( "The output file name conflicts with the selected compression format." ) );
DisplayErrorMessage( this, msg );
DisplayErrorMessage( this, _( "The output file name conflicts with the selected compression format." ) );
return;
}
m_parent->SetLastPath( LAST_PATH_ODBPP, m_outputFileName->GetValue() );
}
event.Skip();
}
bool DIALOG_EXPORT_ODBPP::Init()
{
if( !m_job )
{
if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
{
m_choiceUnits->SetSelection( cfg->m_ExportODBPP.units );
m_precision->SetValue( cfg->m_ExportODBPP.precision );
m_choiceCompress->SetSelection( cfg->m_ExportODBPP.compressFormat );
OnFmtChoiceOptionChanged();
}
}
else
{
SetTitle( m_job->GetSettingsDialogTitle() );
m_choiceUnits->SetSelection( static_cast<int>( m_job->m_units ) );
m_precision->SetValue( m_job->m_precision );
m_choiceCompress->SetSelection( static_cast<int>( m_job->m_compressionMode ) );
m_outputFileName->SetValue( m_job->GetConfiguredOutputPath() );
}
// DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
// non-job versions (which have different sizes).
m_hash_key = TO_UTF8( GetTitle() );
return true;
}
bool DIALOG_EXPORT_ODBPP::TransferDataFromWindow()
{
if( !m_job )
{
if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
{
cfg->m_ExportODBPP.units = m_choiceUnits->GetSelection();
cfg->m_ExportODBPP.precision = m_precision->GetValue();
cfg->m_ExportODBPP.compressFormat = m_choiceCompress->GetSelection();
}
}
else
if( m_job )
{
m_job->SetConfiguredOutputPath( m_outputFileName->GetValue() );
@ -287,9 +249,8 @@ bool DIALOG_EXPORT_ODBPP::TransferDataFromWindow()
void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BOARD* aBoard,
PCB_EDIT_FRAME* aParentFrame,
PROGRESS_REPORTER* aProgressReporter,
REPORTER* aReporter )
PCB_EDIT_FRAME* aParentFrame, PROGRESS_REPORTER* aProgressReporter,
REPORTER* aReporter )
{
wxCHECK( aBoard, /* void */ );
wxString outputPath = aJob.GetFullOutputPath( aBoard->GetProject() );
@ -351,12 +312,10 @@ void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BO
{
if( aParentFrame )
{
msg = wxString::Format( _( "Output files '%s' already exists. "
"Do you want to overwrite it?" ),
msg = wxString::Format( _( "Output files '%s' already exists. Do you want to overwrite it?" ),
outputFn.GetFullPath() );
KIDIALOG errorDlg( aParentFrame, msg, _( "Confirmation" ),
wxOK | wxCANCEL | wxICON_WARNING );
KIDIALOG errorDlg( aParentFrame, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) );
if( errorDlg.ShowModal() != wxID_OK )
@ -364,16 +323,14 @@ void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BO
if( !wxRemoveFile( outputFn.GetFullPath() ) )
{
msg.Printf( _( "Cannot remove existing output file '%s'." ),
outputFn.GetFullPath() );
msg.Printf( _( "Cannot remove existing output file '%s'." ), outputFn.GetFullPath() );
DisplayErrorMessage( aParentFrame, msg );
return;
}
}
else
{
msg = wxString::Format( _( "Output file '%s' already exists." ),
outputFn.GetFullPath() );
msg = wxString::Format( _( "Output file '%s' already exists." ), outputFn.GetFullPath() );
if( aReporter )
aReporter->Report( msg, RPT_SEVERITY_ERROR );
@ -409,8 +366,7 @@ void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BO
"Do you want to overwrite it?" ),
tempFile.GetFullPath() );
KIDIALOG errorDlg( aParentFrame, msg, _( "Confirmation" ),
wxOK | wxCANCEL | wxICON_WARNING );
KIDIALOG errorDlg( aParentFrame, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) );
if( errorDlg.ShowModal() != wxID_OK )
@ -418,16 +374,14 @@ void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BO
if( !tempFile.Rmdir( wxPATH_RMDIR_RECURSIVE ) )
{
msg.Printf( _( "Cannot remove existing output directory '%s'." ),
tempFile.GetFullPath() );
msg.Printf( _( "Cannot remove existing output directory '%s'." ), tempFile.GetFullPath() );
DisplayErrorMessage( aParentFrame, msg );
return;
}
}
else
{
msg = wxString::Format( _( "Output directory '%s' already exists." ),
tempFile.GetFullPath() );
msg = wxString::Format( _( "Output directory '%s' already exists." ), tempFile.GetFullPath() );
if( aReporter )
aReporter->Report( msg, RPT_SEVERITY_ERROR );
@ -442,30 +396,31 @@ void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BO
props["units"] = aJob.m_units == JOB_EXPORT_PCB_ODB::ODB_UNITS::MM ? "mm" : "inch";
props["sigfig"] = wxString::Format( "%d", aJob.m_precision );
auto saveFile = [&]() -> bool
{
try
{
IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::ODBPP ) );
pi->SetReporter( aReporter );
pi->SetProgressReporter( aProgressReporter );
pi->SaveBoard( tempFile.GetFullPath(), aBoard, &props );
return true;
}
catch( const IO_ERROR& ioe )
{
if( aReporter )
auto saveFile =
[&]() -> bool
{
msg = wxString::Format( _( "Error generating ODBPP files '%s'.\n%s" ),
tempFile.GetFullPath(), ioe.What() );
aReporter->Report( msg, RPT_SEVERITY_ERROR );
}
try
{
IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( PCB_IO_MGR::ODBPP ) );
pi->SetReporter( aReporter );
pi->SetProgressReporter( aProgressReporter );
pi->SaveBoard( tempFile.GetFullPath(), aBoard, &props );
return true;
}
catch( const IO_ERROR& ioe )
{
if( aReporter )
{
msg = wxString::Format( _( "Error generating ODBPP files '%s'.\n%s" ),
tempFile.GetFullPath(), ioe.What() );
aReporter->Report( msg, RPT_SEVERITY_ERROR );
}
// In case we started a file but didn't fully write it, clean up
wxFileName::Rmdir( tempFile.GetFullPath() );
return false;
}
};
// In case we started a file but didn't fully write it, clean up
wxFileName::Rmdir( tempFile.GetFullPath() );
return false;
}
};
thread_pool& tp = GetKiCadThreadPool();
auto ret = tp.submit( saveFile );
@ -506,35 +461,34 @@ void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BO
std::function<void( const wxString&, const wxString& )> addDirToZip =
[&]( const wxString& dirPath, const wxString& parentPath )
{
wxDir dir( dirPath );
wxString fileName;
bool cont = dir.GetFirst( &fileName, wxEmptyString, wxDIR_DEFAULT );
while( cont )
{
wxFileName fileInZip( dirPath, fileName );
wxString relativePath =
parentPath.IsEmpty()
? fileName
: parentPath + wxString( wxFileName::GetPathSeparator() )
+ fileName;
if( wxFileName::DirExists( fileInZip.GetFullPath() ) )
{
zipStream.PutNextDirEntry( relativePath );
addDirToZip( fileInZip.GetFullPath(), relativePath );
}
else
{
wxFFileInputStream fileStream( fileInZip.GetFullPath() );
zipStream.PutNextEntry( relativePath );
fileStream.Read( zipStream );
}
cont = dir.GetNext( &fileName );
}
};
wxDir dir( dirPath );
wxString fileName;
bool cont = dir.GetFirst( &fileName, wxEmptyString, wxDIR_DEFAULT );
while( cont )
{
wxFileName fileInZip( dirPath, fileName );
wxString relativePath = fileName;
if( !parentPath.IsEmpty() )
relativePath = parentPath + wxString( wxFileName::GetPathSeparator() ) + fileName;
if( wxFileName::DirExists( fileInZip.GetFullPath() ) )
{
zipStream.PutNextDirEntry( relativePath );
addDirToZip( fileInZip.GetFullPath(), relativePath );
}
else
{
wxFFileInputStream fileStream( fileInZip.GetFullPath() );
zipStream.PutNextEntry( relativePath );
fileStream.Read( zipStream );
}
cont = dir.GetNext( &fileName );
}
};
addDirToZip( tempFile.GetFullPath(), wxEmptyString );
@ -551,39 +505,36 @@ void DIALOG_EXPORT_ODBPP::GenerateODBPPFiles( const JOB_EXPORT_PCB_ODB& aJob, BO
std::function<void( const wxString&, const wxString& )> addDirToTar =
[&]( const wxString& dirPath, const wxString& parentPath )
{
wxDir dir( dirPath );
wxString fileName;
bool cont = dir.GetFirst( &fileName, wxEmptyString, wxDIR_DEFAULT );
while( cont )
{
wxFileName fileInTar( dirPath, fileName );
wxString relativePath =
parentPath.IsEmpty()
? fileName
: parentPath + wxString( wxFileName::GetPathSeparator() )
+ fileName;
if( wxFileName::DirExists( fileInTar.GetFullPath() ) )
{
tarStream.PutNextDirEntry( relativePath );
addDirToTar( fileInTar.GetFullPath(), relativePath );
}
else
{
wxFFileInputStream fileStream( fileInTar.GetFullPath() );
tarStream.PutNextEntry( relativePath, wxDateTime::Now(),
fileStream.GetLength() );
fileStream.Read( tarStream );
}
cont = dir.GetNext( &fileName );
}
};
wxDir dir( dirPath );
wxString fileName;
addDirToTar(
tempFile.GetFullPath(),
tempFile.GetPath( wxPATH_NO_SEPARATOR ).AfterLast( tempFile.GetPathSeparator() ) );
bool cont = dir.GetFirst( &fileName, wxEmptyString, wxDIR_DEFAULT );
while( cont )
{
wxFileName fileInTar( dirPath, fileName );
wxString relativePath = fileName;
if( !parentPath.IsEmpty() )
relativePath = parentPath + wxString( wxFileName::GetPathSeparator() ) + fileName;
if( wxFileName::DirExists( fileInTar.GetFullPath() ) )
{
tarStream.PutNextDirEntry( relativePath );
addDirToTar( fileInTar.GetFullPath(), relativePath );
}
else
{
wxFFileInputStream fileStream( fileInTar.GetFullPath() );
tarStream.PutNextEntry( relativePath, wxDateTime::Now(), fileStream.GetLength() );
fileStream.Read( tarStream );
}
cont = dir.GetNext( &fileName );
}
};
addDirToTar( tempFile.GetFullPath(),
tempFile.GetPath( wxPATH_NO_SEPARATOR ).AfterLast( tempFile.GetPathSeparator() ) );
tarStream.Close();
zlibStream.Close();

View File

@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ODBPP_EXPORT_DIALOG_H
#define ODBPP_EXPORT_DIALOG_H
#pragma once
#include "dialog_export_odbpp_base.h"
class PCB_EDIT_FRAME;
@ -60,12 +60,10 @@ private:
void OnFmtChoiceOptionChanged();
bool Init();
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
PCB_EDIT_FRAME* m_parent;
private:
PCB_EDIT_FRAME* m_parent;
JOB_EXPORT_PCB_ODB* m_job;
};
#endif // ODBPP_EXPORT_DIALOG_H

View File

@ -93,19 +93,6 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aEditFrame, wxWindow* aP
m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
SetupStandardButtons( { { wxID_OK, _( "Export" ) },
{ wxID_CANCEL, _( "Close" ) } } );
// Build default output file name
// (last saved filename in project or built from board filename)
wxString path = m_editFrame->GetLastPath( LAST_PATH_STEP );
if( path.IsEmpty() )
{
wxFileName brdFile( m_editFrame->GetBoard()->GetFileName() );
brdFile.SetExt( wxT( "step" ) );
path = brdFile.GetFullPath();
}
m_outputFileName->SetValue( path );
}
else
{
@ -169,7 +156,16 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aEditFrame, wxWindow* aP
bool DIALOG_EXPORT_STEP::TransferDataToWindow()
{
if( m_job )
if( !m_job )
{
if( m_outputFileName->GetValue().IsEmpty() )
{
wxFileName brdFile( m_editFrame->GetBoard()->GetFileName() );
brdFile.SetExt( wxT( "step" ) );
m_outputFileName->SetValue( brdFile.GetFullPath() );
}
}
else
{
m_rbBoardCenterOrigin->SetValue( true ); // Default
@ -331,7 +327,6 @@ void DIALOG_EXPORT_STEP::OnFmtChoiceOptionChanged()
path = path.Mid( 0, dotIdx ) << '.' << newExt;
m_outputFileName->SetValue( path );
m_editFrame->SetLastPath( LAST_PATH_STEP, path );
}
@ -367,8 +362,6 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
if( !m_job )
{
m_editFrame->SetLastPath( LAST_PATH_STEP, path );
// Build the absolute path of current output directory to preselect it in the file browser.
std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool

View File

@ -22,9 +22,6 @@
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_export_vrml.cpp
*/
#include <wx/dir.h>
@ -43,46 +40,11 @@
DIALOG_EXPORT_VRML::DIALOG_EXPORT_VRML( PCB_EDIT_FRAME* aEditFrame ) :
DIALOG_EXPORT_VRML_BASE( aEditFrame ),
m_editFrame( aEditFrame ),
m_unitsOpt( 1 ),
m_noUnspecified( false ),
m_noDNP( false ),
m_copy3DFilesOpt( false ),
m_useRelativePathsOpt( false ),
m_RefUnits( 0 ),
m_XRef( 0.0 ),
m_YRef( 0.0 ),
m_originMode( 0 )
m_xOrigin( aEditFrame, m_xLabel, m_VRML_Xref, m_xUnits ),
m_yOrigin( aEditFrame, m_yLabel, m_VRML_Yref, m_yUnits )
{
m_filePicker->SetFocus();
if( PCBNEW_SETTINGS* cfg = m_editFrame->GetPcbNewSettings() )
{
m_unitsOpt = cfg->m_ExportVrml.units;
m_noUnspecified = cfg->m_ExportVrml.no_unspecified;
m_noDNP = cfg->m_ExportVrml.no_dnp;
m_copy3DFilesOpt = cfg->m_ExportVrml.copy_3d_models;
m_useRelativePathsOpt = cfg->m_ExportVrml.use_relative_paths;
m_RefUnits = cfg->m_ExportVrml.ref_units;
m_XRef = cfg->m_ExportVrml.ref_x;
m_YRef = cfg->m_ExportVrml.ref_y;
m_originMode = cfg->m_ExportVrml.origin_mode;
}
m_rbCoordOrigin->SetSelection( m_originMode );
m_rbSelectUnits->SetSelection( m_unitsOpt );
m_cbRemoveUnspecified->SetValue( m_noUnspecified );
m_cbRemoveDNP->SetValue( m_noDNP );
m_cbCopyFiles->SetValue( m_copy3DFilesOpt );
m_cbUseRelativePaths->SetValue( m_useRelativePathsOpt );
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 );
SetupStandardButtons();
// Now all widgets have the size fixed, call FinishDialogSettings
@ -90,65 +52,26 @@ DIALOG_EXPORT_VRML::DIALOG_EXPORT_VRML( PCB_EDIT_FRAME* aEditFrame ) :
}
DIALOG_EXPORT_VRML::~DIALOG_EXPORT_VRML()
{
m_unitsOpt = GetUnits();
m_noUnspecified = GetNoUnspecifiedOption();
m_noDNP = GetNoDNPOption();
m_copy3DFilesOpt = GetCopyFilesOption();
if( PCBNEW_SETTINGS* cfg = m_editFrame->GetPcbNewSettings() )
{
cfg->m_ExportVrml.units = m_unitsOpt;
cfg->m_ExportVrml.no_unspecified = m_noUnspecified;
cfg->m_ExportVrml.no_dnp = m_noDNP;
cfg->m_ExportVrml.copy_3d_models = m_copy3DFilesOpt;
cfg->m_ExportVrml.use_relative_paths = m_useRelativePathsOpt;
cfg->m_ExportVrml.ref_units = m_VRML_RefUnitChoice->GetSelection();
cfg->m_ExportVrml.origin_mode = m_rbCoordOrigin->GetSelection();
double val = 0.0;
m_VRML_Xref->GetValue().ToDouble( &val );
cfg->m_ExportVrml.ref_x = val;
m_VRML_Yref->GetValue().ToDouble( &val );
cfg->m_ExportVrml.ref_y = val;
}
}
bool DIALOG_EXPORT_VRML::TransferDataFromWindow()
{
wxFileName fn = m_filePicker->GetPath();
if( fn.Exists() )
{
if( wxMessageBox( _( "Are you sure you want to overwrite the existing file?" ),
_( "Warning" ), wxYES_NO | wxCENTER | wxICON_QUESTION, this ) == wxNO )
if( wxMessageBox( _( "Are you sure you want to overwrite the existing file?" ), _( "Warning" ),
wxYES_NO | wxCENTER | wxICON_QUESTION, this )
== wxNO )
{
return false;
}
}
return true;
}
double DIALOG_EXPORT_VRML::GetXRef()
{
return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_VRML_Xref->GetValue() );
}
double DIALOG_EXPORT_VRML::GetYRef()
{
return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_VRML_Yref->GetValue() );
}
int BOARD_EDITOR_CONTROL::ExportVRML( const TOOL_EVENT& aEvent )
{
// These variables are static to keep info during the session.
static wxString subDirFor3Dshapes;
BOARD* board = m_frame->GetBoard();
// Build default output file name
@ -161,32 +84,21 @@ int BOARD_EDITOR_CONTROL::ExportVRML( const TOOL_EVENT& aEvent )
path = brdFile.GetFullPath();
}
if( subDirFor3Dshapes.IsEmpty() )
subDirFor3Dshapes = wxT( "shapes3D" );
// 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[4] = { 1.0, 0.001, 10.0/25.4, 1.0/25.4 };
DIALOG_EXPORT_VRML dlg( m_frame );
dlg.FilePicker()->SetPath( path );
dlg.SetSubdir( subDirFor3Dshapes );
if( dlg.ShowModal() != wxID_OK )
return 0;
double aXRef = dlg.GetXRef();
double aYRef = dlg.GetYRef();
double aXRef;
double aYRef;
if( dlg.GetRefUnitsChoice() == 1 )
if( dlg.GetSetUserDefinedOrigin() )
{
// selected reference unit is in inches
aXRef *= 25.4;
aYRef *= 25.4;
aXRef = dlg.GetXRefMM();
aYRef = dlg.GetYRefMM();
}
if( dlg.GetOriginChoice() == 1 )
else
{
// Origin = board center:
BOX2I bbox = board->ComputeBoundingBox( true );
@ -194,22 +106,15 @@ int BOARD_EDITOR_CONTROL::ExportVRML( const TOOL_EVENT& aEvent )
aYRef = pcbIUScale.IUTomm( bbox.GetCenter().y );
}
double scale = scaleList[dlg.GetUnits()]; // final scale export
bool includeUnspecified = !dlg.GetNoUnspecifiedOption();
bool includeDNP = !dlg.GetNoDNPOption();
bool export3DFiles = dlg.GetCopyFilesOption();
bool useRelativePaths = dlg.GetUseRelativePathsOption();
path = dlg.FilePicker()->GetPath();
m_frame->SetLastPath( LAST_PATH_VRML, path );
wxFileName modelPath = path;
wxBusyCursor dummy;
subDirFor3Dshapes = dlg.GetSubdir3Dshapes();
modelPath.AppendDir( subDirFor3Dshapes );
modelPath.AppendDir( dlg.GetSubdir3Dshapes() );
if( export3DFiles && !modelPath.DirExists() )
if( dlg.GetCopyFilesOption() && !modelPath.DirExists() )
{
if( !modelPath.Mkdir() )
{
@ -219,11 +124,16 @@ int BOARD_EDITOR_CONTROL::ExportVRML( const TOOL_EVENT& aEvent )
}
}
if( !m_frame->ExportVRML_File( path, scale, includeUnspecified, includeDNP, export3DFiles,
useRelativePaths, modelPath.GetPath(), aXRef, aYRef ) )
if( !m_frame->ExportVRML_File( path,
dlg.GetScale(),
!dlg.GetNoUnspecifiedOption(),
!dlg.GetNoDNPOption(),
dlg.GetCopyFilesOption(),
dlg.GetUseRelativePathsOption(),
modelPath.GetPath(),
aXRef, aYRef ) )
{
DisplayErrorMessage( m_frame, wxString::Format( _( "Failed to create file '%s'." ),
path ) );
DisplayErrorMessage( m_frame, wxString::Format( _( "Failed to create file '%s'." ), path ) );
}
return 0;

View File

@ -26,6 +26,7 @@
#pragma once
#include <dialog_export_vrml_base.h> // the wxFormBuilder header file
#include <widgets/unit_binder.h>
class PCB_EDIT_FRAME;
@ -33,35 +34,28 @@ class DIALOG_EXPORT_VRML : public DIALOG_EXPORT_VRML_BASE
{
public:
DIALOG_EXPORT_VRML( PCB_EDIT_FRAME* aEditFrame );
~DIALOG_EXPORT_VRML();
void SetSubdir( const wxString& aDir ) { m_SubdirNameCtrl->SetValue( aDir ); }
wxString GetSubdir3Dshapes() { return m_SubdirNameCtrl->GetValue(); }
~DIALOG_EXPORT_VRML() = default;
wxFilePickerCtrl* FilePicker() { return m_filePicker; }
int GetRefUnitsChoice() { return m_VRML_RefUnitChoice->GetSelection(); }
wxString GetSubdir3Dshapes() { return m_SubdirNameCtrl->GetValue(); }
int GetSetUserDefinedOrigin() { return m_cbUserDefinedOrigin->GetValue(); }
int GetOriginChoice() { return m_rbCoordOrigin->GetSelection(); }
double GetXRefMM() { return pcbIUScale.IUTomm( m_xOrigin.GetIntValue() ); }
double GetYRefMM() { return pcbIUScale.IUTomm( m_yOrigin.GetIntValue() ); }
double GetXRef();
double GetYRef();
int GetUnits() { return m_unitsOpt = m_rbSelectUnits->GetSelection(); }
double GetScale()
{
// 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[4] = { 1.0, 0.001, 10.0/25.4, 1.0/25.4 };
return scaleList[ m_unitsChoice->GetSelection() ];
}
bool GetNoUnspecifiedOption() { return m_cbRemoveUnspecified->GetValue(); }
bool GetNoDNPOption() { return m_cbRemoveDNP->GetValue(); }
bool GetCopyFilesOption() { return m_copy3DFilesOpt = m_cbCopyFiles->GetValue(); }
bool GetUseRelativePathsOption()
{
return m_useRelativePathsOpt = m_cbUseRelativePaths->GetValue();
}
bool GetCopyFilesOption() { return m_cbCopyFiles->GetValue(); }
bool GetUseRelativePathsOption() { return m_cbUseRelativePaths->GetValue(); }
void OnUpdateUseRelativePath( wxUpdateUIEvent& event ) override
{
@ -72,15 +66,6 @@ public:
bool TransferDataFromWindow() override;
private:
PCB_EDIT_FRAME* m_editFrame;
int m_unitsOpt; // Remember last units option
bool m_noUnspecified; // Remember last No Unspecified Component option
bool m_noDNP; // Remember last No DNP Component option
bool m_copy3DFilesOpt; // Remember last copy model files option
bool m_useRelativePathsOpt; // Remember last use absolute paths 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
int m_originMode; // Origin selection option
// (0 = user, 1 = board center)
UNIT_BINDER m_xOrigin;
UNIT_BINDER m_yOrigin;
};

View File

@ -32,47 +32,28 @@ DIALOG_EXPORT_VRML_BASE::DIALOG_EXPORT_VRML_BASE( wxWindow* parent, wxWindowID i
m_staticText3->Wrap( -1 );
bUpperSizer->Add( m_staticText3, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_SubdirNameCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SubdirNameCtrl = new wxTextCtrl( this, wxID_ANY, _("shapes3D"), wxDefaultPosition, wxDefaultSize, 0 );
bUpperSizer->Add( m_SubdirNameCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizer1->Add( bUpperSizer, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizerOptions;
bSizerOptions = new wxBoxSizer( wxHORIZONTAL );
bSizerOptions = new wxBoxSizer( wxVERTICAL );
wxString m_rbCoordOriginChoices[] = { _("User defined origin"), _("Board center origin") };
int m_rbCoordOriginNChoices = sizeof( m_rbCoordOriginChoices ) / sizeof( wxString );
m_rbCoordOrigin = new wxRadioBox( this, wxID_ANY, _("Coordinate Origin Options"), wxDefaultPosition, wxDefaultSize, m_rbCoordOriginNChoices, m_rbCoordOriginChoices, 1, wxRA_SPECIFY_COLS );
m_rbCoordOrigin->SetSelection( 0 );
bSizerOptions->Add( m_rbCoordOrigin, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizerVrmlUnits;
bSizerVrmlUnits = new wxBoxSizer( wxVERTICAL );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("User defined origin:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
bSizerVrmlUnits->Add( m_staticText6, 0, wxALL, 5 );
m_cbUserDefinedOrigin = new wxCheckBox( this, wxID_ANY, _("User defined origin"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUserDefinedOrigin->SetValue(true);
bSizerOptions->Add( m_cbUserDefinedOrigin, 0, wxALL, 5 );
wxFlexGridSizer* fgSizerOptions;
fgSizerOptions = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizerOptions = new wxFlexGridSizer( 0, 3, 3, 0 );
fgSizerOptions->AddGrowableCol( 1 );
fgSizerOptions->SetFlexibleDirection( wxBOTH );
fgSizerOptions->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticText61 = new wxStaticText( this, 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( this, 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( this, wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
fgSizerOptions->Add( m_staticText4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_xLabel = new wxStaticText( this, wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_xLabel->Wrap( -1 );
fgSizerOptions->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_VRML_Xref = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
@ -83,11 +64,15 @@ DIALOG_EXPORT_VRML_BASE::DIALOG_EXPORT_VRML_BASE( wxWindow* parent, wxWindowID i
#else
m_VRML_Xref->SetMaxLength( 8 );
#endif
fgSizerOptions->Add( m_VRML_Xref, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
fgSizerOptions->Add( m_VRML_Xref, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_staticText5 = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText5->Wrap( -1 );
fgSizerOptions->Add( m_staticText5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_xUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 );
m_xUnits->Wrap( -1 );
fgSizerOptions->Add( m_xUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_yLabel = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_yLabel->Wrap( -1 );
fgSizerOptions->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_VRML_Yref = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
@ -98,22 +83,33 @@ DIALOG_EXPORT_VRML_BASE::DIALOG_EXPORT_VRML_BASE( wxWindow* parent, wxWindowID i
#else
m_VRML_Yref->SetMaxLength( 8 );
#endif
fgSizerOptions->Add( m_VRML_Yref, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
fgSizerOptions->Add( m_VRML_Yref, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_yUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 );
m_yUnits->Wrap( -1 );
fgSizerOptions->Add( m_yUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
bSizerVrmlUnits->Add( fgSizerOptions, 1, wxEXPAND, 5 );
bSizerOptions->Add( fgSizerOptions, 0, wxEXPAND|wxRIGHT|wxLEFT, 20 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
m_unitsLabel = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 );
m_unitsLabel->Wrap( -1 );
bSizer7->Add( m_unitsLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxString m_unitsChoiceChoices[] = { _("mm"), _("meter"), _("0.1 inch"), _("inch") };
int m_unitsChoiceNChoices = sizeof( m_unitsChoiceChoices ) / sizeof( wxString );
m_unitsChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_unitsChoiceNChoices, m_unitsChoiceChoices, 0 );
m_unitsChoice->SetSelection( 1 );
bSizer7->Add( m_unitsChoice, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bSizerOptions->Add( bSizerVrmlUnits, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 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, _("Units"), wxDefaultPosition, wxDefaultSize, m_rbSelectUnitsNChoices, m_rbSelectUnitsChoices, 1, wxRA_SPECIFY_COLS );
m_rbSelectUnits->SetSelection( 0 );
bSizerOptions->Add( m_rbSelectUnits, 1, wxALL|wxEXPAND, 5 );
bSizerOptions->Add( bSizer7, 0, wxEXPAND|wxTOP, 5 );
bSizer1->Add( bSizerOptions, 0, wxEXPAND, 5 );
bSizer1->Add( bSizerOptions, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bLowerSizer;
bLowerSizer = new wxBoxSizer( wxHORIZONTAL );
@ -122,15 +118,15 @@ DIALOG_EXPORT_VRML_BASE::DIALOG_EXPORT_VRML_BASE( wxWindow* parent, wxWindowID i
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_cbRemoveDNP = new wxCheckBox( this, wxID_ANY, _("Ignore 'Do not populate' components"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_cbRemoveDNP, 0, wxALL, 5 );
bSizer4->Add( m_cbRemoveDNP, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_cbRemoveUnspecified = new wxCheckBox( this, wxID_ANY, _("Ignore 'Unspecified' components"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_cbRemoveUnspecified, 0, wxALL, 5 );
bSizer4->Add( m_cbRemoveUnspecified, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_cbCopyFiles = new wxCheckBox( this, wxID_ANY, _("Copy 3D model files to 3D model path"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbCopyFiles->SetToolTip( _("If checked: copy 3D models to the destination folder\nIf not checked: Embed 3D models in the VRML board file") );
bSizer4->Add( m_cbCopyFiles, 0, wxALL, 5 );
bSizer4->Add( m_cbCopyFiles, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_cbUseRelativePaths = new wxCheckBox( this, wxID_ANY, _("Use relative paths to model files in board VRML file"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUseRelativePaths->SetToolTip( _("Use paths for model files in board VRML file relative to the VRML file") );

File diff suppressed because it is too large Load Diff

View File

@ -20,9 +20,8 @@
#include <wx/filepicker.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/radiobox.h>
#include <wx/choice.h>
#include <wx/checkbox.h>
#include <wx/choice.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -40,15 +39,15 @@ class DIALOG_EXPORT_VRML_BASE : public DIALOG_SHIM
wxFilePickerCtrl* m_filePicker;
wxStaticText* m_staticText3;
wxTextCtrl* m_SubdirNameCtrl;
wxRadioBox* m_rbCoordOrigin;
wxStaticText* m_staticText6;
wxStaticText* m_staticText61;
wxChoice* m_VRML_RefUnitChoice;
wxStaticText* m_staticText4;
wxCheckBox* m_cbUserDefinedOrigin;
wxStaticText* m_xLabel;
wxTextCtrl* m_VRML_Xref;
wxStaticText* m_staticText5;
wxStaticText* m_xUnits;
wxStaticText* m_yLabel;
wxTextCtrl* m_VRML_Yref;
wxRadioBox* m_rbSelectUnits;
wxStaticText* m_yUnits;
wxStaticText* m_unitsLabel;
wxChoice* m_unitsChoice;
wxCheckBox* m_cbRemoveDNP;
wxCheckBox* m_cbRemoveUnspecified;
wxCheckBox* m_cbCopyFiles;

View File

@ -26,14 +26,9 @@
DIALOG_FILTER_SELECTION::DIALOG_FILTER_SELECTION( PCB_BASE_FRAME* aParent, OPTIONS& aOptions ) :
DIALOG_FILTER_SELECTION_BASE( aParent ),
m_options( aOptions )
DIALOG_FILTER_SELECTION_BASE( aParent ),
m_options( aOptions )
{
setCheckboxStatesFromOptions( aOptions );
// Update "All Items" checkbox based on how many items are currently checked
m_All_Items->Set3StateValue( GetSuggestedAllItemsState() );
SetupStandardButtons();
SetFocus();
@ -54,7 +49,7 @@ void DIALOG_FILTER_SELECTION::checkBoxClicked( wxCommandEvent& aEvent )
}
void DIALOG_FILTER_SELECTION::setCheckboxStatesFromOptions( OPTIONS& aOptions )
bool DIALOG_FILTER_SELECTION::TransferDataToWindow()
{
m_Include_Modules->SetValue( m_options.includeModules );
m_IncludeLockedModules->SetValue( m_options.includeLockedModules );
@ -70,6 +65,11 @@ void DIALOG_FILTER_SELECTION::setCheckboxStatesFromOptions( OPTIONS& aOptions )
m_Include_Draw_Items->SetValue( m_options.includeItemsOnTechLayers );
m_Include_Edges_Items->SetValue( m_options.includeBoardOutlineLayer );
m_Include_PcbTexts->SetValue( m_options.includePcbTexts );
// Update "All Items" checkbox based on how many items are currently checked
m_All_Items->Set3StateValue( GetSuggestedAllItemsState() );
return true;
}
@ -93,28 +93,27 @@ void DIALOG_FILTER_SELECTION::forceCheckboxStates( bool aNewState )
wxCheckBoxState DIALOG_FILTER_SELECTION::GetSuggestedAllItemsState( void )
{
int NumChecked = 0;
int NumCheckboxesOnDlg = 0;
wxCheckBoxState SuggestedState = wxCHK_UNDETERMINED; // Assume some but not all are checked
int numChecked = 0;
int numCheckboxesOnDlg = 0;
wxCheckBoxState suggestedState = wxCHK_UNDETERMINED; // Assume some but not all are checked
// Find out how many checkboxes are on this dialog. We do this at runtime so future
// changes to the dialog are easier to handle or automatic, depending on the change.
const wxWindowList& list = this->GetChildren();
for( wxWindowList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext() )
{
wxWindow* current = node->GetData();
// If casting the child window to a checkbox isn't NULL, then the child is a checkbox
wxCheckBox* CurrCB = dynamic_cast<wxCheckBox*>( current );
if( CurrCB )
if( wxCheckBox* currCB = dynamic_cast<wxCheckBox*>( current ) )
{
// Need to get count of checkboxes, but not include the "All Items" checkbox (the only
// one that allows the 3rd state) or the hidden one (the only one with an empty label)
// that keeps the dialog formatted properly
if( !( "" == CurrCB->GetLabelText() || CurrCB->Is3State() ) )
NumCheckboxesOnDlg++;
if( !( currCB->GetLabelText().IsEmpty() || currCB->Is3State() ) )
numCheckboxesOnDlg++;
}
}
@ -122,49 +121,38 @@ wxCheckBoxState DIALOG_FILTER_SELECTION::GetSuggestedAllItemsState( void )
// if "footprints" is checked.
if( m_Include_Modules->GetValue() )
{
NumChecked++;
numChecked++;
if( m_IncludeLockedModules->GetValue() )
NumChecked++;
numChecked++;
}
else
{
// If include modules isn't checked then ignore the "Locked Footprints" checkbox in tally
NumCheckboxesOnDlg--;
numCheckboxesOnDlg--;
}
if( m_Include_Tracks->GetValue() )
NumChecked++;
if( m_Include_Vias->GetValue() )
NumChecked++;
if( m_Include_Zones->GetValue() )
NumChecked++;
if( m_Include_Draw_Items->GetValue() )
NumChecked++;
if( m_Include_Edges_Items->GetValue() )
NumChecked++;
if( m_Include_PcbTexts->GetValue() )
NumChecked++;
for( wxCheckBox* cb : { m_Include_Tracks, m_Include_Vias, m_Include_Zones, m_Include_Draw_Items,
m_Include_Edges_Items, m_Include_PcbTexts } )
{
if( cb->GetValue() )
numChecked++;
}
// Change suggestion if all or none are checked
if( !NumChecked )
SuggestedState = wxCHK_UNCHECKED;
else if( NumChecked == NumCheckboxesOnDlg )
SuggestedState = wxCHK_CHECKED;
if( !numChecked )
suggestedState = wxCHK_UNCHECKED;
else if( numChecked == numCheckboxesOnDlg )
suggestedState = wxCHK_CHECKED;
return SuggestedState;
return suggestedState;
}
void DIALOG_FILTER_SELECTION::allItemsClicked( wxCommandEvent& aEvent )
{
if( wxCHK_CHECKED == m_All_Items->Get3StateValue() )
if( m_All_Items->Get3StateValue() == wxCHK_CHECKED )
forceCheckboxStates( true ); // Select all items
else
forceCheckboxStates( false ); // Clear all items
@ -176,7 +164,6 @@ bool DIALOG_FILTER_SELECTION::TransferDataFromWindow()
if( !wxDialog::TransferDataFromWindow() )
return false;
m_options.allItems = m_All_Items->Get3StateValue();
m_options.includeModules = m_Include_Modules->GetValue();
m_options.includeLockedModules = m_IncludeLockedModules->GetValue();
m_options.includeTracks = m_Include_Tracks->GetValue();

View File

@ -21,8 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DIALOG_FILTER_SELECTION_H
#define DIALOG_FILTER_SELECTION_H
#pragma once
#include <dialogs/dialog_filter_selection_base.h>
@ -31,13 +30,11 @@ class PCB_BASE_FRAME;
class DIALOG_FILTER_SELECTION : public DIALOG_FILTER_SELECTION_BASE
{
public:
/**
* Struct that will be set with the result of the user choices in the dialog
*/
struct OPTIONS
{
wxCheckBoxState allItems = wxCHK_UNDETERMINED;
bool includeModules = true;
bool includeLockedModules = true;
bool includeTracks = true;
@ -56,24 +53,19 @@ public:
* changes made by the dialog on exit.
*/
DIALOG_FILTER_SELECTION( PCB_BASE_FRAME* aParent, OPTIONS& aOptions );
~DIALOG_FILTER_SELECTION()
{
}
~DIALOG_FILTER_SELECTION() = default;
protected:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
private:
void checkBoxClicked( wxCommandEvent& aEvent ) override;
void allItemsClicked( wxCommandEvent& aEvent ) override;
void setCheckboxStatesFromOptions( OPTIONS& aOptions );
void forceCheckboxStates( bool aNewState );
wxCheckBoxState GetSuggestedAllItemsState( void );
///< Reference to the options struct to fill.
OPTIONS& m_options;
};
#endif // DIALOG_FILTER_SELECTION_H

View File

@ -42,27 +42,19 @@ DIALOG_FOOTPRINT_CHECKER::DIALOG_FOOTPRINT_CHECKER( FOOTPRINT_EDIT_FRAME* aParen
DIALOG_FOOTPRINT_CHECKER_BASE( aParent ),
m_frame( aParent ),
m_checksRun( false ),
m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ),
m_centerMarkerOnIdle( nullptr )
{
m_markersProvider = std::make_shared<DRC_ITEMS_PROVIDER>( m_frame->GetBoard(),
MARKER_BASE::MARKER_DRC );
m_markersProvider = std::make_shared<DRC_ITEMS_PROVIDER>( m_frame->GetBoard(), MARKER_BASE::MARKER_DRC );
m_markersTreeModel = new RC_TREE_MODEL( m_frame, m_markersDataView );
m_markersDataView->AssociateModel( m_markersTreeModel );
m_markersTreeModel->Update( m_markersProvider, m_severities );
if( m_frame->GetBoard()->GetFirstFootprint() == g_lastFootprint )
{
m_checksRun = g_lastChecksRun;
updateDisplayedCounts();
}
SetupStandardButtons( { { wxID_OK, _( "Run Checks" ) },
{ wxID_CANCEL, _( "Close" ) } } );
syncCheckboxes();
finishDialogSettings();
}
@ -78,31 +70,20 @@ DIALOG_FOOTPRINT_CHECKER::~DIALOG_FOOTPRINT_CHECKER()
}
void DIALOG_FOOTPRINT_CHECKER::updateData()
{
m_markersTreeModel->Update( m_markersProvider, getSeverities() );
updateDisplayedCounts();
}
bool DIALOG_FOOTPRINT_CHECKER::TransferDataToWindow()
{
updateData();
return true;
}
bool DIALOG_FOOTPRINT_CHECKER::TransferDataFromWindow()
{
return true;
}
// Don't globally define this; different facilities use different definitions of "ALL"
static int RPT_SEVERITY_ALL = RPT_SEVERITY_WARNING | RPT_SEVERITY_ERROR | RPT_SEVERITY_EXCLUSION;
void DIALOG_FOOTPRINT_CHECKER::syncCheckboxes()
{
m_showAll->SetValue( m_severities == RPT_SEVERITY_ALL );
m_showErrors->SetValue( m_severities & RPT_SEVERITY_ERROR );
m_showWarnings->SetValue( m_severities & RPT_SEVERITY_WARNING );
m_showExclusions->SetValue( m_severities & RPT_SEVERITY_EXCLUSION );
}
void DIALOG_FOOTPRINT_CHECKER::runChecks()
{
BOARD* board = m_frame->GetBoard();
@ -148,15 +129,13 @@ void DIALOG_FOOTPRINT_CHECKER::runChecks()
&& footprint->GetCourtyard( F_CrtYd ).OutlineCount() == 0
&& footprint->GetCourtyard( B_CrtYd ).OutlineCount() == 0 )
{
errorHandler( footprint, nullptr, nullptr, DRCE_MISSING_COURTYARD, wxEmptyString,
{ 0, 0 } );
errorHandler( footprint, nullptr, nullptr, DRCE_MISSING_COURTYARD, wxEmptyString, { 0, 0 } );
}
footprint->CheckFootprintAttributes(
[&]( const wxString& aMsg )
{
errorHandler( footprint, nullptr, nullptr, DRCE_FOOTPRINT_TYPE_MISMATCH, aMsg,
{ 0, 0 } );
errorHandler( footprint, nullptr, nullptr, DRCE_FOOTPRINT_TYPE_MISMATCH, aMsg, { 0, 0 } );
} );
footprint->CheckPads( m_frame,
@ -181,10 +160,9 @@ void DIALOG_FOOTPRINT_CHECKER::runChecks()
footprint->CheckNetTies(
[&]( const BOARD_ITEM* aItemA, const BOARD_ITEM* aItemB, const BOARD_ITEM* aItemC,
const VECTOR2I& aPosition )
const VECTOR2I& aPt )
{
errorHandler( aItemA, aItemB, aItemC, DRCE_SHORTING_ITEMS, wxEmptyString,
aPosition );
errorHandler( aItemA, aItemB, aItemC, DRCE_SHORTING_ITEMS, wxEmptyString, aPt );
} );
}
@ -195,10 +173,7 @@ void DIALOG_FOOTPRINT_CHECKER::runChecks()
} );
m_checksRun = true;
m_markersTreeModel->Update( m_markersProvider, m_severities );
updateDisplayedCounts();
updateData();
refreshEditor();
}
@ -228,7 +203,6 @@ void DIALOG_FOOTPRINT_CHECKER::centerMarkerIdleHandler( wxIdleEvent& aEvent )
void DIALOG_FOOTPRINT_CHECKER::OnRunChecksClick( wxCommandEvent& aEvent )
{
m_checksRun = false;
runChecks();
}
@ -242,9 +216,7 @@ void DIALOG_FOOTPRINT_CHECKER::OnSelectItem( wxDataViewEvent& aEvent )
if( m_centerMarkerOnIdle )
{
// we already came from a cross-probe of the marker in the document; don't go
// around in circles
// we already came from a cross-probe of the marker in the document; don't go around in circles
aEvent.Skip();
return;
}
@ -333,35 +305,37 @@ void DIALOG_FOOTPRINT_CHECKER::OnLeftDClickItem( wxMouseEvent& event )
Show( false );
}
// Do not skip aVent here: this is not useful, and Pcbnew crashes
// if skipped (at least on Windows)
// Do not skip event here: this is not useful, and Pcbnew crashes if skipped (at least on MSW)
}
int DIALOG_FOOTPRINT_CHECKER::getSeverities() const
{
int severities = 0;
if( m_showErrors->GetValue() )
severities |= RPT_SEVERITY_ERROR;
if( m_showWarnings->GetValue() )
severities |= RPT_SEVERITY_WARNING;
if( m_showExclusions->GetValue() )
severities |= RPT_SEVERITY_EXCLUSION;
return severities;
}
void DIALOG_FOOTPRINT_CHECKER::OnSeverity( wxCommandEvent& aEvent )
{
int flag = 0;
if( aEvent.GetEventObject() == m_showAll )
flag = RPT_SEVERITY_ALL;
else if( aEvent.GetEventObject() == m_showErrors )
flag = RPT_SEVERITY_ERROR;
else if( aEvent.GetEventObject() == m_showWarnings )
flag = RPT_SEVERITY_WARNING;
else if( aEvent.GetEventObject() == m_showExclusions )
flag = RPT_SEVERITY_EXCLUSION;
{
m_showErrors->SetValue( true );
m_showWarnings->SetValue( aEvent.IsChecked() );
m_showExclusions->SetValue( aEvent.IsChecked() );
}
if( aEvent.IsChecked() )
m_severities |= flag;
else if( aEvent.GetEventObject() == m_showAll )
m_severities = RPT_SEVERITY_ERROR;
else
m_severities &= ~flag;
syncCheckboxes();
m_markersTreeModel->Update( m_markersProvider, m_severities );
updateDisplayedCounts();
updateData();
}

View File

@ -22,8 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DIALOG_FOOTPRINT_CHECKER_H
#define DIALOG_FOOTPRINT_CHECKER_H
#pragma once
#include <dialog_footprint_checker_base.h>
#include <rc_item.h>
@ -41,11 +40,13 @@ public:
void SelectMarker( const PCB_MARKER* aMarker );
private:
void syncCheckboxes();
void updateDisplayedCounts();
int getSeverities() const;
void runChecks();
void updateDisplayedCounts();
void updateData();
void centerMarkerIdleHandler( wxIdleEvent& aEvent );
void deleteAllMarkers();
@ -63,17 +64,13 @@ private:
void OnDeleteAllClick( wxCommandEvent& event ) override;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
private:
FOOTPRINT_EDIT_FRAME* m_frame;
bool m_checksRun;
int m_severities;
std::shared_ptr<RC_ITEMS_PROVIDER> m_markersProvider;
RC_TREE_MODEL* m_markersTreeModel;
const PCB_MARKER* m_centerMarkerOnIdle;
};
#endif // DIALOG_FOOTPRINT_CHECKER_H

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -34,19 +34,20 @@ DIALOG_FOOTPRINT_CHECKER_BASE::DIALOG_FOOTPRINT_CHECKER_BASE( wxWindow* parent,
bSeveritySizer->Add( m_showLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
m_showAll = new wxCheckBox( this, wxID_ANY, _("All"), wxDefaultPosition, wxDefaultSize, 0 );
m_showAll->SetValue(true);
bSeveritySizer->Add( m_showAll, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bSeveritySizer->Add( 35, 0, 0, wxEXPAND, 5 );
m_showErrors = new wxCheckBox( this, wxID_ANY, _("Errors"), wxDefaultPosition, wxDefaultSize, 0 );
m_showErrors->SetValue(true);
bSeveritySizer->Add( m_showErrors, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_errorsBadge = new NUMBER_BADGE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
bSeveritySizer->Add( m_errorsBadge, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 25 );
m_showWarnings = new wxCheckBox( this, wxID_ANY, _("Warnings"), wxDefaultPosition, wxDefaultSize, 0 );
m_showWarnings->SetValue(true);
bSeveritySizer->Add( m_showWarnings, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_warningsBadge = new NUMBER_BADGE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -29,7 +29,6 @@
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_FOOTPRINT_CHECKER_BASE
///////////////////////////////////////////////////////////////////////////////

View File

@ -55,8 +55,6 @@ DIALOG_GEN_FOOTPRINT_POSITION::DIALOG_GEN_FOOTPRINT_POSITION( PCB_EDIT_FRAME* aE
m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
m_outputDirectoryName->SetValue( m_editFrame->Prj().GetProjectFile().m_PcbLastPath[LAST_PATH_POS_FILES] );
SetupStandardButtons( { { wxID_OK, _( "Generate Position File" ) },
{ wxID_CANCEL, _( "Close" ) } } );
@ -217,8 +215,6 @@ void DIALOG_GEN_FOOTPRINT_POSITION::onGenerate( wxCommandEvent& event )
// Keep unix directory format convention in cfg files
m_outputDirectory.Replace( wxT( "\\" ), wxT( "/" ) );
m_editFrame->Prj().GetProjectFile().m_PcbLastPath[LAST_PATH_POS_FILES] = m_outputDirectory;
if( m_formatCtrl->GetSelection() == 2 )
CreateGerberFiles();
else

View File

@ -42,13 +42,12 @@
#include <board.h>
DIALOG_GENCAD_EXPORT_OPTIONS::DIALOG_GENCAD_EXPORT_OPTIONS( PCB_EDIT_FRAME* aParent,
const wxString& aPath ) :
DIALOG_SHIM( aParent, wxID_ANY, _( "Export to GenCAD settings" ), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
DIALOG_GENCAD_EXPORT_OPTIONS::DIALOG_GENCAD_EXPORT_OPTIONS( PCB_EDIT_FRAME* aParent, const wxString& aTitle,
JOB_EXPORT_PCB_GENCAD* aJob ) :
DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
m_frame( aParent ),
m_job( nullptr )
m_job( aJob )
{
wxBoxSizer* m_mainSizer = new wxBoxSizer( wxVERTICAL );
@ -58,20 +57,17 @@ DIALOG_GENCAD_EXPORT_OPTIONS::DIALOG_GENCAD_EXPORT_OPTIONS( PCB_EDIT_FRAME* aPar
m_textFile->Wrap( -1 );
m_fileSizer->Add( m_textFile, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
m_outputFileName =
new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_outputFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_outputFileName->SetToolTip( _( "Enter a filename if you do not want to use default file names" ) );
m_outputFileName->SetMinSize( wxSize( 350, -1 ) );
m_fileSizer->Add( m_outputFileName, 1, wxALL | wxEXPAND, 5 );
m_browseButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition,
wxSize( -1, -1 ), wxBU_AUTODRAW | 0 );
m_browseButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1, -1 ),
wxBU_AUTODRAW | 0 );
m_fileSizer->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
m_mainSizer->Add( m_fileSizer, 0, wxEXPAND | wxALL, 5 );
m_optsSizer = new wxGridSizer( 0, 1, 3, 3 );
createOptCheckboxes();
m_mainSizer->Add( m_optsSizer, 1, wxEXPAND | wxALL, 5 );
@ -81,41 +77,34 @@ DIALOG_GENCAD_EXPORT_OPTIONS::DIALOG_GENCAD_EXPORT_OPTIONS( PCB_EDIT_FRAME* aPar
SetSizer( m_mainSizer );
if( !aTitle.IsEmpty() )
SetTitle( aTitle );
if( aJob )
m_browseButton->Hide();
// DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
// non-job versions.
m_hash_key = TO_UTF8( GetTitle() );
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();
// Set the path in m_filePicker, now the size is set
// (otherwise the text is truncated)
m_outputFileName->SetValue( aPath );
Layout();
Fit();
m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( DIALOG_GENCAD_EXPORT_OPTIONS::onBrowseClicked ),
NULL, this );
}
DIALOG_GENCAD_EXPORT_OPTIONS::DIALOG_GENCAD_EXPORT_OPTIONS( PCB_EDIT_FRAME* aParent,
JOB_EXPORT_PCB_GENCAD* aJob ) :
DIALOG_GENCAD_EXPORT_OPTIONS( aParent, aJob->GetConfiguredOutputPath() )
{
m_job = aJob;
m_browseButton->Hide();
// Set the title
SetTitle( aJob->GetSettingsDialogTitle() );
nullptr, this );
}
DIALOG_GENCAD_EXPORT_OPTIONS::~DIALOG_GENCAD_EXPORT_OPTIONS()
{
m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( DIALOG_GENCAD_EXPORT_OPTIONS::onBrowseClicked ),
NULL, this );
wxCommandEventHandler( DIALOG_GENCAD_EXPORT_OPTIONS::onBrowseClicked ),
nullptr, this );
}
@ -148,17 +137,6 @@ bool DIALOG_GENCAD_EXPORT_OPTIONS::GetOption( GENCAD_EXPORT_OPT aOption ) const
}
std::map<GENCAD_EXPORT_OPT, bool> DIALOG_GENCAD_EXPORT_OPTIONS::GetAllOptions() const
{
std::map<GENCAD_EXPORT_OPT, bool> retVal;
for( const auto& option : m_options )
retVal[option.first] = option.second->IsChecked();
return retVal;
}
wxString DIALOG_GENCAD_EXPORT_OPTIONS::GetFileName() const
{
return m_outputFileName->GetValue();
@ -170,14 +148,25 @@ bool DIALOG_GENCAD_EXPORT_OPTIONS::TransferDataToWindow()
if( !wxDialog::TransferDataToWindow() )
return false;
if( m_job )
if( !m_job )
{
if( m_outputFileName->GetValue().IsEmpty() )
{
wxFileName brdFile = m_frame->GetBoard()->GetFileName();
brdFile.SetExt( wxT( "cad" ) );
m_outputFileName->SetValue( brdFile.GetFullPath() );
}
}
else
{
m_outputFileName->SetValue( m_job->GetConfiguredOutputPath() );
m_options[FLIP_BOTTOM_PADS]->SetValue( m_job->m_flipBottomPads );
m_options[UNIQUE_PIN_NAMES]->SetValue( m_job->m_useUniquePins );
m_options[INDIVIDUAL_SHAPES]->SetValue( m_job->m_useIndividualShapes );
m_options[USE_AUX_ORIGIN]->SetValue( m_job->m_useDrillOrigin );
m_options[STORE_ORIGIN_COORDS]->SetValue( m_job->m_storeOriginCoords );
}
return true;
}

View File

@ -24,8 +24,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __DIALOG_GENCAD_EXPORT_OPTIONS_H__
#define __DIALOG_GENCAD_EXPORT_OPTIONS_H__
#pragma once
#include <dialog_shim.h>
@ -55,16 +54,12 @@ class JOB_EXPORT_PCB_GENCAD;
class DIALOG_GENCAD_EXPORT_OPTIONS : public DIALOG_SHIM
{
public:
DIALOG_GENCAD_EXPORT_OPTIONS( PCB_EDIT_FRAME* aParent, const wxString& aPath );
DIALOG_GENCAD_EXPORT_OPTIONS( PCB_EDIT_FRAME* aParent, JOB_EXPORT_PCB_GENCAD* aJob );
DIALOG_GENCAD_EXPORT_OPTIONS( PCB_EDIT_FRAME* aParent, const wxString& aTitle, JOB_EXPORT_PCB_GENCAD* aJob );
~DIALOG_GENCAD_EXPORT_OPTIONS();
///< Check whether an option has been selected.
bool GetOption( GENCAD_EXPORT_OPT aOption ) const;
///< Return all export settings.
std::map<GENCAD_EXPORT_OPT, bool> GetAllOptions() const;
///< Return the selected file path.
wxString GetFileName() const;
@ -77,6 +72,7 @@ protected:
///< Create checkboxes for GenCAD export options.
void createOptCheckboxes();
protected:
std::map<GENCAD_EXPORT_OPT, wxCheckBox*> m_options;
PCB_EDIT_FRAME* m_frame;
@ -89,5 +85,3 @@ protected:
STD_BITMAP_BUTTON* m_browseButton;
JOB_EXPORT_PCB_GENCAD* m_job;
};
#endif //__DIALOG_GENCAD_EXPORT_OPTIONS_H__

View File

@ -42,23 +42,12 @@
/* Driver function: processing starts here */
int BOARD_EDITOR_CONTROL::ExportGenCAD( const TOOL_EVENT& aEvent )
{
// Build default output file name
wxString path = m_frame->GetLastPath( LAST_PATH_GENCAD );
if( path.IsEmpty() )
{
wxFileName brdFile = m_frame->GetBoard()->GetFileName();
brdFile.SetExt( wxT( "cad" ) );
path = brdFile.GetFullPath();
}
DIALOG_GENCAD_EXPORT_OPTIONS optionsDialog( m_frame, path );
DIALOG_GENCAD_EXPORT_OPTIONS optionsDialog( m_frame, _( "Export to GenCAD" ), nullptr );
if( optionsDialog.ShowModal() == wxID_CANCEL )
return 0;
path = optionsDialog.GetFileName();
m_frame->SetLastPath( LAST_PATH_GENCAD, path );
wxString path = optionsDialog.GetFileName();
// Get options
bool flipBottomPads = optionsDialog.GetOption( FLIP_BOTTOM_PADS );

View File

@ -160,7 +160,7 @@ PCBNEW_JOBS_HANDLER::PCBNEW_JOBS_HANDLER( KIWAY* aKiway ) :
wxCHECK( gencadJob && editFrame, false );
DIALOG_GENCAD_EXPORT_OPTIONS dlg( editFrame, gencadJob );
DIALOG_GENCAD_EXPORT_OPTIONS dlg( editFrame, gencadJob->GetSettingsDialogTitle(), gencadJob );
return dlg.ShowModal() == wxID_OK;
} );
Register( "dxf", std::bind( &PCBNEW_JOBS_HANDLER::JobExportDxf, this, std::placeholders::_1 ),

View File

@ -50,8 +50,6 @@ const int pcbnewSchemaVersion = 5;
PCBNEW_SETTINGS::PCBNEW_SETTINGS()
: PCB_VIEWERS_SETTINGS_BASE( "pcbnew", pcbnewSchemaVersion ),
m_AuiPanels(),
m_ExportODBPP(),
m_ExportVrml(),
m_FootprintWizardList(),
m_FootprintChooser(),
m_Zones(),
@ -300,42 +298,6 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<bool>( "export_2581.compress",
&m_Export2581.compress, false ) );
m_params.emplace_back( new PARAM<int>( "export_odb.units",
&m_ExportODBPP.units, 0 ) );
m_params.emplace_back( new PARAM<int>( "export_odb.precision",
&m_ExportODBPP.precision, 6 ) );
m_params.emplace_back( new PARAM<int>( "export_odb.compress_format",
&m_ExportODBPP.compressFormat, 1 ) );
m_params.emplace_back( new PARAM<int>( "export_vrml.units",
&m_ExportVrml.units, 1 ) );
m_params.emplace_back( new PARAM<bool>( "export_vrml.no_unspecified",
&m_ExportVrml.no_unspecified, false ) );
m_params.emplace_back( new PARAM<bool>( "export_vrml.no_dnp",
&m_ExportVrml.no_dnp, false ) );
m_params.emplace_back( new PARAM<bool>( "export_vrml.copy_3d_models",
&m_ExportVrml.copy_3d_models, false ) );
m_params.emplace_back( new PARAM<bool>( "export_vrml.use_relative_paths",
&m_ExportVrml.use_relative_paths, false ) );
m_params.emplace_back( new PARAM<int>( "export_vrml.ref_units",
&m_ExportVrml.ref_units, 0 ) );
m_params.emplace_back( new PARAM<double>( "export_vrml.ref_x",
&m_ExportVrml.ref_x, 0 ) );
m_params.emplace_back( new PARAM<double>( "export_vrml.ref_y",
&m_ExportVrml.ref_y, 0 ) );
m_params.emplace_back( new PARAM<int>( "export_vrml.origin_mode",
&m_ExportVrml.origin_mode, 0 ) );
m_params.emplace_back( new PARAM<bool>( "export_d356.doNotExportUnconnectedPads",
&m_ExportD356.doNotExportUnconnectedPads, false ) );

View File

@ -171,28 +171,9 @@ public:
bool compress;
};
struct DIALOG_EXPORT_ODBPP
{
int precision;
int units;
int compressFormat;
};
struct DIALOG_EXPORT_VRML
{
int units;
bool no_unspecified;
bool no_dnp;
bool copy_3d_models;
bool use_relative_paths;
int ref_units;
double ref_x;
double ref_y;
int origin_mode;
};
struct DIALOG_EXPORT_D356
{
// Export D356 uses wxFileDialog, so there's no DIALOG_SHIM to save/restore control state
bool doNotExportUnconnectedPads;
};
@ -263,10 +244,6 @@ public:
DIALOG_EXPORT_2581 m_Export2581;
DIALOG_EXPORT_ODBPP m_ExportODBPP;
DIALOG_EXPORT_VRML m_ExportVrml;
DIALOG_EXPORT_D356 m_ExportD356;
DIALOG_FOOTPRINT_WIZARD_LIST m_FootprintWizardList;