KiCad PCB EDA Suite
Loading...
Searching...
No Matches
mocks.cpp
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <kiface_base.h>
21#include <confirm.h>
22#include <pcb_edit_frame.h>
23#include <wx/file.h>
24#include <wx/app.h>
25#include <board.h>
26#include <collectors.h>
28#include <footprint.h>
29#include <tools/pcb_actions.h>
31#include <router/router_tool.h>
32#include <dialog_find.h>
34#include <zone_filler.h>
37
38
40 DIALOG_FIND_BASE( aParent )
41{
42 // these members are initialized to avoid warnings about non initialized vars
43 m_frame = aParent;
44 m_hitList.clear();
45 m_it = m_hitList.begin();
46 m_upToDate = false;
47 m_board = nullptr;
48}
49
51
52void DIALOG_FIND::OnBoardChanged( wxCommandEvent& event ) {}
53
54void DIALOG_FIND::OnCharHook( wxKeyEvent& aEvent )
55{
56}
57
58void DIALOG_FIND::onFindNextClick( wxCommandEvent& aEvent )
59{
60}
61
62void DIALOG_FIND::onFindPreviousClick( wxCommandEvent& aEvent )
63{
64}
65
66void DIALOG_FIND::onSearchAgainClick( wxCommandEvent& aEvent )
67{
68}
69
70void DIALOG_FIND::onTextEnter( wxCommandEvent& event )
71{
72}
73
74void DIALOG_FIND::onShowSearchPanel( wxHyperlinkEvent& event )
75{
76}
77
78bool DIALOG_FIND::Show( bool show )
79{
80 return true;
81}
82
83
84DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxString& title,
85 const wxPoint& pos, const wxSize& size, long style ) :
86 DIALOG_SHIM( parent, id, title, pos, size, style )
87{
88 // these members are initialized only to avoid warnings about non initialized vars
89 searchStringLabel = nullptr;
90 m_searchCombo = nullptr;
91 m_matchCase = nullptr;
92 m_matchWords = nullptr;
93 m_wildcards = nullptr;
94 m_wrap = nullptr;
95 m_includeValues = nullptr;
96 m_includeReferences = nullptr;
97 m_includeTexts = nullptr;
98 m_includeMarkers = nullptr;
99 m_includeNets = nullptr;
100 m_findNext = nullptr;
101 m_findPrevious = nullptr;
102 m_searchAgain = nullptr;
103 m_closeButton = nullptr;
104 m_status = nullptr;
105}
106
107
109{
110}
111
112
114 const wxString& title,
115 const wxPoint& pos, const wxSize& size,
116 long style ) :
117 DIALOG_SHIM( parent, id, title, pos, size, style )
118{
119 // these members are initialized only to avoid warnings about non initialized vars
120 m_Include_Modules = nullptr;
121 m_Include_PcbTexts = nullptr;
122 m_IncludeLockedModules = nullptr;
123 m_Include_Draw_Items = nullptr;
124 m_Include_Tracks = nullptr;
125 m_Include_Vias = nullptr;
126 m_Include_Edges_Items = nullptr;
127 m_Include_Zones = nullptr;
128 m_sdbSizer1 = nullptr;
129 m_sdbSizer1OK = nullptr;
130 m_sdbSizer1Cancel = nullptr;
131}
132
133
135{
136}
137
138
141 m_options( aOptions )
142{
143 // silence another compiler warning about m_options not being used
144 if( m_options.includeFootprints )
145 {
146 }
147}
148
149
150void DIALOG_FILTER_SELECTION::checkBoxClicked( wxCommandEvent& aEvent )
151{
152}
153
154
155void DIALOG_FILTER_SELECTION::allItemsClicked( wxCommandEvent& aEvent )
156{
157}
158
159
161{
162 return true;
163}
164
165
167{
168 return true;
169}
170
171
173{
174}
175
176
177
179
180
185{
186public:
187 DIALOG_FILTER_SELECTION::OPTIONS m_filterOpts;
188};
189
190
192 SELECTION_TOOL( "common.InteractiveSelection" ),
193 m_frame( NULL ),
194 m_enteredGroup( NULL ),
195 m_lockedItemsFiltered( false ),
196 m_priv( nullptr )
197{
198}
199
200
202{
203}
204
205
207{
208 return true;
209}
210
211
212void PCB_SELECTION_TOOL::Reset( RESET_REASON aReason )
213{
214}
215
216
217int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
218{
219 return 0;
220}
221
222
224{
225}
226
227
228void PCB_SELECTION_TOOL::ExitGroup( bool aSelectGroup )
229{
230}
231
232
234{
235 return m_selection;
236}
237
238
240{
241 m_lockedItemsFiltered = false;
242 return m_selection;
243}
244
245
247{
248 return GENERAL_COLLECTORS_GUIDE( LSET(), PCB_LAYER_ID::UNDEFINED_LAYER, nullptr );
249}
250
251
252bool PCB_SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
253 bool* aSelectionCancelledFlag,
254 CLIENT_SELECTION_FILTER aClientFilter )
255{
256 return false;
257}
258
259
260bool PCB_SELECTION_TOOL::selectCursor( bool aForceSelect, CLIENT_SELECTION_FILTER aClientFilter )
261{
262 return false;
263}
264
265
267 bool aExclusiveOr )
268{
269}
270
271
273{
274 return 0;
275}
276
277
279{
280 return 0;
281}
282
283
284int PCB_SELECTION_TOOL::SelectAll( const TOOL_EVENT& aEvent )
285{
286 return 0;
287}
288
289
291{
292 return 0;
293}
294
295
297 const std::vector<BOARD_CONNECTED_ITEM*>& aStartItems, STOP_CONDITION aStopCondition )
298{
299}
300
301
302void PCB_SELECTION_TOOL::SelectAllItemsOnNet( int aNetCode, bool aSelect )
303{
304}
305
306
307int PCB_SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
308{
309 return 0;
310}
311
312
313void PCB_SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetPath )
314{
315}
316
317
319{
320}
321
322
324{
325 return 0;
326}
327
328
330{
331 return 0;
332}
333
334
336{
337 return false;
338}
339
340
348static bool itemIsIncludedByFilter( const BOARD_ITEM& aItem, const BOARD& aBoard,
349 const DIALOG_FILTER_SELECTION::OPTIONS& aFilterOptions )
350{
351 return false;
352}
353
354
356{
357 return 0;
358}
359
360
361void PCB_SELECTION_TOOL::FilterCollectedItems( GENERAL_COLLECTOR& aCollector, bool aMultiSelect,
363{
364}
365
366
367bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect,
369{
370 return true;
371}
372
373
374void PCB_SELECTION_TOOL::ClearSelection( bool aQuietMode )
375{
376}
377
378
380{
381}
382
383
384bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly ) const
385{
386 return false;
387}
388
389
390bool PCB_SELECTION_TOOL::SelectionContains( const VECTOR2I& aPoint ) const
391{
392 return false;
393}
394
396 const VECTOR2I& aWhere ) const
397{
398}
399
400
402{
403 return 0;
404}
405
406
408{
409}
410
411
413{
414}
415
416
418{
419}
420
421
422void PCB_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aHighlightMode,
423 SELECTION* aGroup )
424{
425}
426
427
428void PCB_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aHighlightMode,
429 SELECTION* aGroup )
430{
431}
432
435 const wxString& aCommitMessage, int aOptions )
436{
437}
438
439
441{
442 return true;
443}
444
445
446void PCB_TOOL_BASE::Reset( RESET_REASON aReason )
447{
448}
449
450
452{
453}
454
455
457{
458 return false;
459}
460
461
463{
464 return false;
465}
466
467
469{
470}
471
472
475 m_fillInProgress( false )
476{
477}
478
479
481{
482}
483
484
485void ZONE_FILLER_TOOL::Reset( RESET_REASON aReason )
486{
487}
488
489
491{
492}
493
494
496{
497 static PCBNEW_SETTINGS::DISPLAY_OPTIONS disp;
498
499 return disp;
500}
501
503{
504 return nullptr;
505}
506
507
509{
510 static PCB_SELECTION sel;
511
512 return sel;
513}
514
515
517{
518 static PCB_SELECTION sel;
519
520 return sel;
521}
522
524{
525 return BOX2I();
526}
527
528
529EDA_ITEM* PCB_SELECTION::GetTopLeftItem( bool onlyModules ) const
530{
531 return nullptr;
532}
533
534
535const std::vector<KIGFX::VIEW_ITEM*> PCB_SELECTION::updateDrawList() const
536{
537 std::vector<VIEW_ITEM*> items;
538
539 return items;
540}
541
542
543#if 0
545
550TRACK_BALL::TRACK_BALL(float x) : CAMERA(x) {};
553
554#endif
555
557
559{
560 return nullptr;
561}
562
563
565{
566 return 0;
567}
std::function< void(const VECTOR2I &, GENERAL_COLLECTOR &, PCB_SELECTION_TOOL *)> CLIENT_SELECTION_FILTER
Definition actions.h:33
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
A class used to derive camera objects from.
Definition camera.h:94
Class DIALOG_FILTER_SELECTION_BASE.
DIALOG_FILTER_SELECTION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Filter Selected Items"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void checkBoxClicked(wxCommandEvent &aEvent) override
DIALOG_FILTER_SELECTION(PCB_BASE_FRAME *aParent, OPTIONS &aOptions)
Create the filter selection dialog.
void allItemsClicked(wxCommandEvent &aEvent) override
Class DIALOG_FIND_BASE.
DIALOG_FIND_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE)
~DIALOG_FIND() override
void onTextEnter(wxCommandEvent &event) override
DIALOG_FIND(PCB_EDIT_FRAME *aParent)
bool Show(bool show=true) override
The Show method is overridden to make the search combobox focused by default.
void onFindNextClick(wxCommandEvent &event) override
void onSearchAgainClick(wxCommandEvent &event) override
void onShowSearchPanel(wxHyperlinkEvent &event) override
void onFindPreviousClick(wxCommandEvent &event) override
void OnCharHook(wxKeyEvent &aEvent) override
void OnBoardChanged(wxCommandEvent &event)
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:81
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
A general implementation of a COLLECTORS_GUIDE.
Definition collectors.h:320
Used when the right click button is pressed, or when the select tool is in effect.
Definition collectors.h:203
Represent a selection area (currently a rectangle) in a VIEW, drawn corner-to-corner between two poin...
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
The main frame for Pcbnew.
Private implementation of firewalled private data.
DIALOG_FILTER_SELECTION::OPTIONS m_filterOpts
The selection tool: currently supports:
void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Highlight the item visually.
int selectNet(const TOOL_EVENT &aEvent)
Select all copper connections belonging to the same net(s) as the items in the selection.
int filterSelection(const TOOL_EVENT &aEvent)
Invoke filter dialog and modify current selection.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void EnterGroup() override
Enter the group at the head of the current selection.
void GuessSelectionCandidates(GENERAL_COLLECTOR &aCollector, const VECTOR2I &aWhere) const
Try to guess best selection candidates in case multiple items are clicked, by doing some brain-dead h...
void ExitGroup(bool aSelectGroup=false) override
Leave the currently-entered group.
void select(EDA_ITEM *aItem) override
Take necessary action mark an item as selected.
bool selectCursor(bool aForceSelect=false, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item under the cursor unless there is something already selected.
bool SelectionContains(const VECTOR2I &aPoint) const
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Return the current selection, filtered according to aClientFilter.
bool itemPassesFilter(BOARD_ITEM *aItem, bool aMultiSelect, PCB_SELECTION_FILTER_OPTIONS *aRejected=nullptr)
Return true if the given item passes the current SELECTION_FILTER_OPTIONS.
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const
bool Selectable(const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=nullptr, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item pointed by the parameter aWhere.
void selectAllItemsOnSheet(wxString &aSheetPath)
Select all items with the given sheet timestamp/UUID name (the sheet path).
void SelectMultiple(KIGFX::PREVIEW::SELECTION_AREA &aArea, bool aSubtractive=false, bool aExclusiveOr=false)
Selects multiple PCB items within a specified area.
void setTransitions() override
Set up handlers for various events.
int expandConnection(const TOOL_EVENT &aEvent)
Expand the current connected-item selection to the next boundary (junctions, pads,...
virtual bool ctrlClickHighlights() override
Determine if ctrl-click is highlight net or XOR selection.
int selectSheetContents(const TOOL_EVENT &aEvent)
Select all footprints belonging to same sheet, from Eeschema using cross-probing.
int selectSameSheet(const TOOL_EVENT &aEvent)
Select all footprints belonging to same hierarchical sheet as the selected footprint (same sheet path...
void zoomFitSelection()
Zoom the screen to center and fit the current selection.
void selectAllConnectedTracks(const std::vector< BOARD_CONNECTED_ITEM * > &aStartItems, STOP_CONDITION aStopCondition)
Select connected tracks and vias.
int CursorSelection(const TOOL_EVENT &aEvent)
Select a single item under cursor event handler.
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
PCB_SELECTION & GetSelection()
int Main(const TOOL_EVENT &aEvent)
The main loop.
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
int updateSelection(const TOOL_EVENT &aEvent)
Event handler to update the selection VIEW_ITEM.
bool Init() override
Init() is called once upon a registration of the tool.
void SelectAllItemsOnNet(int aNetCode, bool aSelect=true)
Select all items with the given net code.
void unselect(EDA_ITEM *aItem) override
Take necessary action mark an item as unselected.
int SelectAll(const TOOL_EVENT &aEvent)
Select all items on the board.
void FilterCollectedItems(GENERAL_COLLECTOR &aCollector, bool aMultiSelect, PCB_SELECTION_FILTER_OPTIONS *aRejected=nullptr)
Apply the SELECTION_FITLER_OPTIONS to the collector.
PCB_SELECTION m_selection
Current state of selection.
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Unhighlight the item visually.
EDA_ITEM * GetTopLeftItem(bool aFootprintsOnly=false) const override
BOX2I GetBoundingBox() const override
const std::vector< KIGFX::VIEW_ITEM * > updateDrawList() const override
virtual bool Is45Limited() const
Should the tool use its 45° mode option?
PCB_DRAW_PANEL_GAL * canvas() const
PCBNEW_SETTINGS::DISPLAY_OPTIONS & displayOptions() const
virtual void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
virtual bool Init() override
Init() is called once upon a registration of the tool.
virtual void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void doInteractiveItemPlacement(const TOOL_EVENT &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
Helper function for performing a common interactive idiom: wait for a left click, place an item there...
virtual bool Is90Limited() const
Should the tool limit drawing to horizontal and vertical only?
const PCB_SELECTION & selection() const
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *aSelTool)
Generic, UI-independent tool event.
Definition tool_event.h:167
TRACK_BALL(float aInitialDistance)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void setTransitions() override
Set up handlers for various events.
This file is part of the common library.
@ UNDEFINED_LAYER
Definition layer_ids.h:57
const FAB_LAYER_COLOR * GetColorStandardList()
Definition mocks.cpp:558
int GetColorStandardListCount()
Definition mocks.cpp:564
static bool itemIsIncludedByFilter(const BOARD_ITEM &aItem, const BOARD &aBoard, const DIALOG_FILTER_SELECTION::OPTIONS &aFilterOptions)
Function itemIsIncludedByFilter()
Definition mocks.cpp:348
OBJECT_2D_TYPE
Definition object_2d.h:41
BBOX_3D()
Create with default values a bounding box (not initialized)
Definition bbox_3d.cpp:33
~BBOX_3D()
Definition bbox_3d.cpp:52
Struct that will be set with the result of the user choices in the dialog.
This file contains data structures that are saved in the project file or project local settings file ...
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
#define ZONE_FILLER_TOOL_NAME