KiCad PCB EDA Suite
pcb_base_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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008-2016 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU 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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef PCB_BASE_FRAME_H
27#define PCB_BASE_FRAME_H
28
29
30#include <eda_item.h>
31#include <board.h>
32#include <eda_draw_frame.h>
33#include <outline_mode.h>
34#include <lib_id.h>
35#include <pcb_display_options.h>
36#include <pcb_draw_panel_gal.h>
38#include <pcb_screen.h>
39#include <richio.h>
40#include <vector>
41
42
43/* Forward declarations of classes. */
45class BOARD;
47class COLOR_SETTINGS;
48class FOOTPRINT;
49class PAD;
54class ZONE_SETTINGS;
55class PCB_PLOT_PARAMS;
56class FP_LIB_TABLE;
58class PCBNEW_SETTINGS;
63
64wxDECLARE_EVENT( BOARD_CHANGED, wxCommandEvent );
65
70{
71public:
72 PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
73 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
74 long aStyle, const wxString& aFrameName );
75
77
82
90 virtual void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr );
91
99 FOOTPRINT* LoadFootprint( const LIB_ID& aFootprintId );
100
107 BOX2I GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const;
108
109 const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override
110 {
111 /* "Zoom to Fit" calls this with "aIncludeAllVisible" as true. Since that feature
112 * always ignored the page and border, this function returns a bbox without them
113 * as well when passed true. This technically is not all things visible, but it
114 * keeps behavior consistent.
115 *
116 * When passed false, this function returns a bbox of just the board edge. This
117 * allows things like fabrication text or anything else outside the board edge to
118 * be ignored, and just zooms up to the board itself.
119 *
120 * Calling "GetBoardBoundingBox(true)" when edge cuts are turned off will return
121 * the entire page and border, so we call "GetBoardBoundingBox(false)" instead.
122 */
123 if( aIncludeAllVisible || !m_pcb->IsLayerVisible( Edge_Cuts ) )
124 return GetBoardBoundingBox( false );
125 else
126 return GetBoardBoundingBox( true );
127 }
128
129 virtual void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
130 const PAGE_INFO& GetPageSettings() const override;
131 const wxSize GetPageSizeIU() const override;
132
133 const VECTOR2I& GetGridOrigin() const override;
134 void SetGridOrigin( const VECTOR2I& aPoint ) override;
135
136 const VECTOR2I& GetAuxOrigin() const;
137
138 const VECTOR2I GetUserOrigin() const;
139
144
145 const TITLE_BLOCK& GetTitleBlock() const override;
146 void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
147
152
156 virtual COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override
157 {
158 wxFAIL_MSG( wxT( "Color settings requested for a PCB_BASE_FRAME that does not override!" ) );
159 return nullptr;
160 }
161
162 void SetDrawBgColor( const COLOR4D& aColor ) override;
163
169
175 void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh = true );
176
177 const ZONE_SETTINGS& GetZoneSettings() const;
178 void SetZoneSettings( const ZONE_SETTINGS& aSettings );
179
183 virtual const PCB_PLOT_PARAMS& GetPlotSettings() const;
184 virtual void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings );
185
189 virtual void SetBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter = nullptr );
190
192 {
193 wxASSERT( m_pcb );
194 return m_pcb;
195 }
196
200 virtual BOARD_ITEM_CONTAINER* GetModel() const = 0;
201
202 EDA_ITEM* GetItem( const KIID& aId ) const override;
203
204 void FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
205 void FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
206
207 void HideSolderMask();
208 void ShowSolderMask();
209
210 // General
211 virtual void ReCreateOptToolbar() override { }
212 virtual void ShowChangedLanguage() override;
213 virtual void ReCreateMenuBar() override;
214 virtual void UpdateStatusBar() override;
215
216 PCB_SCREEN* GetScreen() const override { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
217
224
229
236 wxString SelectLibrary( const wxString& aNicknameExisting );
237
244
249 void OnModify() override;
250
264 FOOTPRINT* CreateNewFootprint( const wxString& aFootprintName, bool aQuiet = false );
265
272 void PlaceFootprint( FOOTPRINT* aFootprint, bool aRecreateRatsnest = true );
273
274 void ShowPadPropertiesDialog( PAD* aPad );
275
282
288 virtual void AddFootprintToBoard( FOOTPRINT* aFootprint );
289
296
305 void Compile_Ratsnest( bool aDisplayStatus );
306
313 virtual void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand ) = 0;
314
321 virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
322 UNDO_REDO aTypeCommand ) = 0;
323
327 virtual void AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsList,
328 UNDO_REDO aTypeCommand ) = 0;
329
330
341 PCB_LAYER_ID SelectOneLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask = LSET(),
342 wxPoint aDlgPosition = wxDefaultPosition );
343
349 virtual void SwitchLayer( PCB_LAYER_ID aLayer );
350
351 virtual void SetActiveLayer( PCB_LAYER_ID aLayer ) { GetScreen()->m_Active_Layer = aLayer; }
353
354 SEVERITY GetSeverity( int aErrorCode ) const override;
355
356 virtual void OnDisplayOptionsChanged() {}
357
358 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
359 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
360
362
364
366
368
369 void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
370
374 void DisplayGridMsg() override;
375
376 PCB_DRAW_PANEL_GAL* GetCanvas() const override;
377
378 virtual void ActivateGalCanvas() override;
379
380protected:
381 bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
382
383 void handleActivateEvent( wxActivateEvent& aEvent ) override;
384
385 void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
386
396 FOOTPRINT* loadFootprint( const LIB_ID& aFootprintId );
397
398 virtual void unitsChangeRefresh() override;
399
400 void rebuildConnectivity();
401
402protected:
406
407private:
409};
410
411#endif // PCB_BASE_FRAME_H
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:532
Color settings are a bit different than most of the settings objects in that there can be more than o...
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
The base class for create windows for drawing purpose.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:326
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:204
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Definition: kiid.h:48
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:273
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
The class that implements the public interface to the SpaceMouse plug-in.
A class to perform either relative or absolute display origin transforms for a single axis of a point...
Definition: pad.h:59
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
wxString SelectFootprintFromLibBrowser()
Launch the footprint viewer to select the name of a footprint to load.
SEVERITY GetSeverity(int aErrorCode) const override
PCB_LAYER_ID SelectOneLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Show the dialog box for a layer selection.
Definition: sel_layer.cpp:274
virtual void OnDisplayOptionsChanged()
void FocusOnItems(std::vector< BOARD_ITEM * > aItems, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
FOOTPRINT * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Open a dialog to select a footprint.
ORIGIN_TRANSFORMS & GetOriginTransforms() override
Return a reference to the default ORIGIN_TRANSFORMS object.
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
void ShowPadPropertiesDialog(PAD *aPad)
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
FOOTPRINT * GetFootprintFromBoardByReference()
virtual void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual void SwitchLayer(PCB_LAYER_ID aLayer)
Change the active layer in the frame.
virtual PCB_LAYER_ID GetActiveLayer() const
PCB_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
const VECTOR2I & GetAuxOrigin() const
virtual PCB_VIEWERS_SETTINGS_BASE * GetViewerSettingsBase() const
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
const VECTOR2I GetUserOrigin() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
const VECTOR2I & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
const TITLE_BLOCK & GetTitleBlock() const override
const PAGE_INFO & GetPageSettings() const override
virtual void ReCreateMenuBar() override
Recreates the menu bar.
BOX2I GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
FOOTPRINT * LoadFootprint(const LIB_ID &aFootprintId)
Attempt to load aFootprintId from the footprint library table.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
wxString SelectLibrary(const wxString &aNicknameExisting)
Put up a dialog and allows the user to pick a library, for unspecified use.
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
virtual void AppendCopyToUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand)=0
As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
void SetDrawBgColor(const COLOR4D &aColor) override
virtual void SaveCopyInUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand)=0
Creates a new entry in undo list of commands.
virtual void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
NL_PCBNEW_PLUGIN * m_spaceMouse
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
const ZONE_SETTINGS & GetZoneSettings() const
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
virtual void ReCreateOptToolbar() override
PCB_DISPLAY_OPTIONS m_displayOptions
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
void SetGridOrigin(const VECTOR2I &aPoint) override
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
PCB_ORIGIN_TRANSFORMS m_originTransforms
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)=0
Create a new entry in undo list of commands.
EDA_3D_VIEWER_FRAME * CreateAndShow3D_Frame()
Shows the 3D view frame.
EDA_3D_VIEWER_FRAME * Get3DViewerFrame()
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void DisplayGridMsg() override
Display the current grid pane on the status bar.
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
Definition: ratsnest.cpp:35
FOOTPRINT * CreateNewFootprint(const wxString &aFootprintName, bool aQuiet=false)
Creates a new footprint, at position 0,0.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
virtual void UpdateStatusBar() override
Update the status bar information.
Parameters and options when plotting/printing a board.
PCB_LAYER_ID m_Active_Layer
Definition: pcb_screen.h:42
A holder to handle information on schematic or board items.
A progress reporter interface for use in multi-threaded environments.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:70
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ Edge_Cuts
Definition: layer_ids.h:113
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
wxDECLARE_EVENT(BOARD_CHANGED, wxCommandEvent)
SEVERITY
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...