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
36
38
39
52{
53public:
55 enum class SIDE
56 {
60 };
61
71 {
75
78 std::map<KIID_PATH, BOX2I> ancestorBBoxes;
79 std::map<KIID_PATH, BOX2I> oursBBoxes;
80 std::map<KIID_PATH, BOX2I> theirsBBoxes;
81
88 std::function<void( WIDGET_DIFF_CANVAS&, SIDE, const std::optional<KIID_PATH>& )> drawSide;
89
91 wxString formatNotice;
92
95 std::function<wxString( const KIID_PATH& )> describeItem;
96 };
97
98 DIALOG_KICAD_MERGE_3WAY( wxWindow* aParent, const KICAD_DIFF::MERGE_PLAN& aPlan,
99 CONFLICT_CONTEXT aContext = {} );
100
101 ~DIALOG_KICAD_MERGE_3WAY() override = default;
102
106
107protected:
108 void OnClose( wxCloseEvent& aEvent ) override;
109 void OnConflictSelected( wxCommandEvent& aEvent ) override;
110 void OnResolutionChanged( wxCommandEvent& aEvent ) override;
111 void OnApply( wxCommandEvent& aEvent ) override;
112 void OnCancel( wxCommandEvent& aEvent ) override;
113
114private:
116 void buildList();
117
119 void showConflict( int aIndex );
120
124 void rebuildCanvas();
125
128 SIDE activeSide() const;
129
131 wxString describe( const KIID_PATH& aId, const wxString& aFallback ) const;
132
135
138 std::vector<bool> m_hasMergedEdit;
139
141 std::vector<std::size_t> m_conflictActionIndex;
142
145
149};
150
151#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={})
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.
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.
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.