comparison data/model/PowerOfSqrtTwoZoomConstraint.cpp @ 1552:05c3fbaec8ea

Introduce RelativelyFineZoomConstraint, which encodes more-or-less the scheme that was already used for the horizontal thumbwheel in the pane (which overrode the layers' own zoom constraints unless they said they couldn't support any other)
author Chris Cannam
date Wed, 10 Oct 2018 14:32:34 +0100
parents c1c45c5146bb
children
comparison
equal deleted inserted replaced
1551:4de4284d0596 1552:05c3fbaec8ea
101 101
102 // SVCERR << "Testing base " << base << " (i = " << i << ", power = " << power << ", type = " << type << ")" << endl; 102 // SVCERR << "Testing base " << base << " (i = " << i << ", power = " << power << ", type = " << type << ")" << endl;
103 103
104 if (base == blockSize) { 104 if (base == blockSize) {
105 result = base; 105 result = base;
106 // SVCERR << "Equal, accepting" << endl;
106 break; 107 break;
107 } 108 }
108 109
109 if (base > blockSize) { 110 if (base > blockSize) {
110 if (dir == RoundNearest) { 111 if (dir == RoundNearest) {
111 if (base - blockSize < blockSize - prevBase) { 112 if (base - blockSize < blockSize - prevBase) {
112 dir = RoundUp; 113 dir = RoundUp;
114 // SVCERR << "Closer to " << base << " than " << prevBase
115 // << ", rounding up" << endl;
113 } else { 116 } else {
114 dir = RoundDown; 117 dir = RoundDown;
118 // SVCERR << "Closer to " << prevBase << " than " << base
119 // << ", rounding down" << endl;
115 } 120 }
116 } 121 }
117 if (dir == RoundUp) { 122 if (dir == RoundUp) {
118 result = base; 123 result = base;
119 break; 124 break;
132 137
133 if (result > getMaxZoomLevel().level) { 138 if (result > getMaxZoomLevel().level) {
134 result = getMaxZoomLevel().level; 139 result = getMaxZoomLevel().level;
135 } 140 }
136 141
142 // SVCERR << "Returning result " << result << endl;
143
137 return result; 144 return result;
138 } 145 }