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
52 index_t subTreeWidth;
\r
53 index_t subTreeHeight;
\r
54 index_t subTreeWeight;
\r
55 index_t branchLength;
\r
59 bool requiresRevision;
\r
63 /// required size(s) to display all content
\r
67 /// temp. value used to store the offset of the final position
\r
68 /// to the current one (logical coordinates)
\r
73 /// actual position (logical coordinates)
\r
79 CStandardLayoutNodeInfo();
\r
83 * utility interface that gives layout options access to the layout info
\r
86 class IStandardLayoutNodeAccess
\r
90 /// make sub-classes deletable through the base interface
\r
92 virtual ~IStandardLayoutNodeAccess() {};
\r
94 /// access graph node layout
\r
96 virtual index_t GetNodeCount() const = 0;
\r
97 virtual CStandardLayoutNodeInfo* GetNode (index_t index) = 0;
\r
100 class CStandardLayout
\r
101 : public IRevisionGraphLayout
\r
102 , public IStandardLayoutNodeAccess
\r
109 int subPathIndex; // 0 -> revNum, pathElementIndex otherwise
\r
111 STextInfo (index_t nodeIndex, int subPathIndex)
\r
112 : nodeIndex (nodeIndex)
\r
113 , subPathIndex (subPathIndex)
\r
120 /// source of revision data
\r
122 const CCachedLogInfo* cache;
\r
124 /// nodes (in the order defined by CVisibleGraphNode::index)
\r
126 std::vector<CStandardLayoutNodeInfo> nodes;
\r
128 /// connections with length > 0. Stored as node index pairs.
\r
130 std::vector<std::pair<index_t, index_t> > connections;
\r
132 /// non-empty texts. Stored as node index, 'is path' pairs
\r
134 std::vector<STextInfo> texts;
\r
136 /// area that covers all visible items
\r
138 CRect boundingRect;
\r
140 /// layout creation
\r
143 void InitializeNodes ( const CVisibleGraphNode* node
\r
144 , CStandardLayoutNodeInfo* parentBranch);
\r
145 void InitializeNodes (const CVisibleGraph* graph);
\r
147 void CreateConnections();
\r
148 void CreateTexts();
\r
149 void CalculateBoundingRect();
\r
153 /// construction / destruction
\r
155 CStandardLayout (const CCachedLogInfo* cache, const CVisibleGraph* graph);
\r
156 virtual ~CStandardLayout(void);
\r
158 /// call this after executing the format options
\r
162 /// implement IRevisionGraphLayout
\r
164 virtual CRect GetRect() const;
\r
166 virtual const ILayoutNodeList* GetNodes() const;
\r
167 virtual const ILayoutConnectionList* GetConnections() const;
\r
168 virtual const ILayoutTextList* GetTexts() const;
\r
170 /// implement IStandardLayoutNodeAccess
\r
172 virtual index_t GetNodeCount() const;
\r
173 virtual CStandardLayoutNodeInfo* GetNode (index_t index);
\r