comparison layer/PaintAssistant.cpp @ 1374:631897ba9fca zoom

Merge from default branch
author Chris Cannam
date Tue, 06 Nov 2018 08:59:03 +0000
parents cca66ce390e0
children 28075cc658c9
comparison
equal deleted inserted replaced
1360:e848ea0850fe 1374:631897ba9fca
240 std::cerr << "ERROR: PaintAssistant::drawVisibleText: Boxed style not yet implemented!" << std::endl; 240 std::cerr << "ERROR: PaintAssistant::drawVisibleText: Boxed style not yet implemented!" << std::endl;
241 } 241 }
242 } 242 }
243 243
244 double 244 double
245 PaintAssistant::scalePenWidth(double width) 245 PaintAssistant::scaleSize(double size)
246 { 246 {
247 static double ratio = 0.0; 247 static double ratio = 0.0;
248 if (ratio == 0.0) { 248 if (ratio == 0.0) {
249 double baseEm; 249 double baseEm;
250 #ifdef Q_OS_MAC 250 #ifdef Q_OS_MAC
253 baseEm = 15.0; 253 baseEm = 15.0;
254 #endif 254 #endif
255 double em = QFontMetrics(QFont()).height(); 255 double em = QFontMetrics(QFont()).height();
256 ratio = em / baseEm; 256 ratio = em / baseEm;
257 257
258 SVDEBUG << "PaintAssistant::scalePenWidth: ratio is " << ratio 258 SVDEBUG << "PaintAssistant::scaleSize: ratio is " << ratio
259 << " (em = " << em << ")" << endl; 259 << " (em = " << em << ")" << endl;
260 } 260
261 261 if (ratio < 1.0) {
262 if (ratio <= 1.0) { 262 SVDEBUG << "PaintAssistant::scaleSize: rounding ratio up to 1.0"
263 // we only ever scale up in this method 263 << endl;
264 return width; 264 ratio = 1.0;
265 } 265 }
266 266 }
267
268 return size * ratio;
269 }
270
271 double
272 PaintAssistant::scalePenWidth(double width)
273 {
267 if (width <= 0) { 274 if (width <= 0) {
268 // zero-width pen, produce a scaled one-pixel pen 275 // zero-width pen, produce a scaled one-pixel pen
269 return ratio; 276 width = 1;
270 } 277 }
271 278
272 return width * ratio; 279 return scaleSize(width);
273 } 280 }
274 281
275 QPen 282 QPen
276 PaintAssistant::scalePen(QPen pen) 283 PaintAssistant::scalePen(QPen pen)
277 { 284 {