Fossil SCM

Improvements to the graph layout algorithm to render a more compact graph when there is lots of branching and merging.

drh 2010-03-03 04:08 trunk
Commit 71edacd95f3b58aea2b158241732c99f2ed4d0a1
1 file changed +8 -3
+8 -3
--- src/graph.c
+++ src/graph.c
@@ -189,19 +189,21 @@
189189
** Compute the complete graph
190190
*/
191191
void graph_finish(GraphContext *p, int omitDescenders){
192192
GraphRow *pRow, *pDesc;
193193
Bag allRids;
194
+ Bag notLeaf;
194195
int i;
195196
int nRow;
196197
u32 mask;
197198
u32 inUse;
198199
199200
if( p==0 || p->pFirst==0 || p->nErr ) return;
200201
201202
/* Initialize all rows */
202203
bag_init(&allRids);
204
+ bag_init(&notLeaf);
203205
nRow = 0;
204206
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
205207
if( pRow->pNext ) pRow->pNext->pPrev = pRow;
206208
pRow->idx = ++nRow;
207209
pRow->iRail = -1;
@@ -216,10 +218,13 @@
216218
for(i=1; i<pRow->nParent; i++){
217219
if( !bag_find(&allRids, pRow->aParent[i]) ){
218220
pRow->aParent[i] = pRow->aParent[--pRow->nParent];
219221
i--;
220222
}
223
+ }
224
+ if( pRow->nParent>0 && bag_find(&allRids, pRow->aParent[0]) ){
225
+ bag_insert(&notLeaf, pRow->aParent[0]);
221226
}
222227
}
223228
224229
/* Identify rows where the primary parent is off screen. Assign
225230
** each to a rail and draw descenders to the bottom of the screen.
@@ -267,14 +272,14 @@
267272
}else{
268273
pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse, 0);
269274
}
270275
pDesc->aiRaiser[pRow->iRail] = pRow->idx;
271276
mask = 1<<pRow->iRail;
272
- if( pRow->isLeaf ){
273
- inUse &= ~mask;
277
+ if( bag_find(&notLeaf, pRow->rid) ){
278
+ inUse |= mask;
274279
}else{
275
- inUse |= mask;
280
+ inUse &= ~mask;
276281
}
277282
for(pDesc = pRow; ; pDesc=pDesc->pNext){
278283
assert( pDesc!=0 );
279284
pDesc->railInUse |= mask;
280285
if( pDesc->rid==parentRid ) break;
281286
--- src/graph.c
+++ src/graph.c
@@ -189,19 +189,21 @@
189 ** Compute the complete graph
190 */
191 void graph_finish(GraphContext *p, int omitDescenders){
192 GraphRow *pRow, *pDesc;
193 Bag allRids;
 
194 int i;
195 int nRow;
196 u32 mask;
197 u32 inUse;
198
199 if( p==0 || p->pFirst==0 || p->nErr ) return;
200
201 /* Initialize all rows */
202 bag_init(&allRids);
 
203 nRow = 0;
204 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
205 if( pRow->pNext ) pRow->pNext->pPrev = pRow;
206 pRow->idx = ++nRow;
207 pRow->iRail = -1;
@@ -216,10 +218,13 @@
216 for(i=1; i<pRow->nParent; i++){
217 if( !bag_find(&allRids, pRow->aParent[i]) ){
218 pRow->aParent[i] = pRow->aParent[--pRow->nParent];
219 i--;
220 }
 
 
 
221 }
222 }
223
224 /* Identify rows where the primary parent is off screen. Assign
225 ** each to a rail and draw descenders to the bottom of the screen.
@@ -267,14 +272,14 @@
267 }else{
268 pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse, 0);
269 }
270 pDesc->aiRaiser[pRow->iRail] = pRow->idx;
271 mask = 1<<pRow->iRail;
272 if( pRow->isLeaf ){
273 inUse &= ~mask;
274 }else{
275 inUse |= mask;
276 }
277 for(pDesc = pRow; ; pDesc=pDesc->pNext){
278 assert( pDesc!=0 );
279 pDesc->railInUse |= mask;
280 if( pDesc->rid==parentRid ) break;
281
--- src/graph.c
+++ src/graph.c
@@ -189,19 +189,21 @@
189 ** Compute the complete graph
190 */
191 void graph_finish(GraphContext *p, int omitDescenders){
192 GraphRow *pRow, *pDesc;
193 Bag allRids;
194 Bag notLeaf;
195 int i;
196 int nRow;
197 u32 mask;
198 u32 inUse;
199
200 if( p==0 || p->pFirst==0 || p->nErr ) return;
201
202 /* Initialize all rows */
203 bag_init(&allRids);
204 bag_init(&notLeaf);
205 nRow = 0;
206 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
207 if( pRow->pNext ) pRow->pNext->pPrev = pRow;
208 pRow->idx = ++nRow;
209 pRow->iRail = -1;
@@ -216,10 +218,13 @@
218 for(i=1; i<pRow->nParent; i++){
219 if( !bag_find(&allRids, pRow->aParent[i]) ){
220 pRow->aParent[i] = pRow->aParent[--pRow->nParent];
221 i--;
222 }
223 }
224 if( pRow->nParent>0 && bag_find(&allRids, pRow->aParent[0]) ){
225 bag_insert(&notLeaf, pRow->aParent[0]);
226 }
227 }
228
229 /* Identify rows where the primary parent is off screen. Assign
230 ** each to a rail and draw descenders to the bottom of the screen.
@@ -267,14 +272,14 @@
272 }else{
273 pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse, 0);
274 }
275 pDesc->aiRaiser[pRow->iRail] = pRow->idx;
276 mask = 1<<pRow->iRail;
277 if( bag_find(&notLeaf, pRow->rid) ){
278 inUse |= mask;
279 }else{
280 inUse &= ~mask;
281 }
282 for(pDesc = pRow; ; pDesc=pDesc->pNext){
283 assert( pDesc!=0 );
284 pDesc->railInUse |= mask;
285 if( pDesc->rid==parentRid ) break;
286

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button