Split off the netlist export content helper but it's advancedcfg

This commit is contained in:
Marek Roszko 2022-06-11 23:09:47 -04:00
parent 415af260a4
commit 87f10ea206
3 changed files with 82 additions and 55 deletions

View File

@ -69,6 +69,8 @@
#include <wx/filedlg.h>
#include <wx/log.h>
#include <widgets/legacyfiledlg_netlist_options.h>
using namespace std::placeholders;
@ -124,56 +126,6 @@ public:
};
/**
* Helper widget to add controls to a wxFileDialog to set netlist configuration options.
*/
class NETLIST_OPTIONS_HELPER : public wxPanel
{
public:
NETLIST_OPTIONS_HELPER( wxWindow* aParent )
: wxPanel( aParent )
{
m_cbOmitExtras = new wxCheckBox( this, wxID_ANY, _( "Omit extra information" ) );
m_cbOmitNets = new wxCheckBox( this, wxID_ANY, _( "Omit nets" ) );
m_cbOmitFpUuids = new wxCheckBox( this, wxID_ANY,
_( "Do not prefix path with footprint UUID." ) );
wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
sizer->Add( m_cbOmitExtras, 0, wxALL, 5 );
sizer->Add( m_cbOmitNets, 0, wxALL, 5 );
sizer->Add( m_cbOmitFpUuids, 0, wxALL, 5 );
SetSizerAndFit( sizer );
}
int GetNetlistOptions() const
{
int options = 0;
if( m_cbOmitExtras->GetValue() )
options |= CTL_OMIT_EXTRA;
if( m_cbOmitNets->GetValue() )
options |= CTL_OMIT_NETS;
if( m_cbOmitFpUuids->GetValue() )
options |= CTL_OMIT_FP_UUID;
return options;
}
static wxWindow* Create( wxWindow* aParent )
{
return new NETLIST_OPTIONS_HELPER( aParent );
}
protected:
wxCheckBox* m_cbOmitExtras;
wxCheckBox* m_cbOmitNets;
wxCheckBox* m_cbOmitFpUuids;
};
BOARD_EDITOR_CONTROL::BOARD_EDITOR_CONTROL() :
PCB_TOOL_BASE( "pcbnew.EditorControl" ),
m_frame( nullptr ),
@ -478,7 +430,7 @@ int BOARD_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
_( "KiCad board netlist files" ) + AddFileExtListToFilter( { "pcb_net" } ),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
dlg.SetExtraControlCreator( &NETLIST_OPTIONS_HELPER::Create );
dlg.SetExtraControlCreator( &LEGACYFILEDLG_NETLIST_OPTIONS::Create );
if( dlg.ShowModal() == wxID_CANCEL )
return 0;
@ -494,8 +446,8 @@ int BOARD_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
return 0;
}
const NETLIST_OPTIONS_HELPER* noh =
dynamic_cast<const NETLIST_OPTIONS_HELPER*>( dlg.GetExtraControl() );
const LEGACYFILEDLG_NETLIST_OPTIONS* noh =
dynamic_cast<const LEGACYFILEDLG_NETLIST_OPTIONS*>( dlg.GetExtraControl() );
wxCHECK( noh, 0 );
NETLIST netlist;

View File

@ -0,0 +1,75 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef LEGACYFILEDLG_NETLIST_OPTIONS_H_
#define LEGACYFILEDLG_NETLIST_OPTIONS_H_
#include <wx/checkbox.h>
#include <wx/panel.h>
#include <wx/sizer.h>
/**
* Helper widget to add controls to a wxFileDialog to set netlist configuration options.
*/
class LEGACYFILEDLG_NETLIST_OPTIONS : public wxPanel
{
public:
LEGACYFILEDLG_NETLIST_OPTIONS( wxWindow* aParent ) : wxPanel( aParent )
{
m_cbOmitExtras = new wxCheckBox( this, wxID_ANY, _( "Omit extra information" ) );
m_cbOmitNets = new wxCheckBox( this, wxID_ANY, _( "Omit nets" ) );
m_cbOmitFpUuids =
new wxCheckBox( this, wxID_ANY, _( "Do not prefix path with footprint UUID." ) );
wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
sizer->Add( m_cbOmitExtras, 0, wxALL, 5 );
sizer->Add( m_cbOmitNets, 0, wxALL, 5 );
sizer->Add( m_cbOmitFpUuids, 0, wxALL, 5 );
SetSizerAndFit( sizer );
}
int GetNetlistOptions() const
{
int options = 0;
if( m_cbOmitExtras->GetValue() )
options |= CTL_OMIT_EXTRA;
if( m_cbOmitNets->GetValue() )
options |= CTL_OMIT_NETS;
if( m_cbOmitFpUuids->GetValue() )
options |= CTL_OMIT_FP_UUID;
return options;
}
static wxWindow* Create( wxWindow* aParent )
{
return new LEGACYFILEDLG_NETLIST_OPTIONS( aParent );
}
protected:
wxCheckBox* m_cbOmitExtras;
wxCheckBox* m_cbOmitNets;
wxCheckBox* m_cbOmitFpUuids;
};
#endif

View File

@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LEGACYFILEDLG_SAVE_PROJ_H
#define LEGACYFILEDLG_SVE_PROJ_H
#ifndef LEGACYFILEDLG_SAVE_PROJ_H_
#define LEGACYFILEDLG_SAVE_PROJ_H_
#include <wx/checkbox.h>
#include <wx/panel.h>