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.
21 #include "IRevisionGraphLayout.h"
23 class CVisibleGraphNode
;
31 class CStandardLayoutNodeInfo
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);
58 index_t subTreeHeight
;
59 index_t subTreeWeight
;
64 bool requiresRevision
;
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
78 /// temp. value used to store the offset of the final position
79 /// to the current one (logical coordinates)
84 /// actual position (logical coordinates)
90 CStandardLayoutNodeInfo();
94 * utility interface that gives layout options access to the layout info
97 class IStandardLayoutNodeAccess
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
120 int subPathIndex
; // 0 -> revNum, pathElementIndex otherwise
122 STextInfo (index_t nodeIndex
, int subPathIndex
)
123 : nodeIndex (nodeIndex
)
124 , subPathIndex (subPathIndex
)
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
162 void InitializeNodes ( const CVisibleGraphNode
* node
163 , CStandardLayoutNodeInfo
* parentBranch
);
164 void InitializeNodes();
166 void CreateConnections();
169 void CloseTreeBoundingRectGaps();
170 void CalculateTreeBoundingRects();
172 void CalculateBoundingRect();
176 /// construction / destruction
178 CStandardLayout (const CCachedLogInfo
* cache
, const CVisibleGraph
* graph
);
179 virtual ~CStandardLayout(void);
181 /// call this after executing the format options
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
);