2017-04-02 12:09:01 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Oliver Walters
|
2023-01-27 14:18:32 +00:00
|
|
|
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-04-02 12:09:01 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2021-07-03 20:43:30 +00:00
|
|
|
#ifndef DIALOG_SYMBOL_FIELDS_TABLE_H
|
|
|
|
#define DIALOG_SYMBOL_FIELDS_TABLE_H
|
2017-04-02 12:09:01 +00:00
|
|
|
|
|
|
|
|
2021-07-03 20:43:30 +00:00
|
|
|
#include <dialog_symbol_fields_table_base.h>
|
2017-04-02 12:09:01 +00:00
|
|
|
#include <sch_reference_list.h>
|
2023-08-14 14:41:28 +00:00
|
|
|
#include <schematic.h>
|
2017-04-02 12:09:01 +00:00
|
|
|
|
2023-08-14 14:41:28 +00:00
|
|
|
wxDECLARE_EVENT( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, wxCommandEvent );
|
2018-04-17 10:34:48 +00:00
|
|
|
|
2023-02-09 20:13:05 +00:00
|
|
|
class SCHEMATIC_SETTINGS;
|
|
|
|
struct BOM_PRESET;
|
2023-03-09 15:54:57 +00:00
|
|
|
struct BOM_FMT_PRESET;
|
2018-04-17 10:34:48 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
|
|
|
class FIELDS_EDITOR_GRID_DATA_MODEL;
|
|
|
|
|
2017-04-02 12:09:01 +00:00
|
|
|
|
2023-08-14 14:41:28 +00:00
|
|
|
class DIALOG_SYMBOL_FIELDS_TABLE : public DIALOG_SYMBOL_FIELDS_TABLE_BASE, public SCHEMATIC_LISTENER
|
2017-04-02 12:09:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-03 20:43:30 +00:00
|
|
|
DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent );
|
|
|
|
virtual ~DIALOG_SYMBOL_FIELDS_TABLE();
|
2017-04-02 12:09:01 +00:00
|
|
|
|
2020-01-09 00:57:39 +00:00
|
|
|
bool TransferDataToWindow() override;
|
2018-04-17 10:34:48 +00:00
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
|
2023-09-20 18:54:14 +00:00
|
|
|
void ShowEditTab();
|
2023-09-20 15:12:03 +00:00
|
|
|
void ShowExportTab();
|
|
|
|
|
2017-04-02 12:09:01 +00:00
|
|
|
private:
|
2023-08-01 17:28:56 +00:00
|
|
|
void SetupColumnProperties( int aCol );
|
|
|
|
void SetupAllColumnProperties();
|
2023-03-15 00:03:57 +00:00
|
|
|
void AddField( const wxString& displayName, const wxString& aCanonicalName, bool show,
|
|
|
|
bool groupBy, bool addedByUser = false );
|
2021-07-16 20:13:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct the rows of m_fieldsCtrl and the columns of m_dataModel from a union of all
|
|
|
|
* field names in use.
|
|
|
|
*/
|
2018-04-17 10:34:48 +00:00
|
|
|
void LoadFieldNames();
|
2017-04-02 12:09:01 +00:00
|
|
|
|
2018-04-17 10:34:48 +00:00
|
|
|
void OnColSort( wxGridEvent& aEvent );
|
2023-01-30 17:16:33 +00:00
|
|
|
void OnColMove( wxGridEvent& aEvent );
|
2023-02-23 19:10:50 +00:00
|
|
|
void OnColLabelChange( wxDataViewEvent& aEvent );
|
2023-08-07 17:49:27 +00:00
|
|
|
void OnTableRangeSelected( wxGridRangeSelectEvent& aEvent );
|
2017-04-18 09:25:02 +00:00
|
|
|
|
2018-04-19 22:13:19 +00:00
|
|
|
void OnColumnItemToggled( wxDataViewEvent& event ) override;
|
2020-11-15 16:08:31 +00:00
|
|
|
void OnGroupSymbolsToggled( wxCommandEvent& event ) override;
|
2023-03-30 14:17:09 +00:00
|
|
|
void OnExcludeDNPToggled( wxCommandEvent& event ) override;
|
2024-04-15 14:06:08 +00:00
|
|
|
void OnShowExcludedToggled( wxCommandEvent& event ) override;
|
2020-11-15 16:08:31 +00:00
|
|
|
void OnRegroupSymbols( wxCommandEvent& aEvent ) override;
|
2023-08-07 19:04:46 +00:00
|
|
|
void OnScopeChanged( wxCommandEvent& aEvent ) override;
|
|
|
|
void UpdateScope();
|
2018-04-19 22:13:19 +00:00
|
|
|
void OnTableValueChanged( wxGridEvent& event ) override;
|
2018-05-12 22:04:11 +00:00
|
|
|
void OnTableCellClick( wxGridEvent& event ) override;
|
2018-04-19 22:13:19 +00:00
|
|
|
void OnTableItemContextMenu( wxGridEvent& event ) override;
|
2020-04-21 15:15:04 +00:00
|
|
|
void OnTableColSize( wxGridSizeEvent& event ) override;
|
2018-04-19 22:13:19 +00:00
|
|
|
void OnSizeFieldList( wxSizeEvent& event ) override;
|
2018-05-23 12:12:01 +00:00
|
|
|
void OnAddField( wxCommandEvent& event ) override;
|
2022-04-12 20:13:26 +00:00
|
|
|
void OnRemoveField( wxCommandEvent& event ) override;
|
2023-01-27 14:18:32 +00:00
|
|
|
void OnRenameField( wxCommandEvent& event ) override;
|
2022-05-09 13:41:00 +00:00
|
|
|
void OnExport( wxCommandEvent& aEvent ) override;
|
2018-04-19 22:13:19 +00:00
|
|
|
void OnSaveAndContinue( wxCommandEvent& aEvent ) override;
|
2022-04-17 19:02:05 +00:00
|
|
|
void OnCancel( wxCommandEvent& aEvent ) override;
|
|
|
|
void OnClose( wxCloseEvent& aEvent ) override;
|
2023-09-27 13:13:55 +00:00
|
|
|
void OnOk( wxCommandEvent& aEvent ) override;
|
2022-04-17 19:02:05 +00:00
|
|
|
void OnFilterText( wxCommandEvent& aEvent ) override;
|
|
|
|
void OnFilterMouseMoved( wxMouseEvent& event ) override;
|
2022-09-11 12:28:53 +00:00
|
|
|
void OnFieldsCtrlSelectionChanged( wxDataViewEvent& event ) override;
|
2023-02-09 20:13:05 +00:00
|
|
|
|
2023-03-08 19:31:51 +00:00
|
|
|
void OnOutputFileBrowseClicked( wxCommandEvent& event ) override;
|
2023-03-09 15:54:57 +00:00
|
|
|
void OnPageChanged( wxNotebookEvent& event ) override;
|
2023-02-28 18:37:04 +00:00
|
|
|
void OnPreviewRefresh( wxCommandEvent& event ) override;
|
2023-03-09 15:54:57 +00:00
|
|
|
void PreviewRefresh();
|
2023-02-28 18:37:04 +00:00
|
|
|
|
2023-02-09 20:13:05 +00:00
|
|
|
std::vector<BOM_PRESET> GetUserBomPresets() const;
|
|
|
|
void SetUserBomPresets( std::vector<BOM_PRESET>& aPresetList );
|
|
|
|
void ApplyBomPreset( const wxString& aPresetName );
|
|
|
|
void ApplyBomPreset( const BOM_PRESET& aPreset );
|
2021-03-21 17:31:23 +00:00
|
|
|
|
2023-04-01 12:57:59 +00:00
|
|
|
/// Returns a formatting configuration corresponding to the values in the UI controls
|
|
|
|
/// of the dialog.
|
|
|
|
BOM_FMT_PRESET GetCurrentBomFmtSettings();
|
2023-03-09 15:54:57 +00:00
|
|
|
std::vector<BOM_FMT_PRESET> GetUserBomFmtPresets() const;
|
|
|
|
void SetUserBomFmtPresets( std::vector<BOM_FMT_PRESET>& aPresetList );
|
|
|
|
void ApplyBomFmtPreset( const wxString& aPresetName );
|
|
|
|
void ApplyBomFmtPreset( const BOM_FMT_PRESET& aPreset );
|
|
|
|
|
2023-08-20 20:13:07 +00:00
|
|
|
// Schematic listener event handlers
|
2023-08-14 14:41:28 +00:00
|
|
|
void OnSchItemsAdded( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) override;
|
|
|
|
void OnSchItemsRemoved( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) override;
|
|
|
|
void OnSchItemsChanged( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aSchItem ) override;
|
2023-08-20 20:13:07 +00:00
|
|
|
void OnSchSheetChanged( SCHEMATIC& aSch ) override;
|
2023-08-14 14:41:28 +00:00
|
|
|
|
2023-08-21 12:55:26 +00:00
|
|
|
void EnableSelectionEvents();
|
|
|
|
void DisableSelectionEvents();
|
|
|
|
|
2022-09-12 22:38:36 +00:00
|
|
|
private:
|
2024-01-28 23:11:08 +00:00
|
|
|
SCH_REFERENCE_LIST getSymbolReferences( SCH_SYMBOL* aSymbol, SCH_REFERENCE_LIST& aCachedRefs );
|
2023-08-14 18:19:00 +00:00
|
|
|
SCH_REFERENCE_LIST getSheetSymbolReferences( SCH_SHEET& aSheet );
|
2023-08-14 14:41:28 +00:00
|
|
|
|
2023-02-09 20:13:05 +00:00
|
|
|
void syncBomPresetSelection();
|
|
|
|
void rebuildBomPresetsWidget();
|
|
|
|
void updateBomPresetSelection( const wxString& aName );
|
|
|
|
void onBomPresetChanged( wxCommandEvent& aEvent );
|
|
|
|
void doApplyBomPreset( const BOM_PRESET& aPreset );
|
|
|
|
void loadDefaultBomPresets();
|
|
|
|
|
|
|
|
std::map<wxString, BOM_PRESET> m_bomPresets;
|
|
|
|
BOM_PRESET* m_currentBomPreset;
|
|
|
|
BOM_PRESET* m_lastSelectedBomPreset;
|
|
|
|
wxArrayString m_bomPresetMRU;
|
|
|
|
|
2023-03-09 15:54:57 +00:00
|
|
|
void syncBomFmtPresetSelection();
|
|
|
|
void rebuildBomFmtPresetsWidget();
|
|
|
|
void updateBomFmtPresetSelection( const wxString& aName );
|
|
|
|
void onBomFmtPresetChanged( wxCommandEvent& aEvent );
|
|
|
|
void doApplyBomFmtPreset( const BOM_FMT_PRESET& aPreset );
|
|
|
|
void loadDefaultBomFmtPresets();
|
|
|
|
|
|
|
|
std::map<wxString, BOM_FMT_PRESET> m_bomFmtPresets;
|
|
|
|
BOM_FMT_PRESET* m_currentBomFmtPreset;
|
|
|
|
BOM_FMT_PRESET* m_lastSelectedBomFmtPreset;
|
|
|
|
wxArrayString m_bomFmtPresetMRU;
|
|
|
|
|
2023-03-29 14:53:11 +00:00
|
|
|
void savePresetsToSchematic();
|
|
|
|
|
2021-03-21 17:31:23 +00:00
|
|
|
SCH_EDIT_FRAME* m_parent;
|
2023-02-23 19:10:50 +00:00
|
|
|
int m_fieldNameColWidth;
|
|
|
|
int m_labelColWidth;
|
2021-03-21 17:31:23 +00:00
|
|
|
int m_showColWidth;
|
|
|
|
int m_groupByColWidth;
|
|
|
|
|
|
|
|
SCH_REFERENCE_LIST m_symbolsList;
|
|
|
|
FIELDS_EDITOR_GRID_DATA_MODEL* m_dataModel;
|
2023-02-09 20:13:05 +00:00
|
|
|
|
|
|
|
SCHEMATIC_SETTINGS& m_schSettings;
|
2017-04-02 12:09:01 +00:00
|
|
|
};
|
|
|
|
|
2021-07-03 20:43:30 +00:00
|
|
|
#endif /* DIALOG_SYMBOL_FIELDS_TABLE_H */
|