KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_constraint_list.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
21
22#include <board.h>
23#include <pcb_base_frame.h>
27
28
30 std::function<void( PCB_CONSTRAINT* )> aHighlight,
31 std::function<void( PCB_CONSTRAINT* )> aRemove ) :
33 m_parentFrame( aParent ),
34 m_board( aBoard ),
35 m_highlight( std::move( aHighlight ) ),
36 m_remove( std::move( aRemove ) )
37{
39
40 Populate();
42}
43
44
46{
47 m_rows.clear();
48
51
53 [&]( long aRow, PCB_CONSTRAINT* aConstraint )
54 {
55 m_rows.push_back( aConstraint );
56 } );
57}
58
59
61{
62 long row = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
63
64 if( row < 0 || row >= static_cast<long>( m_rows.size() ) )
65 return nullptr;
66
67 return m_rows[row];
68}
69
70
71void DIALOG_CONSTRAINT_LIST::onRowActivated( wxListEvent& aEvent )
72{
73 if( PCB_CONSTRAINT* constraint = selectedConstraint() )
74 {
75 m_highlight( constraint );
76
77 // Close so the highlighted members are visible on the canvas behind the dialog.
78 EndModal( wxID_OK );
79 }
80}
81
82
83void DIALOG_CONSTRAINT_LIST::onDelete( wxCommandEvent& aEvent )
84{
85 if( PCB_CONSTRAINT* constraint = selectedConstraint() )
86 {
87 m_remove( constraint );
88 Populate(); // the constraint set changed
89 }
90}
BOARD_CONSTRAINT_DIAGNOSTICS DiagnoseBoardConstraints(BOARD *aBoard)
Diagnose every constraint cluster on the board (validate only – geometry is not changed) and return t...
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
DIALOG_CONSTRAINT_LIST_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Geometric Constraints"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(560, 360), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void onRowActivated(wxListEvent &aEvent) override
DIALOG_CONSTRAINT_LIST(PCB_BASE_FRAME *aParent, BOARD *aBoard, std::function< void(PCB_CONSTRAINT *)> aHighlight, std::function< void(PCB_CONSTRAINT *)> aRemove)
std::vector< PCB_CONSTRAINT * > m_rows
Row index -> constraint.
std::function< void(PCB_CONSTRAINT *)> m_remove
void onDelete(wxCommandEvent &aEvent) override
void Populate()
Rebuild the rows from the board's current constraints.
PCB_CONSTRAINT * selectedConstraint() const
std::function< void(PCB_CONSTRAINT *)> m_highlight
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
A geometric constraint between board items (issue #2329).
void PopulateConstraintList(wxListCtrl *aList, BOARD *aBoard, UNITS_PROVIDER *aUnits, const BOARD_CONSTRAINT_DIAGNOSTICS &aDiag, const std::function< void(long, PCB_CONSTRAINT *)> &aOnRow)
Fill aList with one row per constraint on aBoard (board-owned then footprint-owned),...
void AddConstraintListColumns(wxListCtrl *aList)
Add the four constraint columns (Item 1 / Item 2 / Constraint / State) to a report-mode list.
STL namespace.
Board-wide diagnostics for the constraint overlay and info bar.