Mercurial > hg > svgui
comparison view/Pane.cpp @ 706:97ea68f62c1f imaf_enc
Merge from default branch
author | Chris Cannam |
---|---|
date | Thu, 05 Dec 2013 09:47:02 +0000 |
parents | 26c5f7fd4807 692a8b9804fe |
children | c02c51ae5238 |
comparison
equal
deleted
inserted
replaced
678:26c5f7fd4807 | 706:97ea68f62c1f |
---|---|
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; |
1504 { | 1504 { |
1505 if (e->buttons() & Qt::RightButton) { | 1505 if (e->buttons() & Qt::RightButton) { |
1506 return; | 1506 return; |
1507 } | 1507 } |
1508 | 1508 |
1509 // std::cerr << "mouseMoveEvent" << std::endl; | 1509 // cerr << "mouseMoveEvent" << endl; |
1510 | 1510 |
1511 QPoint pos = e->pos(); | 1511 QPoint pos = e->pos(); |
1512 updateContextHelp(&pos); | 1512 updateContextHelp(&pos); |
1513 | 1513 |
1514 if (m_navigating && m_clickedInRange && !m_releasing) { | 1514 if (m_navigating && m_clickedInRange && !m_releasing) { |
1701 if (newStartFrame >= long(getModelsEndFrame())) { | 1701 if (newStartFrame >= long(getModelsEndFrame())) { |
1702 newStartFrame = getModelsEndFrame() - 1; | 1702 newStartFrame = getModelsEndFrame() - 1; |
1703 } | 1703 } |
1704 | 1704 |
1705 float ratio = float(w) / float(width()); | 1705 float ratio = float(w) / float(width()); |
1706 // std::cerr << "ratio: " << ratio << std::endl; | 1706 // cerr << "ratio: " << ratio << endl; |
1707 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio); | 1707 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio); |
1708 if (newZoomLevel < 1) newZoomLevel = 1; | 1708 if (newZoomLevel < 1) newZoomLevel = 1; |
1709 | 1709 |
1710 // std::cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << std::endl; | 1710 // cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; |
1711 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); | 1711 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); |
1712 setStartFrame(newStartFrame); | 1712 setStartFrame(newStartFrame); |
1713 | 1713 |
1714 QString unit; | 1714 QString unit; |
1715 float min, max; | 1715 float min, max; |
1729 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min); | 1729 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min); |
1730 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max); | 1730 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max); |
1731 } | 1731 } |
1732 float rmin = min + ((max - min) * (height() - y1)) / height(); | 1732 float rmin = min + ((max - min) * (height() - y1)) / height(); |
1733 float rmax = min + ((max - min) * (height() - y0)) / height(); | 1733 float rmax = min + ((max - min) * (height() - y0)) / height(); |
1734 std::cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << std::endl; | 1734 cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << endl; |
1735 if (log) { | 1735 if (log) { |
1736 rmin = powf(10, rmin); | 1736 rmin = powf(10, rmin); |
1737 rmax = powf(10, rmax); | 1737 rmax = powf(10, rmax); |
1738 } | 1738 } |
1739 std::cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit << std::endl; | 1739 cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit << endl; |
1740 | 1740 |
1741 layer->setDisplayExtents(rmin, rmax); | 1741 layer->setDisplayExtents(rmin, rmax); |
1742 updateVerticalPanner(); | 1742 updateVerticalPanner(); |
1743 } | 1743 } |
1744 } | 1744 } |
1816 float vmin = 0.f, vmax = 0.f; | 1816 float vmin = 0.f, vmax = 0.f; |
1817 float dmin = 0.f, dmax = 0.f; | 1817 float dmin = 0.f, dmax = 0.f; |
1818 | 1818 |
1819 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1819 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1820 | 1820 |
1821 // std::cerr << "ydiff = " << ydiff << std::endl; | 1821 // cerr << "ydiff = " << ydiff << endl; |
1822 | 1822 |
1823 int ydiff = e->y() - m_clickPos.y(); | 1823 int ydiff = e->y() - m_clickPos.y(); |
1824 float perpix = (dmax - dmin) / height(); | 1824 float perpix = (dmax - dmin) / height(); |
1825 float valdiff = ydiff * perpix; | 1825 float valdiff = ydiff * perpix; |
1826 // std::cerr << "valdiff = " << valdiff << std::endl; | 1826 // cerr << "valdiff = " << valdiff << endl; |
1827 | 1827 |
1828 if (m_dragMode == UnresolvedDrag && ydiff != 0) { | 1828 if (m_dragMode == UnresolvedDrag && ydiff != 0) { |
1829 m_dragMode = VerticalDrag; | 1829 m_dragMode = VerticalDrag; |
1830 } | 1830 } |
1831 | 1831 |
1837 } | 1837 } |
1838 if (newmax > vmax) { | 1838 if (newmax > vmax) { |
1839 newmin -= newmax - vmax; | 1839 newmin -= newmax - vmax; |
1840 newmax -= newmax - vmax; | 1840 newmax -= newmax - vmax; |
1841 } | 1841 } |
1842 // std::cerr << "(" << dmin << ", " << dmax << ") -> (" | 1842 // cerr << "(" << dmin << ", " << dmax << ") -> (" |
1843 // << newmin << ", " << newmax << ") (drag start " << m_dragStartMinValue << ")" << std::endl; | 1843 // << newmin << ", " << newmax << ") (drag start " << m_dragStartMinValue << ")" << endl; |
1844 | 1844 |
1845 setTopLayerDisplayExtents(newmin, newmax); | 1845 setTopLayerDisplayExtents(newmin, newmax); |
1846 updateVerticalPanner(); | 1846 updateVerticalPanner(); |
1847 } | 1847 } |
1848 } | 1848 } |
1921 resolution, Layer::SnapLeft); | 1921 resolution, Layer::SnapLeft); |
1922 layer->snapToFeatureFrame(this, snapFrameRight, | 1922 layer->snapToFeatureFrame(this, snapFrameRight, |
1923 resolution, Layer::SnapRight); | 1923 resolution, Layer::SnapRight); |
1924 } | 1924 } |
1925 | 1925 |
1926 // std::cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << std::endl; | 1926 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; |
1927 | 1927 |
1928 if (snapFrameLeft < 0) snapFrameLeft = 0; | 1928 if (snapFrameLeft < 0) snapFrameLeft = 0; |
1929 if (snapFrameRight < 0) snapFrameRight = 0; | 1929 if (snapFrameRight < 0) snapFrameRight = 0; |
1930 | 1930 |
1931 size_t min, max; | 1931 size_t min, max; |
1984 { | 1984 { |
1985 if (e->buttons() & Qt::RightButton) { | 1985 if (e->buttons() & Qt::RightButton) { |
1986 return; | 1986 return; |
1987 } | 1987 } |
1988 | 1988 |
1989 // std::cerr << "mouseDoubleClickEvent" << std::endl; | 1989 // cerr << "mouseDoubleClickEvent" << endl; |
1990 | 1990 |
1991 m_clickPos = e->pos(); | 1991 m_clickPos = e->pos(); |
1992 m_clickedInRange = true; | 1992 m_clickedInRange = true; |
1993 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); | 1993 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier); |
1994 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); | 1994 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier); |
2057 } | 2057 } |
2058 | 2058 |
2059 void | 2059 void |
2060 Pane::wheelEvent(QWheelEvent *e) | 2060 Pane::wheelEvent(QWheelEvent *e) |
2061 { | 2061 { |
2062 //std::cerr << "wheelEvent, delta " << e->delta() << std::endl; | 2062 //cerr << "wheelEvent, delta " << e->delta() << endl; |
2063 | 2063 |
2064 int count = e->delta(); | 2064 int count = e->delta(); |
2065 | 2065 |
2066 if (count > 0) { | 2066 if (count > 0) { |
2067 if (count >= 120) count /= 120; | 2067 if (count >= 120) count /= 120; |
2176 step = 1; | 2176 step = 1; |
2177 while (pwr > 0) { | 2177 while (pwr > 0) { |
2178 step *= 2; | 2178 step *= 2; |
2179 --pwr; | 2179 --pwr; |
2180 } | 2180 } |
2181 // std::cerr << level << std::endl; | 2181 // cerr << level << endl; |
2182 level += step; | 2182 level += step; |
2183 if (++count == 100 || level > 262144) break; | 2183 if (++count == 100 || level > 262144) break; |
2184 } | 2184 } |
2185 } | 2185 } |
2186 | 2186 |
2187 // std::cerr << "new level is " << level << std::endl; | 2187 // cerr << "new level is " << level << endl; |
2188 setZoomLevel(level); | 2188 setZoomLevel(level); |
2189 } | 2189 } |
2190 | 2190 |
2191 void | 2191 void |
2192 Pane::verticalThumbwheelMoved(int value) | 2192 Pane::verticalThumbwheelMoved(int value) |
2214 float vmin, vmax, dmin, dmax; | 2214 float vmin, vmax, dmin, dmax; |
2215 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; | 2215 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; |
2216 float y1 = y0 + h; | 2216 float y1 = y0 + h; |
2217 float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); | 2217 float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); |
2218 float newmin = vmin + ((1.0 - y1) * (vmax - vmin)); | 2218 float newmin = vmin + ((1.0 - y1) * (vmax - vmin)); |
2219 // std::cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w | 2219 // cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w |
2220 // << "," << h << ") -> (" << newmin << "," << newmax << ")" << std::endl; | 2220 // << "," << h << ") -> (" << newmin << "," << newmax << ")" << endl; |
2221 setTopLayerDisplayExtents(newmin, newmax); | 2221 setTopLayerDisplayExtents(newmin, newmax); |
2222 } | 2222 } |
2223 | 2223 |
2224 void | 2224 void |
2225 Pane::editVerticalPannerExtents() | 2225 Pane::editVerticalPannerExtents() |
2255 | 2255 |
2256 void | 2256 void |
2257 Pane::dragEnterEvent(QDragEnterEvent *e) | 2257 Pane::dragEnterEvent(QDragEnterEvent *e) |
2258 { | 2258 { |
2259 QStringList formats(e->mimeData()->formats()); | 2259 QStringList formats(e->mimeData()->formats()); |
2260 std::cerr << "dragEnterEvent: format: " | 2260 cerr << "dragEnterEvent: format: " |
2261 << formats.join(",").toStdString() | 2261 << formats.join(",") |
2262 << ", possibleActions: " << e->possibleActions() | 2262 << ", possibleActions: " << e->possibleActions() |
2263 << ", proposedAction: " << e->proposedAction() << std::endl; | 2263 << ", proposedAction: " << e->proposedAction() << endl; |
2264 | 2264 |
2265 if (e->mimeData()->hasFormat("text/uri-list") || | 2265 if (e->mimeData()->hasFormat("text/uri-list") || |
2266 e->mimeData()->hasFormat("text/plain")) { | 2266 e->mimeData()->hasFormat("text/plain")) { |
2267 | 2267 |
2268 if (e->proposedAction() & Qt::CopyAction) { | 2268 if (e->proposedAction() & Qt::CopyAction) { |
2275 } | 2275 } |
2276 | 2276 |
2277 void | 2277 void |
2278 Pane::dropEvent(QDropEvent *e) | 2278 Pane::dropEvent(QDropEvent *e) |
2279 { | 2279 { |
2280 std::cerr << "dropEvent: text: \"" << e->mimeData()->text().toStdString() | 2280 cerr << "dropEvent: text: \"" << e->mimeData()->text() |
2281 << "\"" << std::endl; | 2281 << "\"" << endl; |
2282 | 2282 |
2283 if (e->mimeData()->hasFormat("text/uri-list") || | 2283 if (e->mimeData()->hasFormat("text/uri-list") || |
2284 e->mimeData()->hasFormat("text/plain")) { | 2284 e->mimeData()->hasFormat("text/plain")) { |
2285 | 2285 |
2286 if (e->proposedAction() & Qt::CopyAction) { | 2286 if (e->proposedAction() & Qt::CopyAction) { |
2440 } | 2440 } |
2441 | 2441 |
2442 void | 2442 void |
2443 Pane::viewZoomLevelChanged(View *v, unsigned long z, bool locked) | 2443 Pane::viewZoomLevelChanged(View *v, unsigned long z, bool locked) |
2444 { | 2444 { |
2445 // std::cerr << "Pane[" << this << "]::zoomLevelChanged (global now " | 2445 // cerr << "Pane[" << this << "]::zoomLevelChanged (global now " |
2446 // << (m_manager ? m_manager->getGlobalZoom() : 0) << ")" << std::endl; | 2446 // << (m_manager ? m_manager->getGlobalZoom() : 0) << ")" << endl; |
2447 | 2447 |
2448 View::viewZoomLevelChanged(v, z, locked); | 2448 View::viewZoomLevelChanged(v, z, locked); |
2449 | 2449 |
2450 if (m_hthumb && !m_hthumb->isVisible()) return; | 2450 if (m_hthumb && !m_hthumb->isVisible()) return; |
2451 | 2451 |