KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_re_condition_group_panel.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) 2024 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#pragma once
21
22#include <wx/panel.h>
23#include <functional>
24#include <vector>
26
27
28class BOARD;
30class wxChoice;
31class wxBitmapButton;
32class wxBoxSizer;
33class wxStaticText;
34
41class DRC_RE_CONDITION_GROUP_PANEL : public wxPanel
42{
43public:
44 enum class BOOL_OPERATOR
45 {
46 AND = 0,
50 };
51
52 DRC_RE_CONDITION_GROUP_PANEL( wxWindow* aParent, BOARD* aBoard, bool aTwoObjectConstraint );
53
59 void ParseCondition( const wxString& aConditionExpr );
60
66 wxString BuildCondition() const;
67
71 void SetChangeCallback( std::function<void()> aCallback ) { m_changeCallback = aCallback; }
72
76 bool HasCustomQuerySelected() const;
77
78private:
86
88 void removeConditionRow( int aIndex );
89 void onAddClicked( wxCommandEvent& aEvent );
90 void rebuildLayout();
92
100 bool tokenizeCondition( const wxString& aExpr,
101 std::vector<std::pair<BOOL_OPERATOR, wxString>>& aParts );
102
106 std::vector<CONDITION_ENTRY> m_conditions;
107 wxBoxSizer* m_mainSizer;
109 wxStaticText* m_labelText;
110
111 std::function<void()> m_changeCallback;
112};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
std::vector< CONDITION_ENTRY > m_conditions
void onAddClicked(wxCommandEvent &aEvent)
bool tokenizeCondition(const wxString &aExpr, std::vector< std::pair< BOOL_OPERATOR, wxString > > &aParts)
Tokenize a condition expression by boolean operators.
void ParseCondition(const wxString &aConditionExpr)
Parse a condition string and populate the UI.
DRC_RE_CONDITION_GROUP_PANEL(wxWindow *aParent, BOARD *aBoard, bool aTwoObjectConstraint)
void addConditionRow(BOOL_OPERATOR aOp=BOOL_OPERATOR::AND)
wxString BuildCondition() const
Build a condition string from the current UI state.
void SetChangeCallback(std::function< void()> aCallback)
Set a callback to be invoked when any condition changes.
A single condition row in the condition group panel.
A bitmap button widget that behaves like a standard dialog button except with an icon.
DRC_RE_CONDITION_ROW_PANEL * panel
wxChoice * operatorChoice
wxBoxSizer * rowSizer
BOOL_OPERATOR boolOp