comparison view/Pane.cpp @ 188:dd573e090eed

* Add range input dialog * Make Panner support middle-click/ctrl-left-click to reset and emit doubleClicked when doubleClicked instead of resetting * Use range input dialog to enter new values for panner on double-click
author Chris Cannam
date Fri, 12 Jan 2007 21:52:56 +0000
parents e7cf6044c2a0
children 5b7472db612b
comparison
equal deleted inserted replaced
187:e7cf6044c2a0 188:dd573e090eed
32 #include <QFrame> 32 #include <QFrame>
33 #include <QGridLayout> 33 #include <QGridLayout>
34 #include <QPushButton> 34 #include <QPushButton>
35 #include "widgets/Thumbwheel.h" 35 #include "widgets/Thumbwheel.h"
36 #include "widgets/Panner.h" 36 #include "widgets/Panner.h"
37 #include "widgets/RangeInputDialog.h"
37 38
38 using std::cerr; 39 using std::cerr;
39 using std::endl; 40 using std::endl;
40 41
41 Pane::Pane(QWidget *w) : 42 Pane::Pane(QWidget *w) :
74 ++count; 75 ++count;
75 } 76 }
76 77
77 std::cerr << "Have " << count+1 << " zoom levels" << std::endl; 78 std::cerr << "Have " << count+1 << " zoom levels" << std::endl;
78 */ 79 */
80
81 Layer *layer = 0;
82 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
79 83
80 if (!m_headsUpDisplay) { 84 if (!m_headsUpDisplay) {
81 85
82 m_headsUpDisplay = new QFrame(this); 86 m_headsUpDisplay = new QFrame(this);
83 87
101 m_vpan->setFixedWidth(12); 105 m_vpan->setFixedWidth(12);
102 m_vpan->setFixedHeight(70); 106 m_vpan->setFixedHeight(70);
103 m_vpan->setAlpha(80, 130); 107 m_vpan->setAlpha(80, 130);
104 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)), 108 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)),
105 this, SLOT(verticalPannerMoved(float, float, float, float))); 109 this, SLOT(verticalPannerMoved(float, float, float, float)));
110 connect(m_vpan, SIGNAL(doubleClicked()),
111 this, SLOT(editVerticalPannerExtents()));
106 112
107 m_vthumb = new Thumbwheel(Qt::Vertical); 113 m_vthumb = new Thumbwheel(Qt::Vertical);
108 m_vthumb->setObjectName(tr("Vertical Zoom")); 114 m_vthumb->setObjectName(tr("Vertical Zoom"));
109 layout->addWidget(m_vthumb, 0, 2); 115 layout->addWidget(m_vthumb, 0, 2);
110 m_vthumb->setFixedWidth(16); 116 m_vthumb->setFixedWidth(16);
111 m_vthumb->setFixedHeight(70); 117 m_vthumb->setFixedHeight(70);
112 connect(m_vthumb, SIGNAL(valueChanged(int)), this, 118 connect(m_vthumb, SIGNAL(valueChanged(int)), this,
113 SLOT(verticalThumbwheelMoved(int))); 119 SLOT(verticalThumbwheelMoved(int)));
114 120
121 if (layer) {
122 RangeMapper *rm = layer->getNewVerticalZoomRangeMapper();
123 if (rm) m_vthumb->setRangeMapper(rm);
124 }
125
115 QPushButton *reset = new QPushButton; 126 QPushButton *reset = new QPushButton;
116 reset->setFixedHeight(16); 127 reset->setFixedHeight(16);
117 reset->setFixedWidth(16); 128 reset->setFixedWidth(16);
118 layout->addWidget(reset, 1, 2); 129 layout->addWidget(reset, 1, 2);
119 connect(reset, SIGNAL(clicked()), m_hthumb, SLOT(resetToDefault())); 130 connect(reset, SIGNAL(clicked()), m_hthumb, SLOT(resetToDefault()));
120 connect(reset, SIGNAL(clicked()), m_vthumb, SLOT(resetToDefault())); 131 connect(reset, SIGNAL(clicked()), m_vthumb, SLOT(resetToDefault()));
132 connect(reset, SIGNAL(clicked()), m_vpan, SLOT(resetToDefault()));
121 } 133 }
122 134
123 int count = 0; 135 int count = 0;
124 int current = 0; 136 int current = 0;
125 int level = 1; 137 int level = 1;
177 if (count != 50 && m_hthumb->getDefaultValue() == 0) { 189 if (count != 50 && m_hthumb->getDefaultValue() == 0) {
178 m_hthumb->setDefaultValue(count - current); 190 m_hthumb->setDefaultValue(count - current);
179 // std::cerr << "set default value to " << m_hthumb->getDefaultValue() << std::endl; 191 // std::cerr << "set default value to " << m_hthumb->getDefaultValue() << std::endl;
180 } 192 }
181 193
182 Layer *layer = 0;
183 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
184 if (layer) { 194 if (layer) {
185 int defaultStep = 0; 195 int defaultStep = 0;
186 int max = layer->getVerticalZoomSteps(defaultStep); 196 int max = layer->getVerticalZoomSteps(defaultStep);
187 if (max == 0) { 197 if (max == 0) {
188 m_vthumb->hide(); 198 m_vthumb->hide();
700 return true; 710 return true;
701 } 711 }
702 712
703 bool 713 bool
704 Pane::getTopLayerDisplayExtents(float &vmin, float &vmax, 714 Pane::getTopLayerDisplayExtents(float &vmin, float &vmax,
705 float &dmin, float &dmax) 715 float &dmin, float &dmax,
716 QString *unit)
706 { 717 {
707 Layer *layer = 0; 718 Layer *layer = 0;
708 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1); 719 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
709 if (!layer) return false; 720 if (!layer) return false;
710 bool vlog; 721 bool vlog;
711 QString vunit; 722 QString vunit;
712 return (layer->getValueExtents(vmin, vmax, vlog, vunit) && 723 bool rv = (layer->getValueExtents(vmin, vmax, vlog, vunit) &&
713 layer->getDisplayExtents(dmin, dmax)); 724 layer->getDisplayExtents(dmin, dmax));
725 if (unit) *unit = vunit;
726 return rv;
714 } 727 }
715 728
716 bool 729 bool
717 Pane::setTopLayerDisplayExtents(float dmin, float dmax) 730 Pane::setTopLayerDisplayExtents(float dmin, float dmax)
718 { 731 {
1413 std::cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w 1426 std::cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w
1414 << "," << h << ") -> (" << newmin << "," << newmax << ")" << std::endl; 1427 << "," << h << ") -> (" << newmin << "," << newmax << ")" << std::endl;
1415 setTopLayerDisplayExtents(newmin, newmax); 1428 setTopLayerDisplayExtents(newmin, newmax);
1416 } 1429 }
1417 1430
1431 void
1432 Pane::editVerticalPannerExtents()
1433 {
1434 if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return;
1435
1436 float vmin, vmax, dmin, dmax;
1437 QString unit;
1438 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax, &unit)
1439 || vmax == vmin) {
1440 return;
1441 }
1442
1443 RangeInputDialog dialog(tr("Enter new range"),
1444 tr("New vertical display range, from %1 to %2 %4:")
1445 .arg(vmin).arg(vmax).arg(unit),
1446 unit, vmin, vmax, this);
1447 dialog.setRange(dmin, dmax);
1448
1449 if (dialog.exec() == QDialog::Accepted) {
1450 dialog.getRange(dmin, dmax);
1451 setTopLayerDisplayExtents(dmin, dmax);
1452 updateVerticalPanner();
1453 }
1454 }
1455
1418 bool 1456 bool
1419 Pane::editSelectionStart(QMouseEvent *e) 1457 Pane::editSelectionStart(QMouseEvent *e)
1420 { 1458 {
1421 if (!m_identifyFeatures || 1459 if (!m_identifyFeatures ||
1422 !m_manager || 1460 !m_manager ||