Split DIALOG_EXPORT_STEP's class def to a header
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
#include <confirm.h>
|
||||
#include <kidialog.h>
|
||||
#include <widgets/std_bitmap_button.h>
|
||||
#include "dialog_export_step_base.h"
|
||||
#include "dialog_export_step.h"
|
||||
#include "dialog_export_step_process.h"
|
||||
#include <footprint.h>
|
||||
#include <kiface_base.h>
|
||||
@@ -65,104 +65,6 @@ static const std::map<wxString, int> c_formatExtToChoice = { { FILEEXT::StepFile
|
||||
{ FILEEXT::BrepFileExtension, 3 } };
|
||||
|
||||
|
||||
class DIALOG_EXPORT_STEP : public DIALOG_EXPORT_STEP_BASE
|
||||
{
|
||||
public:
|
||||
enum STEP_ORIGIN_OPTION
|
||||
{
|
||||
STEP_ORIGIN_0, // absolute coordinates
|
||||
STEP_ORIGIN_PLOT_AXIS, // origin is plot/drill axis origin
|
||||
STEP_ORIGIN_GRID_AXIS, // origin is grid origin
|
||||
STEP_ORIGIN_BOARD_CENTER, // origin is board center
|
||||
STEP_ORIGIN_USER, // origin is entered by user
|
||||
};
|
||||
|
||||
DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath );
|
||||
~DIALOG_EXPORT_STEP();
|
||||
|
||||
protected:
|
||||
void onBrowseClicked( wxCommandEvent& aEvent ) override;
|
||||
void onUpdateUnits( wxUpdateUIEvent& aEvent ) override;
|
||||
void onUpdateXPos( wxUpdateUIEvent& aEvent ) override;
|
||||
void onUpdateYPos( wxUpdateUIEvent& aEvent ) override;
|
||||
void onExportButton( wxCommandEvent& aEvent ) override;
|
||||
void onFormatChoice( wxCommandEvent& event ) override;
|
||||
void onCbExportComponents( wxCommandEvent& event ) override;
|
||||
void OnComponentModeChange( wxCommandEvent& event ) override;
|
||||
|
||||
int GetOrgUnitsChoice() const
|
||||
{
|
||||
return m_STEP_OrgUnitChoice->GetSelection();
|
||||
}
|
||||
|
||||
double GetXOrg() const
|
||||
{
|
||||
return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_STEP_Xorg->GetValue() );
|
||||
}
|
||||
|
||||
double GetYOrg()
|
||||
{
|
||||
return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_STEP_Yorg->GetValue() );
|
||||
}
|
||||
|
||||
STEP_ORIGIN_OPTION GetOriginOption();
|
||||
|
||||
bool GetNoUnspecifiedOption()
|
||||
{
|
||||
return m_cbRemoveUnspecified->GetValue();
|
||||
}
|
||||
|
||||
bool GetNoDNPOption()
|
||||
{
|
||||
return m_cbRemoveDNP->GetValue();
|
||||
}
|
||||
|
||||
bool GetSubstOption()
|
||||
{
|
||||
return m_cbSubstModels->GetValue();
|
||||
}
|
||||
|
||||
bool GetOverwriteFile()
|
||||
{
|
||||
return m_cbOverwriteFile->GetValue();
|
||||
}
|
||||
|
||||
// Called to update filename extension after the output file format is changed
|
||||
void OnFmtChoiceOptionChanged();
|
||||
|
||||
private:
|
||||
enum class COMPONENT_MODE
|
||||
{
|
||||
EXPORT_ALL,
|
||||
EXPORT_SELECTED,
|
||||
CUSTOM_FILTER
|
||||
};
|
||||
|
||||
PCB_EDIT_FRAME* m_parent;
|
||||
STEP_ORIGIN_OPTION m_origin; // The last preference for STEP origin option
|
||||
double m_userOriginX; // remember last User Origin X value
|
||||
double m_userOriginY; // remember last User Origin Y value
|
||||
int m_originUnits; // remember last units for User Origin
|
||||
bool m_noUnspecified; // remember last preference for No Unspecified Component
|
||||
bool m_noDNP; // remember last preference for No DNP Component
|
||||
static bool m_optimizeStep; // remember last preference for Optimize STEP file (stored only for the session)
|
||||
static bool m_exportBoardBody; // remember last preference to export board body (stored only for the session)
|
||||
static bool m_exportComponents; // remember last preference to export components (stored only for the session)
|
||||
static bool m_exportTracks; // remember last preference to export tracks and vias (stored only for the session)
|
||||
static bool m_exportPads; // remember last preference to export pads (stored only for the session)
|
||||
static bool m_exportZones; // remember last preference to export zones (stored only for the session)
|
||||
static bool m_exportInnerCopper; // remember last preference to export inner layers (stored only for the session)
|
||||
static bool m_exportSilkscreen; // remember last preference to export silkscreen (stored only for the session)
|
||||
static bool m_exportSoldermask; // remember last preference to export soldermask (stored only for the session)
|
||||
static bool m_fuseShapes; // remember last preference to fuse shapes (stored only for the session)
|
||||
wxString m_netFilter; // filter copper nets
|
||||
static wxString m_componentFilter; // filter component reference designators
|
||||
static COMPONENT_MODE m_componentMode;
|
||||
wxString m_boardPath; // path to the exported board file
|
||||
static int m_toleranceLastChoice; // Store m_tolerance option during a session
|
||||
static int m_formatLastChoice; // Store format option during a session
|
||||
};
|
||||
|
||||
|
||||
int DIALOG_EXPORT_STEP::m_toleranceLastChoice = -1; // Use default
|
||||
int DIALOG_EXPORT_STEP::m_formatLastChoice = -1; // Use default
|
||||
@@ -179,12 +81,12 @@ bool DIALOG_EXPORT_STEP::m_fuseShapes = false;
|
||||
DIALOG_EXPORT_STEP::COMPONENT_MODE DIALOG_EXPORT_STEP::m_componentMode = COMPONENT_MODE::EXPORT_ALL;
|
||||
wxString DIALOG_EXPORT_STEP::m_componentFilter;
|
||||
|
||||
DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath ) :
|
||||
DIALOG_EXPORT_STEP_BASE( aParent )
|
||||
DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aEditFrame, const wxString& aBoardPath ) :
|
||||
DIALOG_EXPORT_STEP_BASE( aEditFrame )
|
||||
{
|
||||
m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
|
||||
|
||||
m_parent = aParent;
|
||||
m_editFrame = aEditFrame;
|
||||
m_boardPath = aBoardPath;
|
||||
|
||||
SetupStandardButtons( { { wxID_OK, _( "Export" ) },
|
||||
@@ -192,11 +94,11 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
|
||||
|
||||
// Build default output file name
|
||||
// (last saved filename in project or built from board filename)
|
||||
wxString path = m_parent->GetLastPath( LAST_PATH_STEP );
|
||||
wxString path = m_editFrame->GetLastPath( LAST_PATH_STEP );
|
||||
|
||||
if( path.IsEmpty() )
|
||||
{
|
||||
wxFileName brdFile( m_parent->GetBoard()->GetFileName() );
|
||||
wxFileName brdFile( m_editFrame->GetBoard()->GetFileName() );
|
||||
brdFile.SetExt( wxT( "step" ) );
|
||||
path = brdFile.GetFullPath();
|
||||
}
|
||||
@@ -208,7 +110,7 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
|
||||
|
||||
SetFocus();
|
||||
|
||||
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
||||
PCBNEW_SETTINGS* cfg = m_editFrame->GetPcbNewSettings();
|
||||
|
||||
m_origin = static_cast<STEP_ORIGIN_OPTION>( cfg->m_ExportStep.origin_mode );
|
||||
|
||||
@@ -267,7 +169,7 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
|
||||
wxString bad_scales;
|
||||
size_t bad_count = 0;
|
||||
|
||||
for( FOOTPRINT* fp : aParent->GetBoard()->Footprints() )
|
||||
for( FOOTPRINT* fp : m_editFrame->GetBoard()->Footprints() )
|
||||
{
|
||||
for( const FP_3DMODEL& model : fp->Models() )
|
||||
{
|
||||
@@ -288,7 +190,7 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
|
||||
{
|
||||
wxString extendedMsg = _( "Non-unity scaled models:" ) + wxT( "\n" ) + bad_scales;
|
||||
|
||||
KIDIALOG msgDlg( m_parent, _( "Scaled models detected. "
|
||||
KIDIALOG msgDlg( m_editFrame, _( "Scaled models detected. "
|
||||
"Model scaling is not reliable for mechanical export." ),
|
||||
_( "Model Scale Warning" ), wxOK | wxICON_WARNING );
|
||||
msgDlg.SetExtendedMessage( extendedMsg );
|
||||
@@ -323,7 +225,7 @@ DIALOG_EXPORT_STEP::~DIALOG_EXPORT_STEP()
|
||||
|
||||
try
|
||||
{
|
||||
cfg = m_parent->GetPcbNewSettings();
|
||||
cfg = m_editFrame->GetPcbNewSettings();
|
||||
}
|
||||
catch( const std::runtime_error& e )
|
||||
{
|
||||
@@ -523,13 +425,13 @@ void DIALOG_EXPORT_STEP::OnComponentModeChange( wxCommandEvent& event )
|
||||
void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxString path = m_outputFileName->GetValue();
|
||||
m_parent->SetLastPath( LAST_PATH_STEP, path );
|
||||
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
|
||||
{
|
||||
return m_parent->GetBoard()->ResolveTextVar( token, 0 );
|
||||
return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
|
||||
};
|
||||
|
||||
path = ExpandTextVars( path, &textResolver );
|
||||
@@ -583,7 +485,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
|
||||
|
||||
// Arc to segment approx error (not critical here: we do not use the outline shape):
|
||||
int maxError = pcbIUScale.mmToIU( 0.005 );
|
||||
bool success = BuildBoardPolygonOutlines( m_parent->GetBoard(), outline, maxError,
|
||||
bool success = BuildBoardPolygonOutlines( m_editFrame->GetBoard(), outline, maxError,
|
||||
chainingEpsilon, nullptr );
|
||||
if( !success )
|
||||
{
|
||||
@@ -691,7 +593,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
|
||||
case COMPONENT_MODE::EXPORT_SELECTED:
|
||||
{
|
||||
wxArrayString components;
|
||||
SELECTION& selection = m_parent->GetCurrentSelection();
|
||||
SELECTION& selection = m_editFrame->GetCurrentSelection();
|
||||
|
||||
std::for_each( selection.begin(), selection.end(),
|
||||
[&components]( EDA_ITEM* item )
|
||||
@@ -748,7 +650,7 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
|
||||
|
||||
case STEP_ORIGIN_BOARD_CENTER:
|
||||
{
|
||||
BOX2I bbox = m_parent->GetBoard()->ComputeBoundingBox( true, false );
|
||||
BOX2I bbox = m_editFrame->GetBoard()->ComputeBoundingBox( true, false );
|
||||
double xOrg = pcbIUScale.IUTomm( bbox.GetCenter().x );
|
||||
double yOrg = pcbIUScale.IUTomm( bbox.GetCenter().y );
|
||||
LOCALE_IO dummy;
|
||||
@@ -778,3 +680,15 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent )
|
||||
DIALOG_EXPORT_STEP_LOG* log = new DIALOG_EXPORT_STEP_LOG( this, cmdK2S );
|
||||
log->ShowModal();
|
||||
}
|
||||
|
||||
|
||||
double DIALOG_EXPORT_STEP::GetXOrg() const
|
||||
{
|
||||
return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_STEP_Xorg->GetValue() );
|
||||
}
|
||||
|
||||
|
||||
double DIALOG_EXPORT_STEP::GetYOrg()
|
||||
{
|
||||
return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_STEP_Yorg->GetValue() );
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 Cirilo Bernardo
|
||||
* Copyright (C) 2016-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "dialog_export_step_base.h"
|
||||
|
||||
class PCB_EDIT_FRAME;
|
||||
|
||||
class DIALOG_EXPORT_STEP : public DIALOG_EXPORT_STEP_BASE
|
||||
{
|
||||
public:
|
||||
enum STEP_ORIGIN_OPTION
|
||||
{
|
||||
STEP_ORIGIN_0, // absolute coordinates
|
||||
STEP_ORIGIN_PLOT_AXIS, // origin is plot/drill axis origin
|
||||
STEP_ORIGIN_GRID_AXIS, // origin is grid origin
|
||||
STEP_ORIGIN_BOARD_CENTER, // origin is board center
|
||||
STEP_ORIGIN_USER, // origin is entered by user
|
||||
};
|
||||
|
||||
DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aEditFrame, const wxString& aBoardPath );
|
||||
~DIALOG_EXPORT_STEP();
|
||||
|
||||
protected:
|
||||
void onBrowseClicked( wxCommandEvent& aEvent ) override;
|
||||
void onUpdateUnits( wxUpdateUIEvent& aEvent ) override;
|
||||
void onUpdateXPos( wxUpdateUIEvent& aEvent ) override;
|
||||
void onUpdateYPos( wxUpdateUIEvent& aEvent ) override;
|
||||
void onExportButton( wxCommandEvent& aEvent ) override;
|
||||
void onFormatChoice( wxCommandEvent& event ) override;
|
||||
void onCbExportComponents( wxCommandEvent& event ) override;
|
||||
void OnComponentModeChange( wxCommandEvent& event ) override;
|
||||
|
||||
int GetOrgUnitsChoice() const
|
||||
{
|
||||
return m_STEP_OrgUnitChoice->GetSelection();
|
||||
}
|
||||
|
||||
double GetXOrg() const;
|
||||
|
||||
double GetYOrg();
|
||||
|
||||
STEP_ORIGIN_OPTION GetOriginOption();
|
||||
|
||||
bool GetNoUnspecifiedOption()
|
||||
{
|
||||
return m_cbRemoveUnspecified->GetValue();
|
||||
}
|
||||
|
||||
bool GetNoDNPOption()
|
||||
{
|
||||
return m_cbRemoveDNP->GetValue();
|
||||
}
|
||||
|
||||
bool GetSubstOption()
|
||||
{
|
||||
return m_cbSubstModels->GetValue();
|
||||
}
|
||||
|
||||
bool GetOverwriteFile()
|
||||
{
|
||||
return m_cbOverwriteFile->GetValue();
|
||||
}
|
||||
|
||||
// Called to update filename extension after the output file format is changed
|
||||
void OnFmtChoiceOptionChanged();
|
||||
|
||||
private:
|
||||
enum class COMPONENT_MODE
|
||||
{
|
||||
EXPORT_ALL,
|
||||
EXPORT_SELECTED,
|
||||
CUSTOM_FILTER
|
||||
};
|
||||
|
||||
PCB_EDIT_FRAME* m_editFrame;
|
||||
STEP_ORIGIN_OPTION m_origin; // The last preference for STEP origin option
|
||||
double m_userOriginX; // remember last User Origin X value
|
||||
double m_userOriginY; // remember last User Origin Y value
|
||||
int m_originUnits; // remember last units for User Origin
|
||||
bool m_noUnspecified; // remember last preference for No Unspecified Component
|
||||
bool m_noDNP; // remember last preference for No DNP Component
|
||||
static bool m_optimizeStep; // remember last preference for Optimize STEP file (stored only for the session)
|
||||
static bool m_exportBoardBody; // remember last preference to export board body (stored only for the session)
|
||||
static bool m_exportComponents; // remember last preference to export components (stored only for the session)
|
||||
static bool m_exportTracks; // remember last preference to export tracks and vias (stored only for the session)
|
||||
static bool m_exportPads; // remember last preference to export pads (stored only for the session)
|
||||
static bool m_exportZones; // remember last preference to export zones (stored only for the session)
|
||||
static bool m_exportInnerCopper; // remember last preference to export inner layers (stored only for the session)
|
||||
static bool m_exportSilkscreen; // remember last preference to export silkscreen (stored only for the session)
|
||||
static bool m_exportSoldermask; // remember last preference to export soldermask (stored only for the session)
|
||||
static bool m_fuseShapes; // remember last preference to fuse shapes (stored only for the session)
|
||||
wxString m_netFilter; // filter copper nets
|
||||
static wxString m_componentFilter; // filter component reference designators
|
||||
static COMPONENT_MODE m_componentMode;
|
||||
wxString m_boardPath; // path to the exported board file
|
||||
static int m_toleranceLastChoice; // Store m_tolerance option during a session
|
||||
static int m_formatLastChoice; // Store format option during a session
|
||||
};
|
||||
Reference in New Issue
Block a user