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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <wx/panel.h>
27#include <functional>
28#include <vector>
29
30class BOARD;
32class wxChoice;
33class wxBitmapButton;
34class wxBoxSizer;
35class wxStaticText;
36
43class DRC_RE_CONDITION_GROUP_PANEL : public wxPanel
44{
45public:
46 enum class BOOL_OPERATOR
47 {
48 AND = 0,
52 };
53
54 DRC_RE_CONDITION_GROUP_PANEL( wxWindow* aParent, BOARD* aBoard, bool aTwoObjectConstraint );
55
61 void ParseCondition( const wxString& aConditionExpr );
62
68 wxString BuildCondition() const;
69
73 void SetChangeCallback( std::function<void()> aCallback ) { m_changeCallback = aCallback; }
74
78 bool HasCustomQuerySelected() const;
79
80private:
88
90 void removeConditionRow( int aIndex );
91 void onAddClicked( wxCommandEvent& aEvent );
92 void rebuildLayout();
94
102 bool tokenizeCondition( const wxString& aExpr,
103 std::vector<std::pair<BOOL_OPERATOR, wxString>>& aParts );
104
108 std::vector<CONDITION_ENTRY> m_conditions;
109 wxBoxSizer* m_mainSizer;
110 wxBitmapButton* m_addBtn;
111 wxStaticText* m_labelText;
112
113 std::function<void()> m_changeCallback;
114};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
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.
DRC_RE_CONDITION_ROW_PANEL * panel
wxChoice * operatorChoice
wxBoxSizer * rowSizer
BOOL_OPERATOR boolOp