KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_control.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) 2014-2020 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef PCB_CONTROL_H
24#define PCB_CONTROL_H
25
26#include <pcb_io/pcb_io_mgr.h>
27#include <memory>
28#include <tools/pcb_tool_base.h>
29#include <status_popup.h>
30#include <wx/dialog.h>
31#include <wx/weakref.h>
32
33namespace KIGFX {
34 class ORIGIN_VIEWITEM;
35}
36
37class PCB_BASE_FRAME;
38class BOARD_ITEM;
39
43
45{
46public:
49
51 void Reset( RESET_REASON aReason ) override;
52
53 int AddLibrary( const TOOL_EVENT& aEvent );
54 int Print( const TOOL_EVENT& aEvent );
55 int Quit( const TOOL_EVENT& aEvent );
56
57 // Footprint library control actions
58 int LoadFpFromBoard( const TOOL_EVENT& aEvent );
59 int SaveFpToBoard( const TOOL_EVENT& aEvent );
60 int IterateFootprint( const TOOL_EVENT& aEvent );
61
62 // Display modes
63 int ToggleRatsnest( const TOOL_EVENT& aEvent );
64 int ZoneDisplayMode( const TOOL_EVENT& aEvent );
65 int TrackDisplayMode( const TOOL_EVENT& aEvent );
66 int ViaDisplayMode( const TOOL_EVENT& aEvent );
67
68 // Update the view with the new high-contrast mode from the display settings
69 int HighContrastMode( const TOOL_EVENT& aEvent );
70
71 int ContrastModeFeedback( const TOOL_EVENT& aEvent );
72
73 // Rotate through the available high-contrast, net color and ratsnest color modes
74 int HighContrastModeCycle( const TOOL_EVENT& aEvent );
75 int NetColorModeCycle( const TOOL_EVENT& aEvent );
76 int RatsnestModeCycle( const TOOL_EVENT& aEvent );
77
78 // Layer control
79 int LayerSwitch( const TOOL_EVENT& aEvent );
80 int LayerNext( const TOOL_EVENT& aEvent );
81 int LayerPrev( const TOOL_EVENT& aEvent );
82 int LayerToggle( const TOOL_EVENT& aEvent );
83 int LayerAlphaInc( const TOOL_EVENT& aEvent );
84 int LayerAlphaDec( const TOOL_EVENT& aEvent );
85 int CycleLayerPresets( const TOOL_EVENT& aEvent );
86 int LayerPresetFeedback( const TOOL_EVENT& aEvent );
87
88 // Grid control
89 int GridPlaceOrigin( const TOOL_EVENT& aEvent );
90 int GridResetOrigin( const TOOL_EVENT& aEvent );
91
92 // Low-level access (below undo) to setting the grid origin
93 static void DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
94 EDA_ITEM* originViewItem, const VECTOR2D& aPoint );
95
96 int Undo( const TOOL_EVENT& aEvent );
97 int Redo( const TOOL_EVENT& aEvent );
98
99 // Snapping control
100 int SnapMode( const TOOL_EVENT& aEvent );
101 int SnapModeFeedback( const TOOL_EVENT& aEvent );
102
103 // Miscellaneous
104 int InteractiveDelete( const TOOL_EVENT& aEvent );
105 int Paste( const TOOL_EVENT& aEvent );
106 int AppendBoardFromFile( const TOOL_EVENT& aEvent );
107 int AppendDesignBlock( const TOOL_EVENT& aEvent );
108 int ApplyDesignBlockLayout( const TOOL_EVENT& aEvent );
109 int PlaceLinkedDesignBlock( const TOOL_EVENT& aEvent );
110 int SaveToLinkedDesignBlock( const TOOL_EVENT& aEvent );
111 int AppendBoard( PCB_IO& pi, const wxString& fileName, DESIGN_BLOCK* aDesignBlock = nullptr,
112 BOARD_COMMIT* aCommit = nullptr, bool aSkipMove = false );
113 int UpdateMessagePanel( const TOOL_EVENT& aEvent );
114 int PlaceCharacteristics( const TOOL_EVENT& aEvent );
115 int PlaceStackup( const TOOL_EVENT& aEvent );
116 int PlaceDrillChart( const TOOL_EVENT& aEvent );
117 int PlaceDrillMap( const TOOL_EVENT& aEvent );
118 int ShowDrillGroups( const TOOL_EVENT& aEvent );
119
120 int CollectAndEmbed3DModels( const TOOL_EVENT& aEvent );
121
122 int FlipPcbView( const TOOL_EVENT& aEvent );
123
124 int RehatchShapes( const TOOL_EVENT& aEvent );
125
127 static void rehatchBoardItem( KIGFX::VIEW* aView, BOARD_ITEM* aItem );
128
129 // Drag and drop
130 int DdAppendBoard( const TOOL_EVENT& aEvent );
131 int DdAddLibrary( const TOOL_EVENT& aEvent );
132 int DdImportFootprint( const TOOL_EVENT& aEvent );
133
134private:
136 void setTransitions() override;
137
143 void unfilledZoneCheck();
144
149 void pruneItemLayers( std::vector<BOARD_ITEM*>& aItems );
150
162 bool placeBoardItems( BOARD_COMMIT* aCommit, std::vector<BOARD_ITEM*>& aItems, bool aIsNew, bool aAnchorAtOrigin,
163 bool aReannotateDuplicates, bool aSkipMove );
164
165 bool placeBoardItems( BOARD_COMMIT* aCommit, BOARD* aBoard, bool aAnchorAtOrigin, bool aReannotateDuplicates,
166 bool aSkipMove );
167
168private:
170
171 std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> m_gridOrigin;
172
174
175 std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
176
181 wxWeakRef<wxDialog> m_drillGroupsDialog;
182};
183
184#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
int PlaceDrillChart(const TOOL_EVENT &aEvent)
int RehatchShapes(const TOOL_EVENT &aEvent)
void setTransitions() override
< Sets up handlers for various events.
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
int AddLibrary(const TOOL_EVENT &aEvent)
int DdAppendBoard(const TOOL_EVENT &aEvent)
int LoadFpFromBoard(const TOOL_EVENT &aEvent)
int SaveToLinkedDesignBlock(const TOOL_EVENT &aEvent)
int DdImportFootprint(const TOOL_EVENT &aEvent)
int SnapModeFeedback(const TOOL_EVENT &aEvent)
int NetColorModeCycle(const TOOL_EVENT &aEvent)
int SaveFpToBoard(const TOOL_EVENT &aEvent)
int RatsnestModeCycle(const TOOL_EVENT &aEvent)
int TrackDisplayMode(const TOOL_EVENT &aEvent)
int DdAddLibrary(const TOOL_EVENT &aEvent)
int ShowDrillGroups(const TOOL_EVENT &aEvent)
int Redo(const TOOL_EVENT &aEvent)
int PlaceLinkedDesignBlock(const TOOL_EVENT &aEvent)
bool placeBoardItems(BOARD_COMMIT *aCommit, std::vector< BOARD_ITEM * > &aItems, bool aIsNew, bool aAnchorAtOrigin, bool aReannotateDuplicates, bool aSkipMove)
Add and select or just select for move/place command a list of board items.
int LayerPresetFeedback(const TOOL_EVENT &aEvent)
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
int LayerAlphaDec(const TOOL_EVENT &aEvent)
static void rehatchBoardItem(KIGFX::VIEW *aView, BOARD_ITEM *aItem)
Regenerate and redraw an item's hatching, skipping non-hatched shapes. Static for testing.
int LayerNext(const TOOL_EVENT &aEvent)
int PlaceStackup(const TOOL_EVENT &aEvent)
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
int ToggleRatsnest(const TOOL_EVENT &aEvent)
int LayerAlphaInc(const TOOL_EVENT &aEvent)
int HighContrastModeCycle(const TOOL_EVENT &aEvent)
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
int Quit(const TOOL_EVENT &aEvent)
int HighContrastMode(const TOOL_EVENT &aEvent)
int Undo(const TOOL_EVENT &aEvent)
int ViaDisplayMode(const TOOL_EVENT &aEvent)
PCB_BASE_FRAME * m_frame
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
int CollectAndEmbed3DModels(const TOOL_EVENT &aEvent)
void pruneItemLayers(std::vector< BOARD_ITEM * > &aItems)
Helper for pasting.
int GridPlaceOrigin(const TOOL_EVENT &aEvent)
int FlipPcbView(const TOOL_EVENT &aEvent)
int PlaceCharacteristics(const TOOL_EVENT &aEvent)
wxWeakRef< wxDialog > m_drillGroupsDialog
Modeless, so it outlives the action that opened it.
int ApplyDesignBlockLayout(const TOOL_EVENT &aEvent)
int SnapMode(const TOOL_EVENT &aEvent)
int ContrastModeFeedback(const TOOL_EVENT &aEvent)
int LayerToggle(const TOOL_EVENT &aEvent)
int AppendBoard(PCB_IO &pi, const wxString &fileName, DESIGN_BLOCK *aDesignBlock=nullptr, BOARD_COMMIT *aCommit=nullptr, bool aSkipMove=false)
int IterateFootprint(const TOOL_EVENT &aEvent)
int Print(const TOOL_EVENT &aEvent)
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
int GridResetOrigin(const TOOL_EVENT &aEvent)
BOARD_ITEM * m_pickerItem
int InteractiveDelete(const TOOL_EVENT &aEvent)
int AppendDesignBlock(const TOOL_EVENT &aEvent)
int LayerPrev(const TOOL_EVENT &aEvent)
int PlaceDrillMap(const TOOL_EVENT &aEvent)
int CycleLayerPresets(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
void unfilledZoneCheck()
We have bug reports indicating that some new users confuse zone filling/unfilling with the display mo...
int LayerSwitch(const TOOL_EVENT &aEvent)
A base class that BOARD loading and saving plugins should derive from.
Definition pcb_io.h:76
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
Generic, UI-independent tool event.
Definition tool_event.h:167
void Reset() override
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
VECTOR2< double > VECTOR2D
Definition vector2d.h:682