KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_kicad_merge_3way.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 * or you may search the http://www.gnu.org website for the version 3 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#ifndef DIALOG_KICAD_MERGE_3WAY_H
25#define DIALOG_KICAD_MERGE_3WAY_H
26
28
31
32#include <functional>
33#include <map>
34#include <optional>
35#include <set>
36
37
38class REPORTER;
40
41
54{
55public:
57 enum class SIDE
58 {
62 };
63
73 {
77
80 std::map<KIID_PATH, BOX2I> ancestorBBoxes;
81 std::map<KIID_PATH, BOX2I> oursBBoxes;
82 std::map<KIID_PATH, BOX2I> theirsBBoxes;
83
90 std::function<void( WIDGET_DIFF_CANVAS&, SIDE, const std::optional<KIID_PATH>& )> drawSide;
91
93 wxString formatNotice;
94
97 std::function<wxString( const KIID_PATH& )> describeItem;
98 };
99
100 using LIBRARY_ITEM_DRAWER = std::function<void( WIDGET_DIFF_CANVAS&, SIDE, const wxString& aName )>;
101
106 static CONFLICT_CONTEXT LibraryContext( const std::set<wxString>& aNames, LIBRARY_ITEM_DRAWER aDraw );
107
109 static bool CanOpen( REPORTER& aReporter );
110
111 DIALOG_KICAD_MERGE_3WAY( wxWindow* aParent, const KICAD_DIFF::MERGE_PLAN& aPlan,
112 CONFLICT_CONTEXT aContext = {} );
113
114 ~DIALOG_KICAD_MERGE_3WAY() override = default;
115
119
120protected:
121 void OnClose( wxCloseEvent& aEvent ) override;
122 void OnConflictSelected( wxCommandEvent& aEvent ) override;
123 void OnResolutionChanged( wxCommandEvent& aEvent ) override;
124 void OnApply( wxCommandEvent& aEvent ) override;
125 void OnCancel( wxCommandEvent& aEvent ) override;
126
127private:
129 void buildList();
130
132 void showConflict( int aIndex );
133
137 void rebuildCanvas();
138
141 SIDE activeSide() const;
142
144 wxString describe( const KIID_PATH& aId, const wxString& aFallback ) const;
145
148
151 std::vector<bool> m_hasMergedEdit;
152
154 std::vector<std::size_t> m_conflictActionIndex;
155
158
162};
163
164#endif // DIALOG_KICAD_MERGE_3WAY_H
DIALOG_KICAD_MERGE_3WAY_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Resolve Merge Conflicts"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(950, 700), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
const KICAD_DIFF::MERGE_PLAN & GetResolvedPlan() const
Returns the plan with the user's resolutions applied.
void OnConflictSelected(wxCommandEvent &aEvent) override
SIDE activeSide() const
The side the canvas previews.
DIALOG_KICAD_MERGE_3WAY(wxWindow *aParent, const KICAD_DIFF::MERGE_PLAN &aPlan, CONFLICT_CONTEXT aContext={})
static CONFLICT_CONTEXT LibraryContext(const std::set< wxString > &aNames, LIBRARY_ITEM_DRAWER aDraw)
Context for merging a library, whose items are known by the names in aNames.
static bool CanOpen(REPORTER &aReporter)
Report to aReporter and return false when this process cannot open a dialog.
void OnApply(wxCommandEvent &aEvent) override
wxString describe(const KIID_PATH &aId, const wxString &aFallback) const
The item's name from the editor, or aFallback when there is none.
void OnCancel(wxCommandEvent &aEvent) override
void rebuildCanvas()
Rebuild the canvas scene from the current side (per radio) and the active conflict's bbox.
void OnClose(wxCloseEvent &aEvent) override
WIDGET_DIFF_CANVAS * m_canvas
GAL-backed conflict viewer injected into the resolution panel.
KICAD_DIFF::MERGE_PLAN m_plan
int m_currentConflict
Currently-displayed conflict (index into m_conflictActionIndex), -1 if none.
std::function< void(WIDGET_DIFF_CANVAS &, SIDE, const wxString &aName)> LIBRARY_ITEM_DRAWER
void showConflict(int aIndex)
Update the detail panel for the selected conflict.
void buildList()
Populate the conflict list from the plan's unresolved items.
SIDE
Which side's version the canvas should currently display.
std::vector< bool > m_hasMergedEdit
True where the engine combined both sides' edits, in the order of m_conflictActionIndex.
void OnResolutionChanged(wxCommandEvent &aEvent) override
~DIALOG_KICAD_MERGE_3WAY() override=default
std::vector< std::size_t > m_conflictActionIndex
Indices into m_plan.actions matching the order of m_listConflicts.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
GAL-backed canvas for visualizing a KICAD_DIFF::DIFF_SCENE.
Phase 8 context for the conflict canvas.
std::map< KIID_PATH, BOX2I > ancestorBBoxes
Per-side bbox of each conflicting item.
wxString formatNotice
Shown with the instructions when the merge cannot keep a side's file format.
std::function< void(WIDGET_DIFF_CANVAS &, SIDE, const std::optional< KIID_PATH > &)> drawSide
Draw a side on the canvas with the editor's own painter.
std::function< wxString(const KIID_PATH &)> describeItem
Name an item the way the editor would, so a conflict can be told from its neighbours.
Aggregate of background geometry extracted from one source document.
Definition diff_scene.h:163
Result of planning a 3-way merge.