Update RevisionGraph to 15570
[TortoiseGit.git] / src / TortoiseProc / RevisionGraph / StandardLayout.h
blob4011b4b9093a67ac2edcabf1deabc4680610b1db
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 #include "IRevisionGraphLayout.h"
23 class CVisibleGraphNode;
24 class CVisibleGraph;
26 namespace LogCache
28 class CCachedLogInfo;
31 class CStandardLayoutNodeInfo
33 public:
35 /// the node to place within the layout
37 const CVisibleGraphNode* node;
39 /// links for faster navigation
41 CStandardLayoutNodeInfo* parentBranch;
42 CStandardLayoutNodeInfo* firstSubBranch;
43 CStandardLayoutNodeInfo* nextInBranch;
44 CStandardLayoutNodeInfo* previousInBranch;
45 CStandardLayoutNodeInfo* lastInBranch;
46 CStandardLayoutNodeInfo* nextBranch;
47 CStandardLayoutNodeInfo* previousBranch;
48 CStandardLayoutNodeInfo* lastBranch;
50 /// the graph may consist of multiple trees.
51 /// root(node) = graph (node)->GetRoot (rootID);
53 index_t rootID;
55 /// branch sizes
57 index_t subTreeWidth;
58 index_t subTreeHeight;
59 index_t subTreeWeight;
60 index_t branchLength;
62 /// node properties
64 bool requiresRevision;
65 bool requiresPath;
66 bool requiresGap;
68 /// number of path elements that shall not be shown
69 /// (used by "show diff path" option)
71 index_t skipStartPathElements;
72 index_t skipTailPathElements;
74 /// required size(s) to display all content
76 CSize requiredSize;
78 /// temp. value used to store the offset of the final position
79 /// to the current one (logical coordinates)
81 CSize treeShift;
82 CSize subTreeShift;
84 /// actual position (logical coordinates)
86 CRect rect;
88 /// initialization
90 CStandardLayoutNodeInfo();
93 /**
94 * utility interface that gives layout options access to the layout info
97 class IStandardLayoutNodeAccess
99 public:
101 /// make sub-classes deletable through the base interface
103 virtual ~IStandardLayoutNodeAccess() {};
105 /// access graph node layout
107 virtual index_t GetNodeCount() const = 0;
108 virtual CStandardLayoutNodeInfo* GetNode (index_t index) = 0;
111 class CStandardLayout
112 : public IRevisionGraphLayout
113 , public IStandardLayoutNodeAccess
115 public:
117 struct STextInfo
119 index_t nodeIndex;
120 int subPathIndex; // 0 -> revNum, pathElementIndex otherwise
122 STextInfo (index_t nodeIndex, int subPathIndex)
123 : nodeIndex (nodeIndex)
124 , subPathIndex (subPathIndex)
129 private:
131 /// source of revision data
133 const CCachedLogInfo* cache;
135 /// logical tree structure
137 const CVisibleGraph* graph;
139 /// nodes (in the order defined by CVisibleGraphNode::index)
141 std::vector<CStandardLayoutNodeInfo> nodes;
143 /// connections with length > 0. Stored as node index pairs.
145 std::vector<std::pair<index_t, index_t> > connections;
147 /// non-empty texts. Stored as node index, 'is path' pairs
149 std::vector<STextInfo> texts;
151 /// bounding rects of the individual trees
153 std::vector<CRect> trees;
155 /// area that covers all visible items
157 CRect boundingRect;
159 /// layout creation
161 void SortNodes();
162 void InitializeNodes ( const CVisibleGraphNode* node
163 , CStandardLayoutNodeInfo* parentBranch);
164 void InitializeNodes();
166 void CreateConnections();
167 void CreateTexts();
169 void CloseTreeBoundingRectGaps();
170 void CalculateTreeBoundingRects();
172 void CalculateBoundingRect();
174 public:
176 /// construction / destruction
178 CStandardLayout (const CCachedLogInfo* cache, const CVisibleGraph* graph);
179 virtual ~CStandardLayout(void);
181 /// call this after executing the format options
183 void Finalize();
185 /// implement IRevisionGraphLayout
187 virtual CRect GetRect() const;
189 virtual const ILayoutRectList* GetTrees() const;
190 virtual const ILayoutNodeList* GetNodes() const;
191 virtual const ILayoutConnectionList* GetConnections() const;
192 virtual const ILayoutTextList* GetTexts() const;
194 /// implement IStandardLayoutNodeAccess
196 virtual index_t GetNodeCount() const;
197 virtual CStandardLayoutNodeInfo* GetNode (index_t index);