2011-10-17 16:01:27 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-06-05 14:26:39 +02:00
|
|
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2018-03-13 17:59:46 -04:00
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-17 16:01:27 -04:00
|
|
|
*
|
2018-01-07 21:05:03 -07: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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2011-10-17 16:01:27 -04:00
|
|
|
*
|
2018-01-07 21:05:03 -07:00
|
|
|
* 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.
|
2011-10-17 16:01:27 -04:00
|
|
|
*
|
2018-01-07 21:05:03 -07:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-10-17 16:01:27 -04:00
|
|
|
*/
|
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
#ifndef WX_GERBER_STRUCT_H
|
|
|
|
#define WX_GERBER_STRUCT_H
|
|
|
|
|
2022-12-28 22:03:03 +00:00
|
|
|
#include <file_history.h>
|
2019-06-08 23:14:57 +01:00
|
|
|
#include <eda_draw_frame.h>
|
2021-07-29 10:47:43 +01:00
|
|
|
#include <layer_ids.h>
|
2012-09-12 19:28:55 +02:00
|
|
|
#include <gerbview.h>
|
2018-01-29 13:26:58 +01:00
|
|
|
#include <gbr_layout.h>
|
2018-01-29 11:37:29 +01:00
|
|
|
#include <page_info.h>
|
2018-01-29 13:26:58 +01:00
|
|
|
#include <gbr_display_options.h>
|
2011-03-02 10:24:39 -05:00
|
|
|
|
2024-09-21 08:22:19 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2013-03-31 15:27:46 +02:00
|
|
|
#define NO_AVAILABLE_LAYERS UNDEFINED_LAYER
|
2011-03-02 10:24:39 -05:00
|
|
|
|
2010-12-17 21:34:29 +01:00
|
|
|
class DCODE_SELECTION_BOX;
|
2011-09-23 09:57:12 -04:00
|
|
|
class GERBER_LAYER_WIDGET;
|
2012-05-04 19:44:42 +02:00
|
|
|
class GBR_LAYER_BOX_SELECTOR;
|
2011-09-23 09:57:12 -04:00
|
|
|
class GERBER_DRAW_ITEM;
|
2016-06-17 20:00:29 +02:00
|
|
|
class GERBER_FILE_IMAGE;
|
|
|
|
class GERBER_FILE_IMAGE_LIST;
|
2021-09-07 21:34:10 +01:00
|
|
|
class GERBVIEW_SETTINGS;
|
2024-07-08 22:00:53 -07:00
|
|
|
class LSET;
|
2017-01-26 10:45:28 +01:00
|
|
|
class REPORTER;
|
2020-07-30 00:50:25 +01:00
|
|
|
class SELECTION;
|
2021-06-03 18:32:32 -04:00
|
|
|
class wxStaticText;
|
2025-01-03 14:00:58 -08:00
|
|
|
|
|
|
|
#ifndef __linux__
|
2024-09-21 08:22:19 +00:00
|
|
|
class NL_GERBVIEW_PLUGIN;
|
2025-01-03 14:00:58 -08:00
|
|
|
#else
|
|
|
|
class SPNAV_2D_PLUGIN;
|
|
|
|
#endif
|
2011-09-23 09:57:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* The main window used in GerbView.
|
2011-09-23 09:57:12 -04:00
|
|
|
*/
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2015-03-02 18:29:18 +01:00
|
|
|
#define GERBVIEW_FRAME_NAME wxT( "GerberFrame" )
|
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
class GERBVIEW_FRAME : public EDA_DRAW_FRAME
|
2009-07-29 13:10:36 +00:00
|
|
|
{
|
2020-10-09 00:51:05 +01:00
|
|
|
public:
|
|
|
|
GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent );
|
|
|
|
~GERBVIEW_FRAME();
|
|
|
|
|
|
|
|
void doCloseWindow() override;
|
|
|
|
|
|
|
|
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
|
|
|
|
|
2018-02-20 21:58:53 -05:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Load a list of Gerber and NC drill files and updates the view based on them.
|
2020-10-09 00:51:05 +01:00
|
|
|
*
|
2018-02-20 21:58:53 -05:00
|
|
|
* @param aPath is the base path for the filenames if they are relative
|
|
|
|
* @param aFilenameList is a list of filenames to load
|
2021-08-16 13:38:04 -04:00
|
|
|
* @param aFileType is a list of type of files to load (0 = Gerber, 1 = NC drill, 2 Autodetect)
|
|
|
|
* Successfully autodetected files will have their type changed
|
2018-02-20 21:58:53 -05:00
|
|
|
* @return true if every file loaded successfully
|
|
|
|
*/
|
2021-08-16 13:38:04 -04:00
|
|
|
bool LoadListOfGerberAndDrillFiles( const wxString& aPath, const wxArrayString& aFilenameList,
|
|
|
|
std::vector<int>* aFileType );
|
2018-02-20 21:58:53 -05:00
|
|
|
|
2018-03-13 17:59:46 -04:00
|
|
|
void UpdateStatusBar() override;
|
2011-03-14 22:19:13 +01:00
|
|
|
|
2021-09-07 21:34:10 +01:00
|
|
|
GERBVIEW_SETTINGS* gvconfig() const;
|
|
|
|
|
|
|
|
/// Updates the GAL with display settings changes
|
|
|
|
void ApplyDisplaySettingsToGAL();
|
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Test whether a given element category is visible. Keep this as an inline function.
|
|
|
|
*
|
2018-07-07 09:50:13 +01:00
|
|
|
* @param aLayerID is an item id from the enum GERBVIEW_LAYER_ID
|
2012-05-04 19:44:42 +02:00
|
|
|
* @return bool - true if the element is visible.
|
2010-02-03 14:05:17 +00:00
|
|
|
*/
|
2018-07-07 09:50:13 +01:00
|
|
|
bool IsElementVisible( int aLayerID ) const;
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Change the visibility of an element category.
|
|
|
|
*
|
2017-03-12 23:19:33 -04:00
|
|
|
* @param aItemIdVisible is an item id from the enum GERBVIEW_LAYER_ID
|
2012-05-04 19:44:42 +02:00
|
|
|
* @param aNewState = The new visibility state of the element category
|
2017-03-12 23:19:33 -04:00
|
|
|
* (see enum PCB)
|
2012-05-04 19:44:42 +02:00
|
|
|
*/
|
2018-07-07 09:50:13 +01:00
|
|
|
void SetElementVisibility( int aLayerID, bool aNewState );
|
2012-05-04 19:44:42 +02:00
|
|
|
|
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* @param aVisible true if the grid must be shown.
|
2010-02-03 14:05:17 +00:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void SetGridVisibility( bool aVisible ) override;
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* A proxy function that calls the correspondent function in m_BoardSettings.
|
|
|
|
*
|
|
|
|
* @return #LSET of the visible layers
|
2010-02-03 14:05:17 +00:00
|
|
|
*/
|
2019-04-10 14:40:01 +01:00
|
|
|
LSET GetVisibleLayers() const;
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* A proxy function that calls the correspondent function in m_BoardSettings.
|
|
|
|
*
|
|
|
|
* @param aLayerMask The new set of visible layers
|
2010-02-03 14:05:17 +00:00
|
|
|
*/
|
2025-03-23 20:33:22 +00:00
|
|
|
void SetVisibleLayers( const LSET& aLayerMask );
|
2010-02-03 14:05:17 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Test whether a given layer is visible.
|
|
|
|
*
|
|
|
|
* @param aLayer The layer to be tested (still 0-31!)
|
|
|
|
* @return true if the layer is visible.
|
2012-05-04 19:44:42 +02:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
bool IsLayerVisible( int aLayer ) const;
|
2012-05-04 19:44:42 +02:00
|
|
|
|
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Return the color of a gerber visible element.
|
2010-02-03 14:05:17 +00:00
|
|
|
*/
|
2018-07-07 09:50:13 +01:00
|
|
|
COLOR4D GetVisibleElementColor( int aLayerID );
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2021-07-26 13:28:37 -04:00
|
|
|
void SetVisibleElementColor( int aLayerID, const COLOR4D& aColor );
|
2010-12-17 21:34:29 +01:00
|
|
|
|
2017-02-20 17:57:41 +01:00
|
|
|
COLOR4D GetLayerColor( int aLayer ) const;
|
2021-07-26 13:28:37 -04:00
|
|
|
void SetLayerColor( int aLayer, const COLOR4D& aColor );
|
2010-02-03 14:05:17 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Change out all the layers in m_Layers; called upon loading new gerber files.
|
2010-02-03 14:05:17 +00:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void ReFillLayerWidget();
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2010-02-04 09:08:08 +00:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* change the currently active layer to \a aLayer and update the #GERBER_LAYER_WIDGET.
|
2010-02-04 09:08:08 +00:00
|
|
|
*/
|
2017-09-17 18:43:20 -04:00
|
|
|
void SetActiveLayer( int aLayer, bool doLayerWidgetUpdate = true );
|
2010-12-17 21:34:29 +01:00
|
|
|
|
2010-02-04 09:08:08 +00:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Return the active layer.
|
2010-02-04 09:08:08 +00:00
|
|
|
*/
|
2020-06-13 22:09:02 +01:00
|
|
|
int GetActiveLayer() const { return m_activeLayer; }
|
2010-12-17 21:34:29 +01:00
|
|
|
|
2011-03-02 10:24:39 -05:00
|
|
|
/**
|
2021-08-16 09:52:25 -04:00
|
|
|
* Find the next empty layer.
|
2021-01-26 10:23:37 -05:00
|
|
|
*
|
|
|
|
* If no empty layers are found, #NO_AVAILABLE_LAYERS is return.
|
|
|
|
*
|
|
|
|
* @return The first empty layer found or #NO_AVAILABLE_LAYERS.
|
2011-03-02 10:24:39 -05:00
|
|
|
*/
|
2021-08-16 09:52:25 -04:00
|
|
|
int getNextAvailableLayer() const;
|
2011-03-02 10:24:39 -05:00
|
|
|
|
2010-02-04 09:08:08 +00:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Update the currently "selected" layer within the #GERBER_LAYER_WIDGET.
|
2017-09-17 18:43:20 -04:00
|
|
|
* The currently active layer is defined by the return value of GetActiveLayer().
|
2010-02-04 09:08:08 +00:00
|
|
|
* <p>
|
2020-06-12 11:58:56 +01:00
|
|
|
* This function cannot be inline without including layer_widget.h in here and we do not
|
|
|
|
* want to do that.
|
2010-02-04 09:08:08 +00:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void syncLayerWidget();
|
2010-02-04 09:08:08 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Update the currently "selected" layer within m_SelLayerBox.
|
2020-06-12 11:58:56 +01:00
|
|
|
* The currently active layer, as defined by the return value of GetActiveLayer().
|
2021-01-26 10:23:37 -05:00
|
|
|
*
|
|
|
|
* @param aRebuildLayerBox true to rebuild the layer box of false to just update the selection.
|
2010-02-04 09:08:08 +00:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void syncLayerBox( bool aRebuildLayerBox = false );
|
2010-02-04 09:08:08 +00:00
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Display the short filename (if exists) of the selected layer on the caption of the main
|
|
|
|
* GerbView window and some other parameters.
|
|
|
|
*
|
|
|
|
* - Name of the layer (found in the gerber file: LN <name> command) in the status bar
|
|
|
|
* - Name of the Image (found in the gerber file: IN <name> command) in the status bar
|
2010-10-06 19:28:07 +02:00
|
|
|
* and other data in toolbar
|
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void UpdateTitleAndInfo();
|
2010-10-06 19:28:07 +02:00
|
|
|
|
2019-05-24 09:55:33 -04:00
|
|
|
/**
|
|
|
|
* Display the current grid pane on the status bar.
|
|
|
|
*/
|
2020-06-12 11:58:56 +01:00
|
|
|
void DisplayGridMsg() override;
|
2019-05-24 09:55:33 -04:00
|
|
|
|
2020-01-12 20:44:19 -05:00
|
|
|
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
|
|
|
|
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2022-09-10 20:16:08 +02:00
|
|
|
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
|
|
|
|
|
2020-10-09 00:51:05 +01:00
|
|
|
void ToggleLayerManager();
|
2010-12-17 21:34:29 +01:00
|
|
|
|
2018-03-13 17:59:46 -04:00
|
|
|
void ShowChangedLanguage() override;
|
|
|
|
|
2017-09-20 10:30:48 +02:00
|
|
|
/// Handles the changing of the highlighted component/net/attribute
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnSelectHighlightChoice( wxCommandEvent& event );
|
2010-12-17 21:34:29 +01:00
|
|
|
|
2011-03-16 11:47:15 +01:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Select the active DCode for the current active layer.
|
2011-10-17 16:01:27 -04:00
|
|
|
* Items using this DCode are highlighted.
|
2011-03-16 11:47:15 +01:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnSelectActiveDCode( wxCommandEvent& event );
|
2011-03-16 11:47:15 +01:00
|
|
|
|
2011-03-14 22:19:13 +01:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Select the active layer:
|
2011-03-14 22:19:13 +01:00
|
|
|
* - if a file is loaded, it is loaded in this layer
|
2021-01-26 10:23:37 -05:00
|
|
|
* - this layer is displayed on top of other layers
|
2011-03-14 22:19:13 +01:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnSelectActiveLayer( wxCommandEvent& event );
|
2011-03-14 22:19:13 +01:00
|
|
|
|
2011-04-06 15:52:47 +02:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Called on request of application quit.
|
2011-04-06 15:52:47 +02:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnQuit( wxCommandEvent& event );
|
2011-04-06 15:52:47 +02:00
|
|
|
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnUpdateSelectDCode( wxUpdateUIEvent& aEvent );
|
2011-02-21 08:54:29 -05:00
|
|
|
|
2011-09-26 16:32:56 -04:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Delete the current data and loads a Gerber file selected from history list on current layer.
|
2011-09-26 16:32:56 -04:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnGbrFileHistory( wxCommandEvent& event );
|
2011-09-26 16:32:56 -04:00
|
|
|
|
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Delete the current data and load a drill file in Excellon format selected from
|
2011-09-26 16:32:56 -04:00
|
|
|
* history list on current layer.
|
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnDrlFileHistory( wxCommandEvent& event );
|
2010-05-17 16:35:46 -04:00
|
|
|
|
2017-01-26 10:45:28 +01:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Delete the current data and load a zip archive file selected from the
|
|
|
|
* history list. The archive is expected containing a set of gerber and drill file
|
2017-01-26 10:45:28 +01:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnZipFileHistory( wxCommandEvent& event );
|
2017-01-26 10:45:28 +01:00
|
|
|
|
2017-08-19 18:28:11 +02:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Delete the current data and load a gerber job file selected from the history list.
|
2017-08-19 18:28:11 +02:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
void OnJobFileHistory( wxCommandEvent& event );
|
2017-08-19 18:28:11 +02:00
|
|
|
|
2017-01-26 10:45:28 +01:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Extract gerber and drill files from the zip archive, and load them.
|
|
|
|
*
|
2017-01-26 10:45:28 +01:00
|
|
|
* @param aFullFileName is the full filename of the zip archive
|
|
|
|
* @param aReporter a REPORTER to collect warning and error messages
|
|
|
|
* @return true if OK, false if a file cannot be readable
|
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
bool unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter = nullptr );
|
2017-01-26 10:45:28 +01:00
|
|
|
|
2021-08-16 14:08:05 -04:00
|
|
|
/**
|
|
|
|
* Load a given file or selected file(s), if the filename is empty.
|
|
|
|
*
|
|
|
|
* @param aFileName - file name with full path to open or empty string.
|
|
|
|
* if empty string: a dialog will be opened to select one or
|
|
|
|
* a set of files
|
|
|
|
* @return true if file was opened successfully.
|
|
|
|
*/
|
|
|
|
bool LoadAutodetectedFiles( const wxString& aFileName );
|
|
|
|
|
2010-05-17 16:35:46 -04:00
|
|
|
/**
|
2021-07-31 11:30:31 +02:00
|
|
|
* Load a given Gerber file or selected file(s), if the filename is empty.
|
2021-01-26 10:23:37 -05:00
|
|
|
*
|
2021-07-31 11:30:31 +02:00
|
|
|
* @param aFileName - file name with full path to open or empty string.
|
|
|
|
* if empty string: a dialog will be opened to select one or
|
|
|
|
* a set of files
|
2010-12-15 21:15:24 +01:00
|
|
|
* @return true if file was opened successfully.
|
2010-05-17 16:35:46 -04:00
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
bool LoadGerberFiles( const wxString& aFileName );
|
2021-07-31 11:30:31 +02:00
|
|
|
bool Read_GERBER_File( const wxString& GERBER_FullFileName );
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2011-03-16 21:51:20 +01:00
|
|
|
/**
|
|
|
|
* Load a drill (EXCELLON) file or many files.
|
2021-01-26 10:23:37 -05:00
|
|
|
*
|
2011-03-16 21:51:20 +01:00
|
|
|
* @param aFileName - void string or file name with full path to open or empty string to
|
|
|
|
* open a new file. In this case one one file is loaded
|
2017-01-26 10:45:28 +01:00
|
|
|
* if empty string: user will be prompted for filename(s)
|
2011-03-16 21:51:20 +01:00
|
|
|
* @return true if file was opened successfully.
|
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
bool LoadExcellonFiles( const wxString& aFileName );
|
|
|
|
bool Read_EXCELLON_File( const wxString& aFullFileName );
|
2011-03-16 21:51:20 +01:00
|
|
|
|
2017-01-26 10:45:28 +01:00
|
|
|
/**
|
|
|
|
* Load a zipped archive file.
|
2021-01-26 10:23:37 -05:00
|
|
|
*
|
2017-01-26 10:45:28 +01:00
|
|
|
* @param aFileName - void string or file name with full path to open or empty string to
|
|
|
|
* open a new file.
|
|
|
|
* if empty string: user will be prompted for filename(s)
|
|
|
|
* @return true if file was opened successfully.
|
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
bool LoadZipArchiveFile( const wxString& aFileName );
|
2017-01-26 10:45:28 +01:00
|
|
|
|
2025-08-15 16:56:05 +01:00
|
|
|
/**
|
|
|
|
* Remove all files from the file history.
|
|
|
|
*/
|
|
|
|
void ClearFileHistory() override;
|
2017-08-19 18:28:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a Gerber job file, and load gerber files found in job files.
|
2021-01-26 10:23:37 -05:00
|
|
|
*
|
2017-08-19 18:28:11 +02:00
|
|
|
* @param aFileName - void string or file name with full path to open or empty string to
|
|
|
|
* open a new file.
|
|
|
|
* if empty string: user will be prompted for filename(s)
|
|
|
|
* @return true if file(s) was opened successfully.
|
|
|
|
*/
|
2018-03-13 17:59:46 -04:00
|
|
|
bool LoadGerberJobFile( const wxString& aFileName );
|
2017-08-19 18:28:11 +02:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
// PCB handling
|
2018-03-13 17:59:46 -04:00
|
|
|
bool Clear_DrawLayers( bool query );
|
|
|
|
void Erase_Current_DrawLayer( bool query );
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2021-08-02 16:00:34 -04:00
|
|
|
void SortLayersByFileExtension();
|
2018-03-13 17:59:46 -04:00
|
|
|
void SortLayersByX2Attributes();
|
2018-02-27 21:33:41 -05:00
|
|
|
|
2023-09-06 18:54:54 +02:00
|
|
|
// Adjust draw params: draw offset and draw rotation for a gerber file image
|
|
|
|
void SetLayerDrawPrms();
|
|
|
|
|
2021-08-02 16:00:34 -04:00
|
|
|
/**
|
|
|
|
* Takes a layer remapping and reorders the layers.
|
|
|
|
*
|
|
|
|
* @param remapping A map of old layer number -> new layer number mapping.
|
|
|
|
* Generally sourced from the SortImagesBy* functions.
|
|
|
|
*/
|
2023-10-01 16:52:21 +01:00
|
|
|
void RemapLayers( const std::unordered_map<int, int>& remapping );
|
2021-08-02 16:00:34 -04:00
|
|
|
|
2021-08-24 12:00:46 -04:00
|
|
|
/**
|
2022-11-17 15:42:12 +00:00
|
|
|
* Update each layers' differential option. Needed when xor mode changes or the active layer
|
|
|
|
* changes (due to changing rendering order) which matters for xor mode but not otherwise.
|
2021-08-24 12:00:46 -04:00
|
|
|
*/
|
2022-11-17 15:42:12 +00:00
|
|
|
void UpdateXORLayers();
|
2021-08-24 12:00:46 -04:00
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
/*
|
|
|
|
* Do nothing in GerbView.
|
2009-07-29 13:10:36 +00:00
|
|
|
*/
|
2012-05-04 19:44:42 +02:00
|
|
|
void SaveCopyInUndoList( GERBER_DRAW_ITEM* aItemToCopy,
|
2021-02-12 11:26:48 -08:00
|
|
|
UNDO_REDO aTypeCommand = UNDO_REDO::UNSPECIFIED ) { }
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2010-11-12 09:17:10 -06:00
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Create a new entry in undo list of commands and add a list of pickers to handle a list
|
|
|
|
* of items.
|
|
|
|
*
|
2009-08-03 18:54:48 +00:00
|
|
|
* @param aItemsList = the list of items modified by the command to undo
|
2020-08-26 18:04:32 +00:00
|
|
|
* @param aTypeCommand = command type (see enum UNDO_REDO)
|
2009-09-22 12:27:57 +00:00
|
|
|
* @param aTransformPoint = the reference point of the transformation,
|
|
|
|
* for commands like move
|
2009-08-03 18:54:48 +00:00
|
|
|
*/
|
2013-12-18 13:27:18 +01:00
|
|
|
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
2021-02-12 11:26:48 -08:00
|
|
|
UNDO_REDO aTypeCommand )
|
2009-08-03 18:54:48 +00:00
|
|
|
{
|
2011-09-30 14:15:37 -04:00
|
|
|
// currently: do nothing in GerbView.
|
2009-08-03 18:54:48 +00:00
|
|
|
}
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
///< @copydoc EDA_DRAW_FRAME::ActivateGalCanvas
|
2019-06-24 16:27:05 +01:00
|
|
|
void ActivateGalCanvas() override;
|
2017-09-17 18:43:20 -04:00
|
|
|
|
2018-05-14 18:34:18 +01:00
|
|
|
/**
|
|
|
|
* Called after the preferences dialog is run.
|
|
|
|
*/
|
2025-02-01 20:00:40 +00:00
|
|
|
void CommonSettingsChanged( int aFlags ) override;
|
2018-01-07 21:05:03 -07:00
|
|
|
|
2020-07-30 00:50:25 +01:00
|
|
|
SELECTION& GetCurrentSelection() override;
|
2019-05-14 20:21:10 +01:00
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
/**
|
|
|
|
* Set the m_gerberLayout member in such as way as to ensure deleting any previous
|
|
|
|
* GBR_LAYOUT.
|
|
|
|
* @param aLayout The GBR_LAYOUT to put into the frame.
|
|
|
|
*/
|
|
|
|
void SetLayout( GBR_LAYOUT* aLayout )
|
|
|
|
{
|
|
|
|
delete m_gerberLayout;
|
|
|
|
m_gerberLayout = aLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
GBR_LAYOUT* GetGerberLayout() const
|
|
|
|
{
|
|
|
|
wxASSERT( m_gerberLayout );
|
|
|
|
return m_gerberLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data
|
|
|
|
*/
|
|
|
|
GERBER_FILE_IMAGE_LIST* GetImagesList() const
|
|
|
|
{
|
|
|
|
return m_gerberLayout->GetImagesList();
|
|
|
|
}
|
|
|
|
|
|
|
|
GERBER_FILE_IMAGE* GetGbrImage( int aIdx ) const;
|
|
|
|
|
|
|
|
unsigned ImagesMaxCount() const; ///< The max number of file images
|
|
|
|
|
|
|
|
|
|
|
|
void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
|
|
|
|
const PAGE_INFO& GetPageSettings() const override;
|
2023-02-18 22:40:07 -05:00
|
|
|
const VECTOR2I GetPageSizeIU() const override;
|
2021-01-26 10:23:37 -05:00
|
|
|
|
2021-12-29 16:30:11 -05:00
|
|
|
const VECTOR2I& GetGridOrigin() const override { return m_grid_origin; }
|
|
|
|
void SetGridOrigin( const VECTOR2I& aPoint ) override { m_grid_origin = aPoint; }
|
2021-01-26 10:23:37 -05:00
|
|
|
|
|
|
|
const TITLE_BLOCK& GetTitleBlock() const override;
|
|
|
|
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the dialog box for layer selection.
|
|
|
|
*
|
|
|
|
* Providing the option to also display a "(Deselect)" radiobutton makes the
|
|
|
|
* GerbView's "Export to Pcbnew" command) more "user friendly",
|
|
|
|
* by permitting any layer to be "deselected" immediately after its
|
|
|
|
* corresponding radiobutton has been clicked on. (It would otherwise be
|
|
|
|
* necessary to first cancel the "Select Layer:" dialog box (invoked after a
|
|
|
|
* different radiobutton is clicked on) prior to then clicking on the "Deselect"
|
|
|
|
* button provided within the "Layer selection:" dialog box).
|
|
|
|
*
|
|
|
|
* @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer)
|
|
|
|
* @param aCopperLayerCount = number of copper layers
|
|
|
|
* @param aGerberName = Name of Gerber file to select KiCad layer for
|
|
|
|
* @return new layer value (NB_PCB_LAYERS when "(Deselect)" radiobutton selected),
|
|
|
|
* or -1 if canceled
|
|
|
|
*/
|
2021-07-27 08:22:27 -04:00
|
|
|
int SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, const wxString& aGerberName );
|
2021-01-26 10:23:37 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the color of the grid
|
|
|
|
*/
|
|
|
|
COLOR4D GetGridColor() override;
|
|
|
|
|
|
|
|
///< @copydoc EDA_DRAW_FRAME::SetGridColor()
|
2021-07-26 13:28:37 -04:00
|
|
|
virtual void SetGridColor( const COLOR4D& aColor ) override;
|
2021-01-26 10:23:37 -05:00
|
|
|
|
|
|
|
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override
|
|
|
|
{
|
|
|
|
wxASSERT( m_gerberLayout );
|
|
|
|
return m_gerberLayout->ViewBBox();
|
|
|
|
}
|
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2021-01-26 10:23:37 -05:00
|
|
|
|
|
|
|
protected:
|
2025-02-20 02:53:15 +00:00
|
|
|
void configureToolbars() override;
|
2021-01-26 10:23:37 -05:00
|
|
|
void setupUIConditions() override;
|
2022-12-16 16:37:32 -05:00
|
|
|
void doReCreateMenuBar() override;
|
2021-01-26 10:23:37 -05:00
|
|
|
|
2024-09-21 08:22:19 +00:00
|
|
|
void handleActivateEvent( wxActivateEvent& aEvent ) override;
|
|
|
|
void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
|
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
private:
|
2021-09-07 21:34:10 +01:00
|
|
|
void updateComponentListSelectBox();
|
|
|
|
void updateNetnameListSelectBox();
|
|
|
|
void updateAperAttributesSelectBox();
|
|
|
|
void updateDCodeSelectBox();
|
|
|
|
void unitsChangeRefresh() override; // See class EDA_DRAW_FRAME
|
2021-01-26 10:23:37 -05:00
|
|
|
|
|
|
|
void OnClearJobFileHistory( wxCommandEvent& aEvent );
|
|
|
|
void OnClearZipFileHistory( wxCommandEvent& aEvent );
|
|
|
|
void OnClearDrlFileHistory( wxCommandEvent& aEvent );
|
|
|
|
void OnClearGbrFileHistory( wxCommandEvent& aEvent );
|
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
void DoWithAcceptedFiles() override;
|
|
|
|
|
2021-08-16 14:08:05 -04:00
|
|
|
/**
|
|
|
|
* Loads the file provided or shows a dialog to get the file(s) from the user.
|
|
|
|
*
|
|
|
|
* @param aFileName Name of the file to open. Shows a dialog if not specified.
|
|
|
|
* @param dialogFiletypes File extensions to pass to the dialog if necessary
|
|
|
|
* @param dialogTitle Dialog title to use if necessary
|
|
|
|
* @param filetype Type of file for parsing, 0 = gerber, 1 = drill, 2 = autodetect
|
|
|
|
*
|
|
|
|
* @return true if success opening all files, false otherwise
|
|
|
|
*/
|
|
|
|
bool LoadFileOrShowDialog( const wxString& aFileName, const wxString& dialogFiletypes,
|
|
|
|
const wxString& dialogTitle, const int filetype );
|
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
// The Tool Framework initialization
|
|
|
|
void setupTools();
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxChoice* m_SelComponentBox; // a choice box to display and highlight component
|
|
|
|
// graphic items
|
|
|
|
wxChoice* m_SelNetnameBox; // a choice box to display and highlight netlist
|
|
|
|
// graphic items
|
|
|
|
wxChoice* m_SelAperAttributesBox; // a choice box to display aperture attributes and
|
|
|
|
// highlight items
|
|
|
|
GBR_LAYER_BOX_SELECTOR* m_SelLayerBox; // The combobox to select the current active
|
|
|
|
// graphic layer
|
|
|
|
// (which is drawn on top on the other layers
|
|
|
|
DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight.
|
|
|
|
wxTextCtrl* m_TextInfo; // a wxTextCtrl used to display some info about
|
|
|
|
// gerber data (format..)
|
|
|
|
|
|
|
|
GERBER_LAYER_WIDGET* m_LayersManager;
|
|
|
|
|
2022-09-11 14:38:33 +02:00
|
|
|
protected:
|
2021-01-26 10:23:37 -05:00
|
|
|
FILE_HISTORY m_zipFileHistory;
|
|
|
|
FILE_HISTORY m_drillFileHistory;
|
|
|
|
FILE_HISTORY m_jobFileHistory;
|
|
|
|
|
|
|
|
wxString m_lastFileName; // The last filename chosen to be proposed to the
|
|
|
|
// user.
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_show_layer_manager_tools;
|
|
|
|
|
|
|
|
GBR_LAYOUT* m_gerberLayout;
|
|
|
|
int m_activeLayer;
|
2021-12-29 16:30:11 -05:00
|
|
|
VECTOR2I m_grid_origin;
|
2021-01-26 10:23:37 -05:00
|
|
|
PAGE_INFO m_paper; // used only to show paper limits to screen
|
|
|
|
wxStaticText* m_cmpText; // a message on the auxiliary toolbar,
|
|
|
|
// relative to the m_SelComponentBox
|
|
|
|
wxStaticText* m_netText; // a message on the auxiliary toolbar,
|
|
|
|
// relative to the m_SelNetnameBox
|
|
|
|
wxStaticText* m_apertText; // a message on the auxiliary toolbar,
|
|
|
|
// relative to the m_SelAperAttributesBox
|
|
|
|
wxStaticText* m_dcodeText; // a message on the auxiliary toolbar,
|
|
|
|
// relative to the m_DCodeSelector
|
2024-09-21 16:28:05 +02:00
|
|
|
|
2025-01-03 14:00:58 -08:00
|
|
|
#ifndef __linux__
|
2024-09-21 08:22:19 +00:00
|
|
|
std::unique_ptr<NL_GERBVIEW_PLUGIN> m_spaceMouse;
|
2025-01-03 14:00:58 -08:00
|
|
|
#else
|
|
|
|
std::unique_ptr<SPNAV_2D_PLUGIN> m_spaceMouse;
|
|
|
|
#endif
|
2009-07-29 13:10:36 +00:00
|
|
|
};
|
|
|
|
|
2012-05-04 19:44:42 +02:00
|
|
|
#endif /* WX_GERBER_STRUCT_H */
|