Mercurial > hg > svgui
comparison view/Pane.cpp @ 682:1a0dfcbffaf1
Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 14:06:40 +0000 |
parents | 7cb6112c59ca |
children | 692a8b9804fe |
comparison
equal
deleted
inserted
replaced
681:eaf4446a1bef | 682:1a0dfcbffaf1 |
---|---|
51 | 51 |
52 #include "widgets/KeyReference.h" //!!! should probably split KeyReference into a data class in base and another that shows the widget | 52 #include "widgets/KeyReference.h" //!!! should probably split KeyReference into a data class in base and another that shows the widget |
53 | 53 |
54 //#define DEBUG_PANE | 54 //#define DEBUG_PANE |
55 | 55 |
56 using std::cerr; | 56 |
57 using std::endl; | 57 |
58 | 58 |
59 QCursor *Pane::m_measureCursor1 = 0; | 59 QCursor *Pane::m_measureCursor1 = 0; |
60 QCursor *Pane::m_measureCursor2 = 0; | 60 QCursor *Pane::m_measureCursor2 = 0; |
61 | 61 |
62 Pane::Pane(QWidget *w) : | 62 Pane::Pane(QWidget *w) : |
108 if (newLevel == 131072) break; //!!! just because | 108 if (newLevel == 131072) break; //!!! just because |
109 level = newLevel; | 109 level = newLevel; |
110 ++count; | 110 ++count; |
111 } | 111 } |
112 | 112 |
113 std::cerr << "Have " << count+1 << " zoom levels" << std::endl; | 113 cerr << "Have " << count+1 << " zoom levels" << endl; |
114 */ | 114 */ |
115 | 115 |
116 Layer *layer = 0; | 116 Layer *layer = 0; |
117 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1); | 117 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1); |
118 | 118 |
221 step = 1; | 221 step = 1; |
222 while (pwr > 0) { | 222 while (pwr > 0) { |
223 step *= 2; | 223 step *= 2; |
224 --pwr; | 224 --pwr; |
225 } | 225 } |
226 // std::cerr << level << std::endl; | 226 // cerr << level << endl; |
227 level += step; | 227 level += step; |
228 if (++count == 100 || level > 262144) break; | 228 if (++count == 100 || level > 262144) break; |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 // std::cerr << "Have " << count << " zoom levels" << std::endl; | 232 // cerr << "Have " << count << " zoom levels" << endl; |
233 | 233 |
234 m_hthumb->setMinimumValue(0); | 234 m_hthumb->setMinimumValue(0); |
235 m_hthumb->setMaximumValue(count); | 235 m_hthumb->setMaximumValue(count); |
236 m_hthumb->setValue(count - current); | 236 m_hthumb->setValue(count - current); |
237 | 237 |
238 // std::cerr << "set value to " << count-current << std::endl; | 238 // cerr << "set value to " << count-current << endl; |
239 | 239 |
240 // std::cerr << "default value is " << m_hthumb->getDefaultValue() << std::endl; | 240 // cerr << "default value is " << m_hthumb->getDefaultValue() << endl; |
241 | 241 |
242 if (count != 50 && m_hthumb->getDefaultValue() == 0) { | 242 if (count != 50 && m_hthumb->getDefaultValue() == 0) { |
243 m_hthumb->setDefaultValue(count - current); | 243 m_hthumb->setDefaultValue(count - current); |
244 // std::cerr << "set default value to " << m_hthumb->getDefaultValue() << std::endl; | 244 // cerr << "set default value to " << m_hthumb->getDefaultValue() << endl; |
245 } | 245 } |
246 | 246 |
247 bool haveVThumb = false; | 247 bool haveVThumb = false; |
248 | 248 |
249 if (layer) { | 249 if (layer) { |
259 m_vthumb->setMaximumValue(max); | 259 m_vthumb->setMaximumValue(max); |
260 m_vthumb->setDefaultValue(defaultStep); | 260 m_vthumb->setDefaultValue(defaultStep); |
261 m_vthumb->setValue(layer->getCurrentVerticalZoomStep()); | 261 m_vthumb->setValue(layer->getCurrentVerticalZoomStep()); |
262 m_vthumb->blockSignals(false); | 262 m_vthumb->blockSignals(false); |
263 | 263 |
264 // std::cerr << "Vertical thumbwheel: min 0, max " << max | 264 // cerr << "Vertical thumbwheel: min 0, max " << max |
265 // << ", default " << defaultStep << ", value " | 265 // << ", default " << defaultStep << ", value " |
266 // << m_vthumb->getValue() << std::endl; | 266 // << m_vthumb->getValue() << endl; |
267 | 267 |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 updateVerticalPanner(); | 271 updateVerticalPanner(); |
772 bool down) | 772 bool down) |
773 { | 773 { |
774 const Model *reference = model->getAlignmentReference(); | 774 const Model *reference = model->getAlignmentReference(); |
775 /* | 775 /* |
776 if (!reference) { | 776 if (!reference) { |
777 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: No reference" << std::endl; | 777 cerr << "Pane[" << this << "]::drawAlignmentStatus: No reference" << endl; |
778 } else if (reference == model) { | 778 } else if (reference == model) { |
779 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: This is the reference model" << std::endl; | 779 cerr << "Pane[" << this << "]::drawAlignmentStatus: This is the reference model" << endl; |
780 } else { | 780 } else { |
781 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: This is not the reference" << std::endl; | 781 cerr << "Pane[" << this << "]::drawAlignmentStatus: This is not the reference" << endl; |
782 } | 782 } |
783 */ | 783 */ |
784 QString text; | 784 QString text; |
785 int completion = 100; | 785 int completion = 100; |
786 | 786 |
876 | 876 |
877 QStringList texts; | 877 QStringList texts; |
878 std::vector<QPixmap> pixmaps; | 878 std::vector<QPixmap> pixmaps; |
879 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { | 879 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { |
880 texts.push_back((*i)->getLayerPresentationName()); | 880 texts.push_back((*i)->getLayerPresentationName()); |
881 // std::cerr << "Pane " << this << ": Layer presentation name for " << *i << ": " | 881 // cerr << "Pane " << this << ": Layer presentation name for " << *i << ": " |
882 // << texts[texts.size()-1] << std::endl; | 882 // << texts[texts.size()-1] << endl; |
883 pixmaps.push_back((*i)->getLayerPresentationPixmap | 883 pixmaps.push_back((*i)->getLayerPresentationPixmap |
884 (QSize(fontAscent, fontAscent))); | 884 (QSize(fontAscent, fontAscent))); |
885 } | 885 } |
886 | 886 |
887 int maxTextWidth = width() / 3; | 887 int maxTextWidth = width() / 3; |
894 | 894 |
895 if (r.x() + r.width() >= llx - fontAscent - 3) { | 895 if (r.x() + r.width() >= llx - fontAscent - 3) { |
896 | 896 |
897 for (size_t i = 0; i < texts.size(); ++i) { | 897 for (size_t i = 0; i < texts.size(); ++i) { |
898 | 898 |
899 // std::cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << std::endl; | 899 // cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << endl; |
900 | 900 |
901 if (i + 1 == texts.size()) { | 901 if (i + 1 == texts.size()) { |
902 paint.setPen(getForeground()); | 902 paint.setPen(getForeground()); |
903 } | 903 } |
904 | 904 |
1276 emit contextHelpChanged(""); | 1276 emit contextHelpChanged(""); |
1277 emit rightButtonMenuRequested(mapToGlobal(e->pos())); | 1277 emit rightButtonMenuRequested(mapToGlobal(e->pos())); |
1278 return; | 1278 return; |
1279 } | 1279 } |
1280 | 1280 |
1281 // std::cerr << "mousePressEvent" << std::endl; | 1281 // cerr << "mousePressEvent" << endl; |
1282 | 1282 |
1283 m_clickPos = e->pos(); | 1283 m_clickPos = e->pos(); |
1284 m_mousePos = m_clickPos; | 1284 m_mousePos = m_clickPos; |
1285 m_clickedInRange = true; | 1285 m_clickedInRange = true; |
1286 m_editingSelection = Selection(); | 1286 m_editingSelection = Selection(); |
1396 { | 1396 { |
1397 if (e->buttons() & Qt::RightButton) { | 1397 if (e->buttons() & Qt::RightButton) { |
1398 return; | 1398 return; |
1399 } | 1399 } |
1400 | 1400 |
1401 // std::cerr << "mouseReleaseEvent" << std::endl; | 1401 // cerr << "mouseReleaseEvent" << endl; |
1402 | 1402 |
1403 ViewManager::ToolMode mode = ViewManager::NavigateMode; | 1403 ViewManager::ToolMode mode = ViewManager::NavigateMode; |
1404 if (m_manager) mode = m_manager->getToolMode(); | 1404 if (m_manager) mode = m_manager->getToolMode(); |
1405 | 1405 |
1406 m_releasing = true; | 1406 m_releasing = true; |
1503 { | 1503 { |
1504 if (e->buttons() & Qt::RightButton) { | 1504 if (e->buttons() & Qt::RightButton) { |
1505 return; | 1505 return; |
1506 } | 1506 } |
1507 | 1507 |
1508 // std::cerr << "mouseMoveEvent" << std::endl; | 1508 // cerr << "mouseMoveEvent" << endl; |
1509 | 1509 |
1510 QPoint pos = e->pos(); | 1510 QPoint pos = e->pos(); |
1511 updateContextHelp(&pos); | 1511 updateContextHelp(&pos); |
1512 | 1512 |
1513 if (m_navigating && m_clickedInRange && !m_releasing) { | 1513 if (m_navigating && m_clickedInRange && !m_releasing) { |
1700 if (newStartFrame >= long(getModelsEndFrame())) { | 1700 if (newStartFrame >= long(getModelsEndFrame())) { |
1701 newStartFrame = getModelsEndFrame() - 1; | 1701 newStartFrame = getModelsEndFrame() - 1; |
1702 } | 1702 } |
1703 | 1703 |
1704 float ratio = float(w) / float(width()); | 1704 float ratio = float(w) / float(width()); |
1705 // std::cerr << "ratio: " << ratio << std::endl; | 1705 // cerr << "ratio: " << ratio << endl; |
1706 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio); | 1706 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio); |
1707 if (newZoomLevel < 1) newZoomLevel = 1; | 1707 if (newZoomLevel < 1) newZoomLevel = 1; |
1708 | 1708 |
1709 // std::cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << std::endl; | 1709 // cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; |
1710 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); | 1710 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); |
1711 setStartFrame(newStartFrame); | 1711 setStartFrame(newStartFrame); |
1712 | 1712 |
1713 QString unit; | 1713 QString unit; |
1714 float min, max; | 1714 float min, max; |
1728 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min); | 1728 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min); |
1729 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max); | 1729 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max); |
1730 } | 1730 } |
1731 float rmin = min + ((max - min) * (height() - y1)) / height(); | 1731 float rmin = min + ((max - min) * (height() - y1)) / height(); |
1732 float rmax = min + ((max - min) * (height() - y0)) / height(); | 1732 float rmax = min + ((max - min) * (height() - y0)) / height(); |
1733 std::cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << std::endl; | 1733 cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << endl; |
1734 if (log) { | 1734 if (log) { |
1735 rmin = powf(10, rmin); | 1735 rmin = powf(10, rmin); |
1736 rmax = powf(10, rmax); | 1736 rmax = powf(10, rmax); |
1737 } | 1737 } |
1738 std::cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit << std::endl; | 1738 cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit << endl; |
1739 | 1739 |
1740 layer->setDisplayExtents(rmin, rmax); | 1740 layer->setDisplayExtents(rmin, rmax); |
1741 updateVerticalPanner(); | 1741 updateVerticalPanner(); |
1742 } | 1742 } |
1743 } | 1743 } |
1815 float vmin = 0.f, vmax = 0.f; | 1815 float vmin = 0.f, vmax = 0.f; |
1816 float dmin = 0.f, dmax = 0.f; | 1816 float dmin = 0.f, dmax = 0.f; |
1817 | 1817 |
1818 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1818 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1819 | 1819 |
1820 // std::cerr << "ydiff = " << ydiff << std::endl; | 1820 // cerr << "ydiff = " << ydiff << endl; |
1821 | 1821 |
1822 int ydiff = e->y() - m_clickPos.y(); | 1822 int ydiff = e->y() - m_clickPos.y(); |
1823 float perpix = (dmax - dmin) / height(); | 1823 float perpix = (dmax - dmin) / height(); |
1824 float valdiff = ydiff * perpix; | 1824 float valdiff = ydiff * perpix; |
1825 // std::cerr << "valdiff = " << valdiff << std::endl; | 1825 // cerr << "valdiff = " << valdiff << endl; |
1826 | 1826 |
1827 if (m_dragMode == UnresolvedDrag && ydiff != 0) { | 1827 if (m_dragMode == UnresolvedDrag && ydiff != 0) { |
1828 m_dragMode = VerticalDrag; | 1828 m_dragMode = VerticalDrag; |
1829 } | 1829 } |
1830 | 1830 |
1836 } | 1836 } |
1837 if (newmax > vmax) { | 1837 if (newmax > vmax) { |
1838 newmin -= newmax - vmax; | 1838 newmin -= newmax - vmax; |
1839 newmax -= newmax - vmax; | 1839 newmax -= newmax - vmax; |
1840 } | 1840 } |
1841 // std::cerr << "(" << dmin << ", " << dmax << ") -> (" | 1841 // cerr << "(" << dmin << ", " << dmax << ") -> (" |
1842 // << newmin << ", " << newmax << ") (drag start " << m_dragStartMinValue << ")" << std::endl; | 1842 // << newmin << ", " << newmax << ") (drag start " << m_dragStartMinValue << ")" << endl; |
1843 | 1843 |
1844 setTopLayerDisplayExtents(newmin, newmax); | 1844 setTopLayerDisplayExtents(newmin, newmax); |
1845 updateVerticalPanner(); | 1845 updateVerticalPanner(); |
1846 } | 1846 } |
1847 } | 1847 } |
1920 resolution, Layer::SnapLeft); | 1920 resolution, Layer::SnapLeft); |
1921 layer->snapToFeatureFrame(this, snapFrameRight, | 1921 layer->snapToFeatureFrame(this, snapFrameRight, |
1922 resolution, Layer::SnapRight); | 1922 resolution, Layer::SnapRight); |
1923 } | 1923 } |
1924 | 1924 |
1925 // std::cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << std::endl; | 1925 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; |
1926 | 1926 |
1927 if (snapFrameLeft < 0) snapFrameLeft = 0; | 1927 if (snapFrameLeft < 0) snapFrameLeft = 0; |
1928 if (snapFrameRight < 0) snapFrameRight = 0; | 1928 if (snapFrameRight < 0) snapFrameRight = 0; |
1929 | 1929 |
1930 size_t min, max; | 1930 size_t min, max; |
1983 { | 1983 { |
1984 if (e->buttons() & Qt::RightButton) { | 1984 if (e->buttons() & Qt::RightButton) { |
1985 return; | 1985 return; |
1986 } | 1986 } |
1987 | 1987 |
1988 // std::cerr << "mouseDoubleClickEvent" << std::endl; | 1988 // cerr << "mouseDoubleClickEvent" << endl; |
1989 | 1989 |
1990 m_clickPos = e->pos(); | 1990 m_clickPos = e->pos(); |
1991 m_clickedInRange = true; | 1991 m_clickedInRange = true; |
1992 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); | 1992 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); |
1993 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); | 1993 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); |
2056 } | 2056 } |
2057 | 2057 |
2058 void | 2058 void |
2059 Pane::wheelEvent(QWheelEvent *e) | 2059 Pane::wheelEvent(QWheelEvent *e) |
2060 { | 2060 { |
2061 //std::cerr << "wheelEvent, delta " << e->delta() << std::endl; | 2061 //cerr << "wheelEvent, delta " << e->delta() << endl; |
2062 | 2062 |
2063 int count = e->delta(); | 2063 int count = e->delta(); |
2064 | 2064 |
2065 if (count > 0) { | 2065 if (count > 0) { |
2066 if (count >= 120) count /= 120; | 2066 if (count >= 120) count /= 120; |
2175 step = 1; | 2175 step = 1; |
2176 while (pwr > 0) { | 2176 while (pwr > 0) { |
2177 step *= 2; | 2177 step *= 2; |
2178 --pwr; | 2178 --pwr; |
2179 } | 2179 } |
2180 // std::cerr << level << std::endl; | 2180 // cerr << level << endl; |
2181 level += step; | 2181 level += step; |
2182 if (++count == 100 || level > 262144) break; | 2182 if (++count == 100 || level > 262144) break; |
2183 } | 2183 } |
2184 } | 2184 } |
2185 | 2185 |
2186 // std::cerr << "new level is " << level << std::endl; | 2186 // cerr << "new level is " << level << endl; |
2187 setZoomLevel(level); | 2187 setZoomLevel(level); |
2188 } | 2188 } |
2189 | 2189 |
2190 void | 2190 void |
2191 Pane::verticalThumbwheelMoved(int value) | 2191 Pane::verticalThumbwheelMoved(int value) |
2213 float vmin, vmax, dmin, dmax; | 2213 float vmin, vmax, dmin, dmax; |
2214 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; | 2214 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; |
2215 float y1 = y0 + h; | 2215 float y1 = y0 + h; |
2216 float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); | 2216 float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); |
2217 float newmin = vmin + ((1.0 - y1) * (vmax - vmin)); | 2217 float newmin = vmin + ((1.0 - y1) * (vmax - vmin)); |
2218 // std::cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w | 2218 // cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w |
2219 // << "," << h << ") -> (" << newmin << "," << newmax << ")" << std::endl; | 2219 // << "," << h << ") -> (" << newmin << "," << newmax << ")" << endl; |
2220 setTopLayerDisplayExtents(newmin, newmax); | 2220 setTopLayerDisplayExtents(newmin, newmax); |
2221 } | 2221 } |
2222 | 2222 |
2223 void | 2223 void |
2224 Pane::editVerticalPannerExtents() | 2224 Pane::editVerticalPannerExtents() |
2254 | 2254 |
2255 void | 2255 void |
2256 Pane::dragEnterEvent(QDragEnterEvent *e) | 2256 Pane::dragEnterEvent(QDragEnterEvent *e) |
2257 { | 2257 { |
2258 QStringList formats(e->mimeData()->formats()); | 2258 QStringList formats(e->mimeData()->formats()); |
2259 std::cerr << "dragEnterEvent: format: " | 2259 cerr << "dragEnterEvent: format: " |
2260 << formats.join(",").toStdString() | 2260 << formats.join(",").toStdString() |
2261 << ", possibleActions: " << e->possibleActions() | 2261 << ", possibleActions: " << e->possibleActions() |
2262 << ", proposedAction: " << e->proposedAction() << std::endl; | 2262 << ", proposedAction: " << e->proposedAction() << endl; |
2263 | 2263 |
2264 if (e->mimeData()->hasFormat("text/uri-list") || | 2264 if (e->mimeData()->hasFormat("text/uri-list") || |
2265 e->mimeData()->hasFormat("text/plain")) { | 2265 e->mimeData()->hasFormat("text/plain")) { |
2266 | 2266 |
2267 if (e->proposedAction() & Qt::CopyAction) { | 2267 if (e->proposedAction() & Qt::CopyAction) { |
2274 } | 2274 } |
2275 | 2275 |
2276 void | 2276 void |
2277 Pane::dropEvent(QDropEvent *e) | 2277 Pane::dropEvent(QDropEvent *e) |
2278 { | 2278 { |
2279 std::cerr << "dropEvent: text: \"" << e->mimeData()->text().toStdString() | 2279 cerr << "dropEvent: text: \"" << e->mimeData()->text().toStdString() |
2280 << "\"" << std::endl; | 2280 << "\"" << endl; |
2281 | 2281 |
2282 if (e->mimeData()->hasFormat("text/uri-list") || | 2282 if (e->mimeData()->hasFormat("text/uri-list") || |
2283 e->mimeData()->hasFormat("text/plain")) { | 2283 e->mimeData()->hasFormat("text/plain")) { |
2284 | 2284 |
2285 if (e->proposedAction() & Qt::CopyAction) { | 2285 if (e->proposedAction() & Qt::CopyAction) { |
2439 } | 2439 } |
2440 | 2440 |
2441 void | 2441 void |
2442 Pane::viewZoomLevelChanged(View *v, unsigned long z, bool locked) | 2442 Pane::viewZoomLevelChanged(View *v, unsigned long z, bool locked) |
2443 { | 2443 { |
2444 // std::cerr << "Pane[" << this << "]::zoomLevelChanged (global now " | 2444 // cerr << "Pane[" << this << "]::zoomLevelChanged (global now " |
2445 // << (m_manager ? m_manager->getGlobalZoom() : 0) << ")" << std::endl; | 2445 // << (m_manager ? m_manager->getGlobalZoom() : 0) << ")" << endl; |
2446 | 2446 |
2447 View::viewZoomLevelChanged(v, z, locked); | 2447 View::viewZoomLevelChanged(v, z, locked); |
2448 | 2448 |
2449 if (m_hthumb && !m_hthumb->isVisible()) return; | 2449 if (m_hthumb && !m_hthumb->isVisible()) return; |
2450 | 2450 |