KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_kicad_diff.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 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 3
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/gpl-3.0.html
19 */
20
21#ifndef DIALOG_KICAD_DIFF_H
22#define DIALOG_KICAD_DIFF_H
23
25
28
29#include <functional>
30#include <map>
31#include <set>
32
33
35class wxButton;
36class wxChoice;
37class wxWrapSizer;
38
39
52{
53public:
54 using SHEET_SWITCHER = std::function<void( WIDGET_DIFF_CANVAS&, const KIID_PATH& )>;
55
56 DIALOG_KICAD_DIFF( wxWindow* aParent, const wxString& aReferencePath, const wxString& aComparisonPath,
57 const KICAD_DIFF::DOCUMENT_DIFF& aDiff, KICAD_DIFF::DOCUMENT_GEOMETRY aReferenceGeometry = {},
58 KICAD_DIFF::DOCUMENT_GEOMETRY aComparisonGeometry = {}, SHEET_SWITCHER aSheetSwitcher = {},
59 KIID_PATH aInitialSheet = {} );
60
61 ~DIALOG_KICAD_DIFF() override = default;
62
64
67 void Reload( const wxString& aReferencePath, const wxString& aComparisonPath, KICAD_DIFF::DOCUMENT_DIFF aDiff,
68 KICAD_DIFF::DOCUMENT_GEOMETRY aReferenceGeometry, KICAD_DIFF::DOCUMENT_GEOMETRY aComparisonGeometry,
69 SHEET_SWITCHER aSheetSwitcher, KIID_PATH aInitialSheet );
70
71 using REVISION_HANDLER = std::function<void( int aIndex )>;
72
76 void SetRevisionChooser( const std::vector<wxString>& aLabels, int aSelected, REVISION_HANDLER aOnChange );
77
78 using LIBRARY_ITEM_DRAWER = std::function<void( WIDGET_DIFF_CANVAS&, const wxString& aName )>;
79
85
86 using UP_HANDLER = std::function<void()>;
87
88 void SetUpHandler( UP_HANDLER aHandler );
89
90 void EnableUp( bool aEnable );
91
92protected:
93 void OnClose( wxCloseEvent& aEvent ) override;
94 void OnTreeSelectionChanged( wxTreeEvent& aEvent ) override;
95 void OnTreeItemMenu( wxTreeEvent& aEvent );
96 void OnOK( wxCommandEvent& aEvent ) override;
97
98private:
101
104 void buildTree( const std::optional<KIID_PATH>& aSelect );
105
107 std::optional<KIID_PATH> selectedChangeId() const;
108
111 void showChange( const KICAD_DIFF::ITEM_CHANGE* aChange );
112
114 void showDiffSummary();
115
120 bool selectChangeById( const KIID_PATH& aChangeId );
121
123 void applyHiddenToTree();
124
126 void buildLayerControls( const KICAD_DIFF::DIFF_SCENE& aScene );
127
130 std::vector<KIID_PATH> changeRowIds( const KICAD_DIFF::ITEM_CHANGE& aChange ) const;
131
133
135 std::set<KIID_PATH> m_hiddenChanges;
136
138 wxChoice* m_revisionChoice = nullptr;
139
141 wxButton* m_btnUp = nullptr;
142 wxWrapSizer* m_filterSizer = nullptr;
143
146 std::vector<wxWindow*> m_layerControls;
147
151 std::map<wxUIntPtr, const KICAD_DIFF::ITEM_CHANGE*> m_changeByTreeId;
152
156
160
164 bool m_suppressCenter = false;
165
168
170};
171
172#endif // DIALOG_KICAD_DIFF_H
DIALOG_KICAD_DIFF_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Compare Files"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(900, 650), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
std::vector< KIID_PATH > changeRowIds(const KICAD_DIFF::ITEM_CHANGE &aChange) const
Change ids a tree row stands for.
SHEET_SWITCHER m_sheetSwitcher
std::optional< KIID_PATH > selectedChangeId() const
The selected row's change id. Valid only while m_diff still owns the listed changes.
size_t m_layerControlsIndex
Index in m_filterSizer of the first layer control, which follow the category filters.
void OnTreeSelectionChanged(wxTreeEvent &aEvent) override
std::function< void(WIDGET_DIFF_CANVAS &, const wxString &aName)> LIBRARY_ITEM_DRAWER
std::set< KIID_PATH > m_hiddenChanges
Changes the user has muted via the tree's right-click menu.
void showChange(const KICAD_DIFF::ITEM_CHANGE *aChange)
Populate the property list for the change associated with the selected tree node, or clear the list i...
wxWrapSizer * m_filterSizer
std::function< void(int aIndex)> REVISION_HANDLER
WIDGET_DIFF_CANVAS * m_canvas
GAL-backed canvas showing the DIFF_SCENE shape rectangles.
void DrawChosenLibraryItem(LIBRARY_ITEM_DRAWER aDraw)
Draw only the library item named by the chosen change, since the outlines of a whole library pile up ...
std::function< void()> UP_HANDLER
std::map< wxUIntPtr, const KICAD_DIFF::ITEM_CHANGE * > m_changeByTreeId
Maps tree item IDs to the underlying change record so selection can find the data without walking the...
std::vector< wxWindow * > m_layerControls
void OnOK(wxCommandEvent &aEvent) override
void buildTree()
Populate the tree from m_diff, keeping the selected change. Groups by CHANGE_KIND.
void SetUpHandler(UP_HANDLER aHandler)
std::function< void(WIDGET_DIFF_CANVAS &, const KIID_PATH &)> SHEET_SWITCHER
wxString m_searchFilter
Lowercased free-text filter applied to typeName / refdes.
void applyHiddenToTree()
Grey out tree rows whose change is in m_hiddenChanges, restore the rest.
DIALOG_KICAD_DIFF(wxWindow *aParent, const wxString &aReferencePath, const wxString &aComparisonPath, const KICAD_DIFF::DOCUMENT_DIFF &aDiff, KICAD_DIFF::DOCUMENT_GEOMETRY aReferenceGeometry={}, KICAD_DIFF::DOCUMENT_GEOMETRY aComparisonGeometry={}, SHEET_SWITCHER aSheetSwitcher={}, KIID_PATH aInitialSheet={})
bool selectChangeById(const KIID_PATH &aChangeId)
Select the tree row whose change has the given KIID_PATH.
KICAD_DIFF::DOCUMENT_DIFF m_diff
void OnClose(wxCloseEvent &aEvent) override
REVISION_HANDLER m_revisionHandler
void OnTreeItemMenu(wxTreeEvent &aEvent)
LIBRARY_ITEM_DRAWER m_drawLibraryItem
void showDiffSummary()
Report the number of changes in the summary label.
void buildLayerControls(const KICAD_DIFF::DIFF_SCENE &aScene)
Replace the layer checkboxes with one per layer of aScene's geometry, after the category filters.
~DIALOG_KICAD_DIFF() override=default
WIDGET_DIFF_CANVAS * DiffCanvas() const
void EnableUp(bool aEnable)
bool m_suppressCenter
True while a canvas click is propagating into the tree, so the tree- selection handler skips re-cente...
void SetRevisionChooser(const std::vector< wxString > &aLabels, int aSelected, REVISION_HANDLER aOnChange)
Add a revision dropdown (with prev/next) at the top.
void Reload(const wxString &aReferencePath, const wxString &aComparisonPath, KICAD_DIFF::DOCUMENT_DIFF aDiff, KICAD_DIFF::DOCUMENT_GEOMETRY aReferenceGeometry, KICAD_DIFF::DOCUMENT_GEOMETRY aComparisonGeometry, SHEET_SWITCHER aSheetSwitcher, KIID_PATH aInitialSheet)
Swap in a fresh diff with new schematics.
GAL-backed canvas for visualizing a KICAD_DIFF::DIFF_SCENE.
The full set of changes between two parsed documents of one type.
Aggregate of background geometry extracted from one source document.
Definition diff_scene.h:163
One change record on a single item.