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>
30
31
32class BOARD;
34class wxChoice;
35class wxBitmapButton;
36class wxBoxSizer;
37class wxStaticText;
38
45class DRC_RE_CONDITION_GROUP_PANEL : public wxPanel
46{
47public:
48 enum class BOOL_OPERATOR
49 {
50 AND = 0,
54 };
55
56 DRC_RE_CONDITION_GROUP_PANEL( wxWindow* aParent, BOARD* aBoard, bool aTwoObjectConstraint );
57
63 void ParseCondition( const wxString& aConditionExpr );
64
70 wxString BuildCondition() const;
71
75 void SetChangeCallback( std::function<void()> aCallback ) { m_changeCallback = aCallback; }
76
80 bool HasCustomQuerySelected() const;
81
82private:
90
92 void removeConditionRow( int aIndex );
93 void onAddClicked( wxCommandEvent& aEvent );
94 void rebuildLayout();
96
104 bool tokenizeCondition( const wxString& aExpr,
105 std::vector<std::pair<BOOL_OPERATOR, wxString>>& aParts );
106
110 std::vector<CONDITION_ENTRY> m_conditions;
111 wxBoxSizer* m_mainSizer;
113 wxStaticText* m_labelText;
114
115 std::function<void()> m_changeCallback;
116};
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.
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