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