Fossil SCM

Improved comments on the graph layout rail shuffling.

drh 2022-03-22 13:30 trunk
Commit ebbfe7d9973664826c0a7c11b603b8e0a4c76382950d500d9cb57e1fdd757bb7
1 file changed +16 -3
+16 -3
--- src/graph.c
+++ src/graph.c
@@ -890,17 +890,30 @@
890890
*/
891891
find_max_rail(p);
892892
893893
/*
894894
** Compute the rail mapping that tries to put the branch named
895
- ** zLeftBranch at the left margin.
895
+ ** zLeftBranch at the left margin. Other branches that merge
896
+ ** with zLeftBranch are to the right with merge rails in between.
896897
**
897898
** aMap[X]=Y means that the X-th rail is drawn as the Y-th rail.
899
+ **
900
+ ** Do not move rails around if there are timewarps, because that can
901
+ ** seriously mess up the display of timewarps. Timewarps should be
902
+ ** rare so this should not be a serious limitation to the algorithm.
898903
*/
899904
aMap = p->aiRailMap;
900
- for(i=0; i<=p->mxRail; i++) aMap[i] = i;
905
+ for(i=0; i<=p->mxRail; i++) aMap[i] = i; /* Set up a default mapping */
901906
if( nTimewarp==0 ){
907
+ /* Priority bits:
908
+ **
909
+ ** 0x04 The preferred branch
910
+ **
911
+ ** 0x02 A merge rail - a rail that contains merge lines
912
+ **
913
+ ** 0x01 A rail that merges with the preferred branch
914
+ */
902915
u8 aPriority[GR_MAX_RAIL];
903916
memset(aPriority, 0, p->mxRail+1);
904917
if( zLeftBranch ){
905918
char *zLeft = persistBranchName(p, zLeftBranch);
906919
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
@@ -922,11 +935,10 @@
922935
}
923936
if( pRow->mergeOut>=0 ) aPriority[pRow->mergeOut] |= 1;
924937
}
925938
}
926939
}
927
- j = 0;
928940
for(i=0; i<=p->mxRail; i++){
929941
if( p->mergeRail & BIT(i) ){
930942
aPriority[i] |= 2;
931943
}
932944
}
@@ -936,10 +948,11 @@
936948
fprintf(stderr,"Priority:");
937949
for(i=0; i<=p->mxRail; i++) fprintf(stderr," %d", aPriority[i]);
938950
fprintf(stderr,"\n");
939951
#endif
940952
953
+ j = 0;
941954
for(i=0; i<=p->mxRail; i++){
942955
if( aPriority[i]>=4 ) aMap[i] = j++;
943956
}
944957
for(i=p->mxRail; i>=0; i--){
945958
if( aPriority[i]==3 ) aMap[i] = j++;
946959
--- src/graph.c
+++ src/graph.c
@@ -890,17 +890,30 @@
890 */
891 find_max_rail(p);
892
893 /*
894 ** Compute the rail mapping that tries to put the branch named
895 ** zLeftBranch at the left margin.
 
896 **
897 ** aMap[X]=Y means that the X-th rail is drawn as the Y-th rail.
 
 
 
 
898 */
899 aMap = p->aiRailMap;
900 for(i=0; i<=p->mxRail; i++) aMap[i] = i;
901 if( nTimewarp==0 ){
 
 
 
 
 
 
 
 
902 u8 aPriority[GR_MAX_RAIL];
903 memset(aPriority, 0, p->mxRail+1);
904 if( zLeftBranch ){
905 char *zLeft = persistBranchName(p, zLeftBranch);
906 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
@@ -922,11 +935,10 @@
922 }
923 if( pRow->mergeOut>=0 ) aPriority[pRow->mergeOut] |= 1;
924 }
925 }
926 }
927 j = 0;
928 for(i=0; i<=p->mxRail; i++){
929 if( p->mergeRail & BIT(i) ){
930 aPriority[i] |= 2;
931 }
932 }
@@ -936,10 +948,11 @@
936 fprintf(stderr,"Priority:");
937 for(i=0; i<=p->mxRail; i++) fprintf(stderr," %d", aPriority[i]);
938 fprintf(stderr,"\n");
939 #endif
940
 
941 for(i=0; i<=p->mxRail; i++){
942 if( aPriority[i]>=4 ) aMap[i] = j++;
943 }
944 for(i=p->mxRail; i>=0; i--){
945 if( aPriority[i]==3 ) aMap[i] = j++;
946
--- src/graph.c
+++ src/graph.c
@@ -890,17 +890,30 @@
890 */
891 find_max_rail(p);
892
893 /*
894 ** Compute the rail mapping that tries to put the branch named
895 ** zLeftBranch at the left margin. Other branches that merge
896 ** with zLeftBranch are to the right with merge rails in between.
897 **
898 ** aMap[X]=Y means that the X-th rail is drawn as the Y-th rail.
899 **
900 ** Do not move rails around if there are timewarps, because that can
901 ** seriously mess up the display of timewarps. Timewarps should be
902 ** rare so this should not be a serious limitation to the algorithm.
903 */
904 aMap = p->aiRailMap;
905 for(i=0; i<=p->mxRail; i++) aMap[i] = i; /* Set up a default mapping */
906 if( nTimewarp==0 ){
907 /* Priority bits:
908 **
909 ** 0x04 The preferred branch
910 **
911 ** 0x02 A merge rail - a rail that contains merge lines
912 **
913 ** 0x01 A rail that merges with the preferred branch
914 */
915 u8 aPriority[GR_MAX_RAIL];
916 memset(aPriority, 0, p->mxRail+1);
917 if( zLeftBranch ){
918 char *zLeft = persistBranchName(p, zLeftBranch);
919 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
@@ -922,11 +935,10 @@
935 }
936 if( pRow->mergeOut>=0 ) aPriority[pRow->mergeOut] |= 1;
937 }
938 }
939 }
 
940 for(i=0; i<=p->mxRail; i++){
941 if( p->mergeRail & BIT(i) ){
942 aPriority[i] |= 2;
943 }
944 }
@@ -936,10 +948,11 @@
948 fprintf(stderr,"Priority:");
949 for(i=0; i<=p->mxRail; i++) fprintf(stderr," %d", aPriority[i]);
950 fprintf(stderr,"\n");
951 #endif
952
953 j = 0;
954 for(i=0; i<=p->mxRail; i++){
955 if( aPriority[i]>=4 ) aMap[i] = j++;
956 }
957 for(i=p->mxRail; i>=0; i--){
958 if( aPriority[i]==3 ) aMap[i] = j++;
959

Keyboard Shortcuts

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