Fossil SCM
Improvements to the graph layout algorithm to render a more compact graph when there is lots of branching and merging.
Commit
71edacd95f3b58aea2b158241732c99f2ed4d0a1
Parent
732e3db329eee7f…
1 file changed
+8
-3
+8
-3
| --- src/graph.c | ||
| +++ src/graph.c | ||
| @@ -189,19 +189,21 @@ | ||
| 189 | 189 | ** Compute the complete graph |
| 190 | 190 | */ |
| 191 | 191 | void graph_finish(GraphContext *p, int omitDescenders){ |
| 192 | 192 | GraphRow *pRow, *pDesc; |
| 193 | 193 | Bag allRids; |
| 194 | + Bag notLeaf; | |
| 194 | 195 | int i; |
| 195 | 196 | int nRow; |
| 196 | 197 | u32 mask; |
| 197 | 198 | u32 inUse; |
| 198 | 199 | |
| 199 | 200 | if( p==0 || p->pFirst==0 || p->nErr ) return; |
| 200 | 201 | |
| 201 | 202 | /* Initialize all rows */ |
| 202 | 203 | bag_init(&allRids); |
| 204 | + bag_init(¬Leaf); | |
| 203 | 205 | nRow = 0; |
| 204 | 206 | for(pRow=p->pFirst; pRow; pRow=pRow->pNext){ |
| 205 | 207 | if( pRow->pNext ) pRow->pNext->pPrev = pRow; |
| 206 | 208 | pRow->idx = ++nRow; |
| 207 | 209 | pRow->iRail = -1; |
| @@ -216,10 +218,13 @@ | ||
| 216 | 218 | for(i=1; i<pRow->nParent; i++){ |
| 217 | 219 | if( !bag_find(&allRids, pRow->aParent[i]) ){ |
| 218 | 220 | pRow->aParent[i] = pRow->aParent[--pRow->nParent]; |
| 219 | 221 | i--; |
| 220 | 222 | } |
| 223 | + } | |
| 224 | + if( pRow->nParent>0 && bag_find(&allRids, pRow->aParent[0]) ){ | |
| 225 | + bag_insert(¬Leaf, pRow->aParent[0]); | |
| 221 | 226 | } |
| 222 | 227 | } |
| 223 | 228 | |
| 224 | 229 | /* Identify rows where the primary parent is off screen. Assign |
| 225 | 230 | ** each to a rail and draw descenders to the bottom of the screen. |
| @@ -267,14 +272,14 @@ | ||
| 267 | 272 | }else{ |
| 268 | 273 | pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse, 0); |
| 269 | 274 | } |
| 270 | 275 | pDesc->aiRaiser[pRow->iRail] = pRow->idx; |
| 271 | 276 | mask = 1<<pRow->iRail; |
| 272 | - if( pRow->isLeaf ){ | |
| 273 | - inUse &= ~mask; | |
| 277 | + if( bag_find(¬Leaf, pRow->rid) ){ | |
| 278 | + inUse |= mask; | |
| 274 | 279 | }else{ |
| 275 | - inUse |= mask; | |
| 280 | + inUse &= ~mask; | |
| 276 | 281 | } |
| 277 | 282 | for(pDesc = pRow; ; pDesc=pDesc->pNext){ |
| 278 | 283 | assert( pDesc!=0 ); |
| 279 | 284 | pDesc->railInUse |= mask; |
| 280 | 285 | if( pDesc->rid==parentRid ) break; |
| 281 | 286 |
| --- 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(¬Leaf); |
| 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(¬Leaf, 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(¬Leaf, 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 |