Mercurial > hg > svgui
comparison view/View.cpp @ 1506:60fe0d20df5d
Debug updates
author | Chris Cannam |
---|---|
date | Fri, 13 Sep 2019 17:27:14 +0100 |
parents | d09345e578a7 |
children | 996e971df9e7 |
comparison
equal
deleted
inserted
replaced
1505:1819978526f9 | 1506:60fe0d20df5d |
---|---|
74 m_useAligningProxy(false), | 74 m_useAligningProxy(false), |
75 m_alignmentProgressBar({ {}, nullptr }), | 75 m_alignmentProgressBar({ {}, nullptr }), |
76 m_manager(nullptr), | 76 m_manager(nullptr), |
77 m_propertyContainer(new ViewPropertyContainer(this)) | 77 m_propertyContainer(new ViewPropertyContainer(this)) |
78 { | 78 { |
79 // cerr << "View::View(" << getId() << ")" << endl; | 79 // SVCERR << "View::View[" << getId() << "]" << endl; |
80 } | 80 } |
81 | 81 |
82 View::~View() | 82 View::~View() |
83 { | 83 { |
84 // cerr << "View::~View(" << getId() << ")" << endl; | 84 // SVCERR << "View::~View[" << getId() << "]" << endl; |
85 | 85 |
86 m_deleting = true; | 86 m_deleting = true; |
87 delete m_propertyContainer; | 87 delete m_propertyContainer; |
88 delete m_cache; | 88 delete m_cache; |
89 delete m_buffer; | 89 delete m_buffer; |
330 View::setCentreFrame(sv_frame_t f, bool e) | 330 View::setCentreFrame(sv_frame_t f, bool e) |
331 { | 331 { |
332 bool changeVisible = false; | 332 bool changeVisible = false; |
333 | 333 |
334 #ifdef DEBUG_VIEW | 334 #ifdef DEBUG_VIEW |
335 SVCERR << "View::setCentreFrame: from " << m_centreFrame | 335 SVCERR << "View[" << getId() << "]::setCentreFrame: from " << m_centreFrame |
336 << " to " << f << endl; | 336 << " to " << f << endl; |
337 #endif | 337 #endif |
338 | 338 |
339 if (m_centreFrame != f) { | 339 if (m_centreFrame != f) { |
340 | 340 |
342 m_centreFrame = f; | 342 m_centreFrame = f; |
343 | 343 |
344 if (m_zoomLevel.zone == ZoomLevel::PixelsPerFrame) { | 344 if (m_zoomLevel.zone == ZoomLevel::PixelsPerFrame) { |
345 | 345 |
346 #ifdef DEBUG_VIEW | 346 #ifdef DEBUG_VIEW |
347 SVCERR << "View(" << getId() << ")::setCentreFrame: in PixelsPerFrame zone, so change must be visible" << endl; | 347 SVCERR << "View[" << getId() << "]::setCentreFrame: in PixelsPerFrame zone, so change must be visible" << endl; |
348 #endif | 348 #endif |
349 update(); | 349 update(); |
350 changeVisible = true; | 350 changeVisible = true; |
351 | 351 |
352 } else { | 352 } else { |
355 int newPixel = int(m_centreFrame / m_zoomLevel.level); | 355 int newPixel = int(m_centreFrame / m_zoomLevel.level); |
356 | 356 |
357 if (newPixel != formerPixel) { | 357 if (newPixel != formerPixel) { |
358 | 358 |
359 #ifdef DEBUG_VIEW | 359 #ifdef DEBUG_VIEW |
360 SVCERR << "View(" << getId() << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; | 360 SVCERR << "View[" << getId() << "]::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; |
361 #endif | 361 #endif |
362 // ensure the centre frame is a multiple of the zoom level | 362 // ensure the centre frame is a multiple of the zoom level |
363 m_centreFrame = sv_frame_t(newPixel) * m_zoomLevel.level; | 363 m_centreFrame = sv_frame_t(newPixel) * m_zoomLevel.level; |
364 | 364 |
365 #ifdef DEBUG_VIEW | 365 #ifdef DEBUG_VIEW |
366 SVCERR << "View(" << this | 366 SVCERR << "View[" << getId() |
367 << ")::setCentreFrame: centre frame rounded to " | 367 << "]::setCentreFrame: centre frame rounded to " |
368 << m_centreFrame << " (zoom level is " | 368 << m_centreFrame << " (zoom level is " |
369 << m_zoomLevel.level << ")" << endl; | 369 << m_zoomLevel.level << ")" << endl; |
370 #endif | 370 #endif |
371 | 371 |
372 update(); | 372 update(); |
375 } | 375 } |
376 | 376 |
377 if (e) { | 377 if (e) { |
378 sv_frame_t rf = alignToReference(m_centreFrame); | 378 sv_frame_t rf = alignToReference(m_centreFrame); |
379 #ifdef DEBUG_VIEW | 379 #ifdef DEBUG_VIEW |
380 cerr << "View[" << getId() << "]::setCentreFrame(" << f | 380 SVCERR << "View[" << getId() << "]::setCentreFrame(" << f |
381 << "): m_centreFrame = " << m_centreFrame | 381 << "): m_centreFrame = " << m_centreFrame |
382 << ", emitting centreFrameChanged with aligned frame " | 382 << ", emitting centreFrameChanged with aligned frame " |
383 << rf << endl; | 383 << rf << endl; |
384 #endif | 384 #endif |
385 emit centreFrameChanged(rf, m_followPan, m_followPlay); | 385 emit centreFrameChanged(rf, m_followPan, m_followPlay); |
925 | 925 |
926 void | 926 void |
927 View::modelChanged(ModelId modelId) | 927 View::modelChanged(ModelId modelId) |
928 { | 928 { |
929 #if defined(DEBUG_VIEW_WIDGET_PAINT) || defined(DEBUG_PROGRESS_STUFF) | 929 #if defined(DEBUG_VIEW_WIDGET_PAINT) || defined(DEBUG_PROGRESS_STUFF) |
930 cerr << "View[" << getId() << "]::modelChanged(" << modelId << ")" << endl; | 930 SVCERR << "View[" << getId() << "]::modelChanged(" << modelId << ")" << endl; |
931 #endif | 931 #endif |
932 | 932 |
933 // If the model that has changed is not used by any of the cached | 933 // If the model that has changed is not used by any of the cached |
934 // layers, we won't need to recreate the cache | 934 // layers, we won't need to recreate the cache |
935 | 935 |
962 { | 962 { |
963 sv_frame_t myStartFrame = getStartFrame(); | 963 sv_frame_t myStartFrame = getStartFrame(); |
964 sv_frame_t myEndFrame = getEndFrame(); | 964 sv_frame_t myEndFrame = getEndFrame(); |
965 | 965 |
966 #ifdef DEBUG_VIEW_WIDGET_PAINT | 966 #ifdef DEBUG_VIEW_WIDGET_PAINT |
967 cerr << "View(" << getId() << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl; | 967 SVCERR << "View[" << getId() << "]::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl; |
968 #endif | 968 #endif |
969 | 969 |
970 if (myStartFrame > 0 && endFrame < myStartFrame) { | 970 if (myStartFrame > 0 && endFrame < myStartFrame) { |
971 checkProgress(modelId); | 971 checkProgress(modelId); |
972 return; | 972 return; |
1005 | 1005 |
1006 void | 1006 void |
1007 View::modelCompletionChanged(ModelId modelId) | 1007 View::modelCompletionChanged(ModelId modelId) |
1008 { | 1008 { |
1009 #ifdef DEBUG_PROGRESS_STUFF | 1009 #ifdef DEBUG_PROGRESS_STUFF |
1010 cerr << "View[" << getId() << "]::modelCompletionChanged(" << modelId << ")" << endl; | 1010 SVCERR << "View[" << getId() << "]::modelCompletionChanged(" << modelId << ")" << endl; |
1011 #endif | 1011 #endif |
1012 checkProgress(modelId); | 1012 checkProgress(modelId); |
1013 } | 1013 } |
1014 | 1014 |
1015 void | 1015 void |
1016 View::modelAlignmentCompletionChanged(ModelId modelId) | 1016 View::modelAlignmentCompletionChanged(ModelId modelId) |
1017 { | 1017 { |
1018 #ifdef DEBUG_PROGRESS_STUFF | 1018 #ifdef DEBUG_PROGRESS_STUFF |
1019 cerr << "View[" << getId() << "]::modelAlignmentCompletionChanged(" << modelId << ")" << endl; | 1019 SVCERR << "View[" << getId() << "]::modelAlignmentCompletionChanged(" << modelId << ")" << endl; |
1020 #endif | 1020 #endif |
1021 checkAlignmentProgress(modelId); | 1021 checkAlignmentProgress(modelId); |
1022 } | 1022 } |
1023 | 1023 |
1024 void | 1024 void |
1025 View::modelReplaced() | 1025 View::modelReplaced() |
1026 { | 1026 { |
1027 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1027 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1028 cerr << "View(" << getId() << ")::modelReplaced()" << endl; | 1028 SVCERR << "View[" << getId() << "]::modelReplaced()" << endl; |
1029 #endif | 1029 #endif |
1030 m_cacheValid = false; | 1030 m_cacheValid = false; |
1031 update(); | 1031 update(); |
1032 } | 1032 } |
1033 | 1033 |
1073 View::globalCentreFrameChanged(sv_frame_t rf) | 1073 View::globalCentreFrameChanged(sv_frame_t rf) |
1074 { | 1074 { |
1075 if (m_followPan) { | 1075 if (m_followPan) { |
1076 sv_frame_t f = alignFromReference(rf); | 1076 sv_frame_t f = alignFromReference(rf); |
1077 #ifdef DEBUG_VIEW | 1077 #ifdef DEBUG_VIEW |
1078 cerr << "View[" << getId() << "]::globalCentreFrameChanged(" << rf | 1078 SVCERR << "View[" << getId() << "]::globalCentreFrameChanged(" << rf |
1079 << "): setting centre frame to " << f << endl; | 1079 << "): setting centre frame to " << f << endl; |
1080 #endif | 1080 #endif |
1081 setCentreFrame(f, false); | 1081 setCentreFrame(f, false); |
1082 } | 1082 } |
1083 } | 1083 } |
1094 if (m_manager) { | 1094 if (m_manager) { |
1095 if (sender() != m_manager) return; | 1095 if (sender() != m_manager) return; |
1096 } | 1096 } |
1097 | 1097 |
1098 #ifdef DEBUG_VIEW | 1098 #ifdef DEBUG_VIEW |
1099 cerr << "View::viewManagerPlaybackFrameChanged(" << f << ")" << endl; | 1099 SVCERR << "View[" << getId() << "]::viewManagerPlaybackFrameChanged(" << f << ")" << endl; |
1100 #endif | 1100 #endif |
1101 | 1101 |
1102 f = getAlignedPlaybackFrame(); | 1102 f = getAlignedPlaybackFrame(); |
1103 | 1103 |
1104 #ifdef DEBUG_VIEW | 1104 #ifdef DEBUG_VIEW |
1105 cerr << " -> aligned frame = " << f << endl; | 1105 SVCERR << " -> aligned frame = " << f << endl; |
1106 #endif | 1106 #endif |
1107 | 1107 |
1108 movePlayPointer(f); | 1108 movePlayPointer(f); |
1109 } | 1109 } |
1110 | 1110 |
1111 void | 1111 void |
1112 View::movePlayPointer(sv_frame_t newFrame) | 1112 View::movePlayPointer(sv_frame_t newFrame) |
1113 { | 1113 { |
1114 #ifdef DEBUG_VIEW | 1114 #ifdef DEBUG_VIEW |
1115 cerr << "View(" << getId() << ")::movePlayPointer(" << newFrame << ")" << endl; | 1115 SVCERR << "View[" << getId() << "]::movePlayPointer(" << newFrame << ")" << endl; |
1116 #endif | 1116 #endif |
1117 | 1117 |
1118 if (m_playPointerFrame == newFrame) return; | 1118 if (m_playPointerFrame == newFrame) return; |
1119 bool visibleChange = | 1119 bool visibleChange = |
1120 (getXForFrame(m_playPointerFrame) != getXForFrame(newFrame)); | 1120 (getXForFrame(m_playPointerFrame) != getXForFrame(newFrame)); |
1121 | |
1122 #ifdef DEBUG_VIEW_WIDGET_PAINT | |
1123 SVCERR << "View[" << getId() << "]::movePlayPointer: moving from " | |
1124 << m_playPointerFrame << " to " << newFrame << ", visible = " | |
1125 << visibleChange << endl; | |
1126 #endif | |
1127 | |
1121 sv_frame_t oldPlayPointerFrame = m_playPointerFrame; | 1128 sv_frame_t oldPlayPointerFrame = m_playPointerFrame; |
1122 m_playPointerFrame = newFrame; | 1129 m_playPointerFrame = newFrame; |
1123 if (!visibleChange) return; | 1130 if (!visibleChange) return; |
1124 | 1131 |
1125 bool somethingGoingOn = | 1132 bool somethingGoingOn = |
1174 } | 1181 } |
1175 } | 1182 } |
1176 } | 1183 } |
1177 | 1184 |
1178 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1185 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1179 cerr << "PlaybackScrollPage: f = " << m_playPointerFrame << ", sf = " << sf << ", start frame " | 1186 SVCERR << "PlaybackScrollPage: f = " << m_playPointerFrame << ", sf = " << sf << ", start frame " |
1180 << getStartFrame() << endl; | 1187 << getStartFrame() << endl; |
1181 #endif | 1188 #endif |
1182 | 1189 |
1183 // We don't consider scrolling unless the pointer is outside | 1190 // We don't consider scrolling unless the pointer is outside |
1184 // the central visible range already | 1191 // the central visible range already |
1185 | 1192 |
1186 int xnew = getXForFrame(m_playPointerFrame); | 1193 int xnew = getXForFrame(m_playPointerFrame); |
1187 | 1194 |
1188 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1195 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1189 cerr << "xnew = " << xnew << ", width = " << width() << endl; | 1196 SVCERR << "xnew = " << xnew << ", width = " << width() << endl; |
1190 #endif | 1197 #endif |
1191 | 1198 |
1192 bool shouldScroll = (xnew > (width() * 7) / 8); | 1199 bool shouldScroll = (xnew > (width() * 7) / 8); |
1193 | 1200 |
1194 if (!m_followPlayIsDetached && (xnew < width() / 8)) { | 1201 if (!m_followPlayIsDetached && (xnew < width() / 8)) { |
1226 | 1233 |
1227 void | 1234 void |
1228 View::viewZoomLevelChanged(View *p, ZoomLevel z, bool locked) | 1235 View::viewZoomLevelChanged(View *p, ZoomLevel z, bool locked) |
1229 { | 1236 { |
1230 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1237 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1231 cerr << "View[" << getId() << "]: viewZoomLevelChanged(" << p << ", " << z << ", " << locked << ")" << endl; | 1238 SVCERR << "View[" << getId() << "]: viewZoomLevelChanged(" << p << ", " << z << ", " << locked << ")" << endl; |
1232 #endif | 1239 #endif |
1233 if (m_followZoom && p != this && locked) { | 1240 if (m_followZoom && p != this && locked) { |
1234 setZoomLevel(z); | 1241 setZoomLevel(z); |
1235 } | 1242 } |
1236 } | 1243 } |
1463 LayerList scrollables; | 1470 LayerList scrollables; |
1464 bool metUnscrollable = false; | 1471 bool metUnscrollable = false; |
1465 | 1472 |
1466 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1473 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1467 // SVDEBUG << "View::getScrollableBackLayers: calling isLayerDormant on layer " << *i << endl; | 1474 // SVDEBUG << "View::getScrollableBackLayers: calling isLayerDormant on layer " << *i << endl; |
1468 // cerr << "(name is " << (*i)->objectName() << ")" | 1475 // SVCERR << "(name is " << (*i)->objectName() << ")" |
1469 // << endl; | 1476 // << endl; |
1470 // SVDEBUG << "View::getScrollableBackLayers: I am " << getId() << endl; | 1477 // SVDEBUG << "View::getScrollableBackLayers: I am " << getId() << endl; |
1471 if ((*i)->isLayerDormant(this)) continue; | 1478 if ((*i)->isLayerDormant(this)) continue; |
1472 if ((*i)->isLayerOpaque()) { | 1479 if ((*i)->isLayerOpaque()) { |
1473 // You can't see anything behind an opaque layer! | 1480 // You can't see anything behind an opaque layer! |
1563 break; | 1570 break; |
1564 } | 1571 } |
1565 level = getZoomConstraintLevel | 1572 level = getZoomConstraintLevel |
1566 (level.incremented(), ZoomConstraint::RoundUp); | 1573 (level.incremented(), ZoomConstraint::RoundUp); |
1567 } | 1574 } |
1568 // cerr << "View::countZoomLevels: " << n << endl; | 1575 // SVCERR << "View::countZoomLevels: " << n << endl; |
1569 return n; | 1576 return n; |
1570 } | 1577 } |
1571 | 1578 |
1572 ZoomLevel | 1579 ZoomLevel |
1573 View::getZoomLevelByIndex(int ix) const | 1580 View::getZoomLevelByIndex(int ix) const |
1576 ZoomLevel min = ZoomConstraint().getMinZoomLevel(); | 1583 ZoomLevel min = ZoomConstraint().getMinZoomLevel(); |
1577 ZoomLevel max = ZoomConstraint().getMaxZoomLevel(); | 1584 ZoomLevel max = ZoomConstraint().getMaxZoomLevel(); |
1578 ZoomLevel level = min; | 1585 ZoomLevel level = min; |
1579 while (true) { | 1586 while (true) { |
1580 if (n == ix) { | 1587 if (n == ix) { |
1581 // cerr << "View::getZoomLevelByIndex: " << ix << " -> " << level | 1588 // SVCERR << "View::getZoomLevelByIndex: " << ix << " -> " << level |
1582 // << endl; | 1589 // << endl; |
1583 return level; | 1590 return level; |
1584 } | 1591 } |
1585 ++n; | 1592 ++n; |
1586 if (level == max) { | 1593 if (level == max) { |
1587 break; | 1594 break; |
1588 } | 1595 } |
1589 level = getZoomConstraintLevel | 1596 level = getZoomConstraintLevel |
1590 (level.incremented(), ZoomConstraint::RoundUp); | 1597 (level.incremented(), ZoomConstraint::RoundUp); |
1591 } | 1598 } |
1592 // cerr << "View::getZoomLevelByIndex: " << ix << " -> " << max << " (max)" | 1599 // SVCERR << "View::getZoomLevelByIndex: " << ix << " -> " << max << " (max)" |
1593 // << endl; | 1600 // << endl; |
1594 return max; | 1601 return max; |
1595 } | 1602 } |
1596 | 1603 |
1597 int | 1604 int |
1601 ZoomLevel min = ZoomConstraint().getMinZoomLevel(); | 1608 ZoomLevel min = ZoomConstraint().getMinZoomLevel(); |
1602 ZoomLevel max = ZoomConstraint().getMaxZoomLevel(); | 1609 ZoomLevel max = ZoomConstraint().getMaxZoomLevel(); |
1603 ZoomLevel level = min; | 1610 ZoomLevel level = min; |
1604 while (true) { | 1611 while (true) { |
1605 if (z == level) { | 1612 if (z == level) { |
1606 // cerr << "View::getZoomLevelIndex: " << z << " -> " << n | 1613 // SVCERR << "View::getZoomLevelIndex: " << z << " -> " << n |
1607 // << endl; | 1614 // << endl; |
1608 return n; | 1615 return n; |
1609 } | 1616 } |
1610 ++n; | 1617 ++n; |
1611 if (level == max) { | 1618 if (level == max) { |
1612 break; | 1619 break; |
1613 } | 1620 } |
1614 level = getZoomConstraintLevel | 1621 level = getZoomConstraintLevel |
1615 (level.incremented(), ZoomConstraint::RoundUp); | 1622 (level.incremented(), ZoomConstraint::RoundUp); |
1616 } | 1623 } |
1617 // cerr << "View::getZoomLevelIndex: " << z << " -> " << n << " (max)" | 1624 // SVCERR << "View::getZoomLevelIndex: " << z << " -> " << n << " (max)" |
1618 // << endl; | 1625 // << endl; |
1619 return n; | 1626 return n; |
1620 } | 1627 } |
1621 | 1628 |
1622 double | 1629 double |
2028 | 2035 |
2029 void | 2036 void |
2030 View::paintEvent(QPaintEvent *e) | 2037 View::paintEvent(QPaintEvent *e) |
2031 { | 2038 { |
2032 // Profiler prof("View::paintEvent", false); | 2039 // Profiler prof("View::paintEvent", false); |
2033 // cerr << "View::paintEvent: centre frame is " << m_centreFrame << endl; | 2040 |
2041 #ifdef DEBUG_VIEW_WIDGET_PAINT | |
2042 { | |
2043 sv_frame_t startFrame = getStartFrame(); | |
2044 SVCERR << "View[" << getId() << "]::paintEvent: centre frame is " << m_centreFrame << " (start frame " << startFrame << ", height " << height() << ")" << endl; | |
2045 } | |
2046 #endif | |
2034 | 2047 |
2035 if (m_layerStack.empty()) { | 2048 if (m_layerStack.empty()) { |
2036 QFrame::paintEvent(e); | 2049 QFrame::paintEvent(e); |
2037 return; | 2050 return; |
2038 } | 2051 } |
2094 bool layersChanged = false; | 2107 bool layersChanged = false; |
2095 LayerList scrollables = getScrollableBackLayers(true, layersChanged); | 2108 LayerList scrollables = getScrollableBackLayers(true, layersChanged); |
2096 LayerList nonScrollables = getNonScrollableFrontLayers(true, layersChanged); | 2109 LayerList nonScrollables = getNonScrollableFrontLayers(true, layersChanged); |
2097 | 2110 |
2098 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2111 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2099 cerr << "View(" << getId() << ")::paintEvent: have " << scrollables.size() | 2112 SVCERR << "View[" << getId() << "]::paintEvent: have " << scrollables.size() |
2100 << " scrollable back layers and " << nonScrollables.size() | 2113 << " scrollable back layers and " << nonScrollables.size() |
2101 << " non-scrollable front layers" << endl; | 2114 << " non-scrollable front layers" << endl; |
2102 #endif | 2115 #endif |
2103 | 2116 |
2104 if (layersChanged || scrollables.empty()) { | 2117 if (layersChanged || scrollables.empty()) { |
2124 shouldUseCache = true; | 2137 shouldUseCache = true; |
2125 shouldRepaintCache = true; | 2138 shouldRepaintCache = true; |
2126 cacheAreaToRepaint = wholeArea; | 2139 cacheAreaToRepaint = wholeArea; |
2127 | 2140 |
2128 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2141 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2129 cerr << "View(" << getId() << "): cache " << m_cache << ", cache zoom " | 2142 SVCERR << "View[" << getId() << "]: cache " << m_cache << ", cache zoom " |
2130 << m_cacheZoomLevel << ", zoom " << m_zoomLevel << endl; | 2143 << m_cacheZoomLevel << ", zoom " << m_zoomLevel << endl; |
2131 #endif | 2144 #endif |
2132 | 2145 |
2133 using namespace std::rel_ops; | 2146 using namespace std::rel_ops; |
2134 | 2147 |
2144 m_cacheValid = false; | 2157 m_cacheValid = false; |
2145 shouldUseCache = false; | 2158 shouldUseCache = false; |
2146 shouldRepaintCache = false; | 2159 shouldRepaintCache = false; |
2147 | 2160 |
2148 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2161 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2149 cerr << "View(" << getId() << ")::paintEvent: cache is invalid but only small area requested, will repaint directly instead" << endl; | 2162 SVCERR << "View[" << getId() << "]::paintEvent: cache is invalid but only small area requested, will repaint directly instead" << endl; |
2150 #endif | 2163 #endif |
2151 } else { | 2164 } else { |
2152 | 2165 |
2153 if (!m_cache || | 2166 if (!m_cache || |
2154 m_cache->size() != wholeSize) { | 2167 m_cache->size() != wholeSize) { |
2155 delete m_cache; | 2168 delete m_cache; |
2156 m_cache = new QPixmap(wholeSize); | 2169 m_cache = new QPixmap(wholeSize); |
2157 } | 2170 } |
2158 | 2171 |
2159 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2172 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2160 cerr << "View(" << getId() << ")::paintEvent: cache is invalid, will repaint whole" << endl; | 2173 SVCERR << "View[" << getId() << "]::paintEvent: cache is invalid, will repaint whole" << endl; |
2161 #endif | 2174 #endif |
2162 } | 2175 } |
2163 | 2176 |
2164 count.miss(); | 2177 count.miss(); |
2165 | 2178 |
2166 } else if (m_cacheCentreFrame != m_centreFrame) { | 2179 } else if (m_cacheCentreFrame != m_centreFrame) { |
2180 | |
2181 #ifdef DEBUG_VIEW_WIDGET_PAINT | |
2182 SVCERR << "View[" << getId() << "]::paintEvent: cache centre frame is " << m_cacheCentreFrame << endl; | |
2183 #endif | |
2167 | 2184 |
2168 int dx = dpratio * (getXForFrame(m_cacheCentreFrame) - | 2185 int dx = dpratio * (getXForFrame(m_cacheCentreFrame) - |
2169 getXForFrame(m_centreFrame)); | 2186 getXForFrame(m_centreFrame)); |
2170 | 2187 |
2171 if (dx > -m_cache->width() && dx < m_cache->width()) { | 2188 if (dx > -m_cache->width() && dx < m_cache->width()) { |
2181 } | 2198 } |
2182 | 2199 |
2183 count.partial(); | 2200 count.partial(); |
2184 | 2201 |
2185 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2202 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2186 cerr << "View(" << getId() << ")::paintEvent: scrolled cache by " << dx << endl; | 2203 SVCERR << "View[" << getId() << "]::paintEvent: scrolled cache by " << dx << endl; |
2187 #endif | 2204 #endif |
2188 } else { | 2205 } else { |
2189 count.miss(); | 2206 count.miss(); |
2190 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2207 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2191 cerr << "View(" << getId() << ")::paintEvent: scrolling too far" << endl; | 2208 SVCERR << "View[" << getId() << "]::paintEvent: scrolling too far" << endl; |
2192 #endif | 2209 #endif |
2193 } | 2210 } |
2194 | 2211 |
2195 } else { | 2212 } else { |
2196 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2213 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2197 cerr << "View(" << getId() << ")::paintEvent: cache is good" << endl; | 2214 SVCERR << "View[" << getId() << "]::paintEvent: cache is good" << endl; |
2198 #endif | 2215 #endif |
2199 count.hit(); | 2216 count.hit(); |
2200 shouldRepaintCache = false; | 2217 shouldRepaintCache = false; |
2201 } | 2218 } |
2202 } | 2219 } |
2203 | 2220 |
2204 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2221 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2205 cerr << "View(" << getId() << ")::paintEvent: m_cacheValid = " << m_cacheValid << ", shouldUseCache = " << shouldUseCache << ", shouldRepaintCache = " << shouldRepaintCache << ", cacheAreaToRepaint = " << cacheAreaToRepaint.x() << "," << cacheAreaToRepaint.y() << " " << cacheAreaToRepaint.width() << "x" << cacheAreaToRepaint.height() << endl; | 2222 SVCERR << "View[" << getId() << "]::paintEvent: m_cacheValid = " << m_cacheValid << ", shouldUseCache = " << shouldUseCache << ", shouldRepaintCache = " << shouldRepaintCache << ", cacheAreaToRepaint = " << cacheAreaToRepaint.x() << "," << cacheAreaToRepaint.y() << " " << cacheAreaToRepaint.width() << "x" << cacheAreaToRepaint.height() << endl; |
2206 #endif | 2223 #endif |
2207 | 2224 |
2208 if (shouldRepaintCache && !shouldUseCache) { | 2225 if (shouldRepaintCache && !shouldUseCache) { |
2209 // If we are repainting the cache, then we paint the | 2226 // If we are repainting the cache, then we paint the |
2210 // scrollables only to the cache, not to the buffer. So if | 2227 // scrollables only to the cache, not to the buffer. So if |
2279 useAligningProxy = true; | 2296 useAligningProxy = true; |
2280 } | 2297 } |
2281 } | 2298 } |
2282 | 2299 |
2283 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2300 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2284 cerr << "Painting scrollable layer " << layer << " (model " << layer->getModel() << ", source model " << layer->getSourceModel() << ") with shouldRepaintCache = " << shouldRepaintCache << ", useAligningProxy = " << useAligningProxy << ", dpratio = " << dpratio << ", areaToPaint = " << areaToPaint.x() << "," << areaToPaint.y() << " " << areaToPaint.width() << "x" << areaToPaint.height() << endl; | 2301 SVCERR << "Painting scrollable layer " << layer << " (model " << layer->getModel() << ", source model " << layer->getSourceModel() << ") with shouldRepaintCache = " << shouldRepaintCache << ", useAligningProxy = " << useAligningProxy << ", dpratio = " << dpratio << ", areaToPaint = " << areaToPaint.x() << "," << areaToPaint.y() << " " << areaToPaint.width() << "x" << areaToPaint.height() << endl; |
2285 #endif | 2302 #endif |
2286 | 2303 |
2287 layer->paint(useAligningProxy ? &aligningProxy : &proxy, | 2304 layer->paint(useAligningProxy ? &aligningProxy : &proxy, |
2288 paint, areaToPaint); | 2305 paint, areaToPaint); |
2289 | 2306 |
2331 useAligningProxy = true; | 2348 useAligningProxy = true; |
2332 } | 2349 } |
2333 } | 2350 } |
2334 | 2351 |
2335 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2352 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2336 cerr << "Painting non-scrollable layer " << layer << " (model " << layer->getModel() << ", source model " << layer->getSourceModel() << ") with shouldRepaintCache = " << shouldRepaintCache << ", useAligningProxy = " << useAligningProxy << ", dpratio = " << dpratio << ", requestedPaintArea = " << requestedPaintArea.x() << "," << requestedPaintArea.y() << " " << requestedPaintArea.width() << "x" << requestedPaintArea.height() << endl; | 2353 SVCERR << "Painting non-scrollable layer " << layer << " (model " << layer->getModel() << ", source model " << layer->getSourceModel() << ") with shouldRepaintCache = " << shouldRepaintCache << ", useAligningProxy = " << useAligningProxy << ", dpratio = " << dpratio << ", requestedPaintArea = " << requestedPaintArea.x() << "," << requestedPaintArea.y() << " " << requestedPaintArea.width() << "x" << requestedPaintArea.height() << endl; |
2337 #endif | 2354 #endif |
2338 | 2355 |
2339 layer->paint(useAligningProxy ? &aligningProxy : &proxy, | 2356 layer->paint(useAligningProxy ? &aligningProxy : &proxy, |
2340 paint, requestedPaintArea); | 2357 paint, requestedPaintArea); |
2341 } | 2358 } |
2882 paint.setRenderHint(QPainter::Antialiasing, false); | 2899 paint.setRenderHint(QPainter::Antialiasing, false); |
2883 | 2900 |
2884 paint.save(); | 2901 paint.save(); |
2885 paint.translate(xorigin + x, 0); | 2902 paint.translate(xorigin + x, 0); |
2886 | 2903 |
2887 cerr << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() + x + xorigin << ", " << chunk.width() << endl; | 2904 SVCERR << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() + x + xorigin << ", " << chunk.width() << endl; |
2888 | 2905 |
2889 (*i)->setSynchronousPainting(true); | 2906 (*i)->setSynchronousPainting(true); |
2890 | 2907 |
2891 (*i)->paint(this, paint, chunk); | 2908 (*i)->paint(this, paint, chunk); |
2892 | 2909 |
3023 } | 3040 } |
3024 | 3041 |
3025 ViewPropertyContainer::ViewPropertyContainer(View *v) : | 3042 ViewPropertyContainer::ViewPropertyContainer(View *v) : |
3026 m_v(v) | 3043 m_v(v) |
3027 { | 3044 { |
3028 // cerr << "ViewPropertyContainer: " << getId() << " is owned by View " << v << endl; | 3045 // SVCERR << "ViewPropertyContainer: " << getId() << " is owned by View " << v << endl; |
3029 connect(m_v, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), | 3046 connect(m_v, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), |
3030 this, SIGNAL(propertyChanged(PropertyContainer::PropertyName))); | 3047 this, SIGNAL(propertyChanged(PropertyContainer::PropertyName))); |
3031 } | 3048 } |
3032 | 3049 |
3033 ViewPropertyContainer::~ViewPropertyContainer() | 3050 ViewPropertyContainer::~ViewPropertyContainer() |