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 wxChoice;
36
37
50{
51public:
52 using SHEET_SWITCHER = std::function<void( WIDGET_DIFF_CANVAS&, const KIID_PATH& )>;
53
54 DIALOG_KICAD_DIFF( wxWindow* aParent, const wxString& aReferencePath, const wxString& aComparisonPath,
55 const KICAD_DIFF::DOCUMENT_DIFF& aDiff, KICAD_DIFF::DOCUMENT_GEOMETRY aReferenceGeometry = {},
56 KICAD_DIFF::DOCUMENT_GEOMETRY aComparisonGeometry = {}, SHEET_SWITCHER aSheetSwitcher = {},
57 KIID_PATH aInitialSheet = {} );
58
59 ~DIALOG_KICAD_DIFF() override = default;
60
61 void SwitchCanvasToSheet( const KIID_PATH& aSheetPath );
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 CHANGE_SELECTED_FN = std::function<void( const KIID_PATH& )>;
79
81
82protected:
83 void OnClose( wxCloseEvent& aEvent ) override;
84 void OnTreeSelectionChanged( wxTreeEvent& aEvent ) override;
85 void OnTreeItemMenu( wxTreeEvent& aEvent );
86 void OnOK( wxCommandEvent& aEvent ) override;
87
88private:
90 void buildTree();
91
94 void showChange( const KICAD_DIFF::ITEM_CHANGE* aChange );
95
100 bool selectChangeById( const KIID_PATH& aChangeId );
101
103 void applyHiddenToTree();
104
107 std::vector<KIID_PATH> changeRowIds( const KICAD_DIFF::ITEM_CHANGE& aChange ) const;
108
110
112 std::set<KIID_PATH> m_hiddenChanges;
113
115 wxChoice* m_revisionChoice = nullptr;
116
120 std::map<wxUIntPtr, const KICAD_DIFF::ITEM_CHANGE*> m_changeByTreeId;
121
125
129
133 bool m_suppressCenter = false;
134
137
139};
140
141#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
void OnTreeSelectionChanged(wxTreeEvent &aEvent) override
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...
std::function< void(const KIID_PATH &)> CHANGE_SELECTED_FN
std::function< void(int aIndex)> REVISION_HANDLER
WIDGET_DIFF_CANVAS * m_canvas
GAL-backed canvas showing the DIFF_SCENE shape rectangles.
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...
void OnOK(wxCommandEvent &aEvent) override
void buildTree()
Populate the tree from m_diff. Groups by CHANGE_KIND.
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.
void SetChangeSelectedHandler(CHANGE_SELECTED_FN aFn)
KICAD_DIFF::DOCUMENT_DIFF m_diff
void OnClose(wxCloseEvent &aEvent) override
REVISION_HANDLER m_revisionHandler
void OnTreeItemMenu(wxTreeEvent &aEvent)
void SwitchCanvasToSheet(const KIID_PATH &aSheetPath)
const KIID_PATH & CurrentCanvasSheet() const
CHANGE_SELECTED_FN m_changeSelectedFn
~DIALOG_KICAD_DIFF() override=default
WIDGET_DIFF_CANVAS * DiffCanvas() const
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.