KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerbview_frame.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2013 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef WX_GERBER_STRUCT_H
23#define WX_GERBER_STRUCT_H
24
25#include <file_history.h>
26#include <eda_draw_frame.h>
27#include <layer_ids.h>
28#include <gerbview.h>
29#include <gbr_layout.h>
30#include <page_info.h>
31#include <gbr_display_options.h>
32
33#include <memory>
34
35#define NO_AVAILABLE_LAYERS UNDEFINED_LAYER
36
44class LSET;
45class REPORTER;
46class SELECTION;
47class wxStaticText;
48
49#if defined(__linux__) || defined(__FreeBSD__)
50class SPNAV_2D_PLUGIN;
51#else
53#endif
54
55
59
60#define GERBVIEW_FRAME_NAME wxT( "GerberFrame" )
61
63{
64public:
65 GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent );
67
68 void doCloseWindow() override;
69
70 bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
71
81 bool LoadListOfGerberAndDrillFiles( const wxString& aPath, const wxArrayString& aFilenameList,
82 std::vector<int>* aFileType );
83
84 void UpdateStatusBar() override;
85
87
90
97 bool IsElementVisible( int aLayerID ) const;
98
106 void SetElementVisibility( int aLayerID, bool aNewState );
107
111 void SetGridVisibility( bool aVisible ) override;
112
118 LSET GetVisibleLayers() const;
119
125 void SetVisibleLayers( const LSET& aLayerMask );
126
133 bool IsLayerVisible( int aLayer ) const;
134
138 COLOR4D GetVisibleElementColor( int aLayerID );
139
140 void SetVisibleElementColor( int aLayerID, const COLOR4D& aColor );
141
142 COLOR4D GetLayerColor( int aLayer ) const;
143 void SetLayerColor( int aLayer, const COLOR4D& aColor );
144
148 void ReFillLayerWidget();
149
153 void SetActiveLayer( int aLayer, bool doLayerWidgetUpdate = true );
154
158 int GetActiveLayer() const { return m_activeLayer; }
159
167 int getNextAvailableLayer() const;
168
176 void syncLayerWidget();
177
184 void syncLayerBox( bool aRebuildLayerBox = false );
185
194 void UpdateTitleAndInfo();
195
199 void DisplayGridMsg() override;
200
201 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
202 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
203
204 COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
205
206 void ToggleLayerManager();
207
208 void ShowChangedLanguage() override;
209
211 void OnSelectHighlightChoice( wxCommandEvent& event );
212
217 void OnSelectActiveDCode( wxCommandEvent& event );
218
224 void OnSelectActiveLayer( wxCommandEvent& event );
225
229 void OnQuit( wxCommandEvent& event );
230
231 void OnUpdateSelectDCode( wxUpdateUIEvent& aEvent );
232
236 void OnGbrFileHistory( wxCommandEvent& event );
237
242 void OnDrlFileHistory( wxCommandEvent& event );
243
248 void OnZipFileHistory( wxCommandEvent& event );
249
253 void OnJobFileHistory( wxCommandEvent& event );
254
263 bool unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter = nullptr,
264 const wxArrayString* aMembers = nullptr );
265
274 bool LoadAutodetectedFiles( const wxString& aFileName );
275
284 bool LoadGerberFiles( const wxString& aFileName );
285 bool Read_GERBER_File( const wxString& GERBER_FullFileName );
286
295 bool LoadExcellonFiles( const wxString& aFileName );
296 bool Read_EXCELLON_File( const wxString& aFullFileName );
297
307 bool LoadZipArchiveFile( const wxString& aFileName, const wxArrayString* aMembers = nullptr );
308
312 void ClearFileHistory() override;
313
322 bool LoadGerberJobFile( const wxString& aFileName );
323
324 // PCB handling
325 bool Clear_DrawLayers( bool query );
326 void Erase_Current_DrawLayer( bool query );
327
330
331 // Adjust draw params: draw offset and draw rotation for a gerber file image
332 void SetLayerDrawPrms();
333
340 void RemapLayers( const std::unordered_map<int, int>& remapping );
341
346 void UpdateXORLayers();
347
348 /*
349 * Do nothing in GerbView.
350 */
352 UNDO_REDO aTypeCommand = UNDO_REDO::UNSPECIFIED ) { }
353
361 void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
362 UNDO_REDO aTypeCommand )
363 {
364 // currently: do nothing in GerbView.
365 }
366
368 void ActivateGalCanvas() override;
369
373 void CommonSettingsChanged( int aFlags ) override;
374
375 SELECTION& GetCurrentSelection() override;
376
382 void SetLayout( GBR_LAYOUT* aLayout )
383 {
384 delete m_gerberLayout;
385 m_gerberLayout = aLayout;
386 }
387
389 {
390 wxASSERT( m_gerberLayout );
391 return m_gerberLayout;
392 }
393
398 {
399 return m_gerberLayout->GetImagesList();
400 }
401
402 GERBER_FILE_IMAGE* GetGbrImage( int aIdx ) const;
403
404 unsigned ImagesMaxCount() const;
405
406
407 void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
408 const PAGE_INFO& GetPageSettings() const override;
409 const VECTOR2I GetPageSizeIU() const override;
410
411 const VECTOR2I& GetGridOrigin() const override { return m_grid_origin; }
412 void SetGridOrigin( const VECTOR2I& aPoint ) override { m_grid_origin = aPoint; }
413
414 const TITLE_BLOCK& GetTitleBlock() const override;
415 void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
416
434 int SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, const wxString& aGerberName );
435
439 COLOR4D GetGridColor() override;
440
442 virtual void SetGridColor( const COLOR4D& aColor ) override;
443
444 const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override
445 {
446 wxASSERT( m_gerberLayout );
447 return m_gerberLayout->ViewBBox();
448 }
449
450 void ClearToolbarControl( int aId ) override;
451
452 DECLARE_EVENT_TABLE()
453
454protected:
455 void configureToolbars() override;
456 void setupUIConditions() override;
457 void doReCreateMenuBar() override;
458
459 void handleActivateEvent( wxActivateEvent& aEvent ) override;
460 void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
461
462private:
467 void unitsChangeRefresh() override; // See class EDA_DRAW_FRAME
468
469 void OnClearJobFileHistory( wxCommandEvent& aEvent );
470 void OnClearZipFileHistory( wxCommandEvent& aEvent );
471 void OnClearDrlFileHistory( wxCommandEvent& aEvent );
472 void OnClearGbrFileHistory( wxCommandEvent& aEvent );
473
474 void DoWithAcceptedFiles() override;
475
486 bool LoadFileOrShowDialog( const wxString& aFileName, const wxString& dialogFiletypes,
487 const wxString& dialogTitle, const int filetype );
488
489 // The Tool Framework initialization
490 void setupTools();
491
492public:
493 wxChoice* m_SelComponentBox; // a choice box to display and highlight component
494 // graphic items
495 wxChoice* m_SelNetnameBox; // a choice box to display and highlight netlist
496 // graphic items
497 wxChoice* m_SelAperAttributesBox; // a choice box to display aperture attributes and
498 // highlight items
499 GBR_LAYER_BOX_SELECTOR* m_SelLayerBox; // The combobox to select the current active
500 // graphic layer
501 // (which is drawn on top on the other layers
502 DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight.
503 wxTextCtrl* m_TextInfo; // a wxTextCtrl used to display some info about
504 // gerber data (format..)
505
507
508protected:
512
513 wxString m_lastFileName; // The last filename chosen to be proposed to the
514 // user.
515
516private:
518
522 PAGE_INFO m_paper; // used only to show paper limits to screen
523 wxStaticText* m_cmpText; // a message on the auxiliary toolbar,
524 // relative to the m_SelComponentBox
525 wxStaticText* m_netText; // a message on the auxiliary toolbar,
526 // relative to the m_SelNetnameBox
527 wxStaticText* m_apertText; // a message on the auxiliary toolbar,
528 // relative to the m_SelAperAttributesBox
529 wxStaticText* m_dcodeText; // a message on the auxiliary toolbar,
530 // relative to the m_DCodeSelector
531
532#if defined(__linux__) || defined(__FreeBSD__)
533 std::unique_ptr<SPNAV_2D_PLUGIN> m_spaceMouse;
534#else
535 std::unique_ptr<NL_GERBVIEW_PLUGIN> m_spaceMouse;
536#endif
537};
538
539#endif /* WX_GERBER_STRUCT_H */
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Color settings are a bit different than most of the settings objects in that there can be more than o...
Helper to display a DCode list and select a DCode id.
EDA_DRAW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
This class implements a file history object to store a list of files, that can then be added to a men...
A list of GERBER_DRAW_ITEM objects currently loaded.
Definition gbr_layout.h:42
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
Hold the image data and parameters for one gerber file and layer parameters.
Abstract functions of LAYER_WIDGET so they may be tied into the GERBVIEW_FRAME's data and we can add ...
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
void SetLayerColor(int aLayer, const COLOR4D &aColor)
void OnUpdateSelectDCode(wxUpdateUIEvent &aEvent)
void OnQuit(wxCommandEvent &event)
Called on request of application quit.
wxStaticText * m_dcodeText
wxChoice * m_SelAperAttributesBox
void UpdateXORLayers()
Update each layers' differential option.
void UpdateStatusBar() override
Update the status bar information.
void configureToolbars() override
COLOR4D GetVisibleElementColor(int aLayerID)
Return the color of a gerber visible element.
GERBVIEW_SETTINGS * gvconfig() const
const PAGE_INFO & GetPageSettings() const override
bool IsLayerVisible(int aLayer) const
Test whether a given layer is visible.
void DisplayGridMsg() override
Display the current grid pane on the status bar.
void OnDrlFileHistory(wxCommandEvent &event)
Delete the current data and load a drill file in Excellon format selected from history list on curren...
void SortLayersByX2Attributes()
void SetLayout(GBR_LAYOUT *aLayout)
Set the m_gerberLayout member in such as way as to ensure deleting any previous GBR_LAYOUT.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
bool Read_EXCELLON_File(const wxString &aFullFileName)
bool m_show_layer_manager_tools
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
GBR_LAYOUT * m_gerberLayout
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void ApplyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
bool LoadFileOrShowDialog(const wxString &aFileName, const wxString &dialogFiletypes, const wxString &dialogTitle, const int filetype)
Loads the file provided or shows a dialog to get the file(s) from the user.
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
wxStaticText * m_cmpText
void OnClearDrlFileHistory(wxCommandEvent &aEvent)
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
int SelectPCBLayer(int aDefaultLayer, int aCopperLayerCount, const wxString &aGerberName)
Show the dialog box for layer selection.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
wxString m_lastFileName
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
const VECTOR2I & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
GBR_LAYOUT * GetGerberLayout() const
bool LoadGerberFiles(const wxString &aFileName)
Load a given Gerber file or selected file(s), if the filename is empty.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void doCloseWindow() override
wxChoice * m_SelComponentBox
FILE_HISTORY m_jobFileHistory
std::unique_ptr< NL_GERBVIEW_PLUGIN > m_spaceMouse
void OnJobFileHistory(wxCommandEvent &event)
Delete the current data and load a gerber job file selected from the history list.
void SetGridOrigin(const VECTOR2I &aPoint) override
wxChoice * m_SelNetnameBox
bool LoadZipArchiveFile(const wxString &aFileName, const wxArrayString *aMembers=nullptr)
Load a zipped archive file.
void OnZipFileHistory(wxCommandEvent &event)
Delete the current data and load a zip archive file selected from the history list.
int GetActiveLayer() const
Return the active layer.
wxTextCtrl * m_TextInfo
bool IsElementVisible(int aLayerID) const
Test whether a given element category is visible.
DCODE_SELECTION_BOX * m_DCodeSelector
GERBER_LAYER_WIDGET * m_LayersManager
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
wxStaticText * m_netText
void SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
void syncLayerWidget()
Update the currently "selected" layer within the GERBER_LAYER_WIDGET.
void SetVisibleElementColor(int aLayerID, const COLOR4D &aColor)
void ClearFileHistory() override
Remove all files from the file history.
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
unsigned ImagesMaxCount() const
The max number of file images.
void updateAperAttributesSelectBox()
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
wxStaticText * m_apertText
void OnSelectHighlightChoice(wxCommandEvent &event)
Handles the changing of the highlighted component/net/attribute.
bool Read_GERBER_File(const wxString &GERBER_FullFileName)
Definition readgerb.cpp:37
COLOR4D GetLayerColor(int aLayer) const
bool Clear_DrawLayers(bool query)
void SortLayersByFileExtension()
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
void handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
void updateComponentListSelectBox()
void SetGridVisibility(bool aVisible) override
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box of document with option to not include some items.
bool LoadListOfGerberAndDrillFiles(const wxString &aPath, const wxArrayString &aFilenameList, std::vector< int > *aFileType)
Load a list of Gerber and NC drill files and updates the view based on them.
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
void SaveCopyInUndoList(GERBER_DRAW_ITEM *aItemToCopy, UNDO_REDO aTypeCommand=UNDO_REDO::UNSPECIFIED)
const TITLE_BLOCK & GetTitleBlock() const override
bool LoadAutodetectedFiles(const wxString &aFileName)
Load a given file or selected file(s), if the filename is empty.
VECTOR2I m_grid_origin
void OnSelectActiveLayer(wxCommandEvent &event)
Select the active layer:
void RemapLayers(const std::unordered_map< int, int > &remapping)
Takes a layer remapping and reorders the layers.
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
void SaveCopyInUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand)
Create a new entry in undo list of commands and add a list of pickers to handle a list of items.
FILE_HISTORY m_zipFileHistory
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
int getNextAvailableLayer() const
Find the next empty layer.
void Erase_Current_DrawLayer(bool query)
void updateNetnameListSelectBox()
void UpdateTitleAndInfo()
Display the short filename (if exists) of the selected layer on the caption of the main GerbView wind...
void OnClearGbrFileHistory(wxCommandEvent &aEvent)
bool unarchiveFiles(const wxString &aFullFileName, REPORTER *aReporter=nullptr, const wxArrayString *aMembers=nullptr)
Extract gerber and drill files from the zip archive, and load them.
void SetElementVisibility(int aLayerID, bool aNewState)
Change the visibility of an element category.
virtual void SetGridColor(const COLOR4D &aColor) override
void OnSelectActiveDCode(wxCommandEvent &event)
Select the active DCode for the current active layer.
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
void OnClearZipFileHistory(wxCommandEvent &aEvent)
void DoWithAcceptedFiles() override
Execute action on accepted dropped file.
void ClearToolbarControl(int aId) override
void OnGbrFileHistory(wxCommandEvent &event)
Delete the current data and loads a Gerber file selected from history list on current layer.
FILE_HISTORY m_drillFileHistory
bool LoadExcellonFiles(const wxString &aFileName)
Load a drill (EXCELLON) file or many files.
void doReCreateMenuBar() override
void OnClearJobFileHistory(wxCommandEvent &aEvent)
COLOR4D GetGridColor() override
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:348
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
The class that implements the public interface to the SpaceMouse plug-in.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
A holder to handle information on schematic or board items.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition title_block.h:38
Class CLASS_GBR_LAYOUT to handle info to draw loaded Gerber images and page frame reference.
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708