comparison view/Pane.cpp @ 268:70537b0434c4

* Use a command for adding layer measurements
author Chris Cannam
date Tue, 26 Jun 2007 11:08:21 +0000
parents 4ed1446ad604
children 61a704654497
comparison
equal deleted inserted replaced
267:4ed1446ad604 268:70537b0434c4
394 break; 394 break;
395 } 395 }
396 } 396 }
397 } 397 }
398 398
399 Layer *topLayer = 0; 399 Layer *topLayer = getTopLayer();
400
400 const Model *waveformModel = 0; // just for reporting purposes 401 const Model *waveformModel = 0; // just for reporting purposes
401 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { 402 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
402 --vi; 403 --vi;
403 if (!topLayer) topLayer = *vi;
404 if (dynamic_cast<WaveformLayer *>(*vi)) { 404 if (dynamic_cast<WaveformLayer *>(*vi)) {
405 waveformModel = (*vi)->getModel(); 405 waveformModel = (*vi)->getModel();
406 break; 406 break;
407 } 407 }
408 } 408 }
966 bool 966 bool
967 Pane::getTopLayerDisplayExtents(float &vmin, float &vmax, 967 Pane::getTopLayerDisplayExtents(float &vmin, float &vmax,
968 float &dmin, float &dmax, 968 float &dmin, float &dmax,
969 QString *unit) 969 QString *unit)
970 { 970 {
971 Layer *layer = 0; 971 Layer *layer = getTopLayer();
972 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
973 if (!layer) return false; 972 if (!layer) return false;
974 bool vlog; 973 bool vlog;
975 QString vunit; 974 QString vunit;
976 bool rv = (layer->getValueExtents(vmin, vmax, vlog, vunit) && 975 bool rv = (layer->getValueExtents(vmin, vmax, vlog, vunit) &&
977 layer->getDisplayExtents(dmin, dmax)); 976 layer->getDisplayExtents(dmin, dmax));
980 } 979 }
981 980
982 bool 981 bool
983 Pane::setTopLayerDisplayExtents(float dmin, float dmax) 982 Pane::setTopLayerDisplayExtents(float dmin, float dmax)
984 { 983 {
985 Layer *layer = 0; 984 Layer *layer = getTopLayer();
986 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
987 if (!layer) return false; 985 if (!layer) return false;
988 return layer->setDisplayExtents(dmin, dmax); 986 return layer->setDisplayExtents(dmin, dmax);
989 } 987 }
990 988
991 void 989 void
1087 } 1085 }
1088 } 1086 }
1089 1087
1090 } else if (mode == ViewManager::MeasureMode) { 1088 } else if (mode == ViewManager::MeasureMode) {
1091 1089
1092 Layer *layer = getSelectedLayer(); 1090 Layer *layer = getTopLayer();
1093 if (layer) layer->measureStart(this, e); 1091 if (layer) layer->measureStart(this, e);
1094 update(); 1092 update();
1095 } 1093 }
1096 1094
1097 emit paneInteractedWith(); 1095 emit paneInteractedWith();
1173 } 1171 }
1174 } 1172 }
1175 1173
1176 } else if (mode == ViewManager::MeasureMode) { 1174 } else if (mode == ViewManager::MeasureMode) {
1177 1175
1178 Layer *layer = getSelectedLayer(); 1176 Layer *layer = getTopLayer();
1179 if (layer) layer->measureEnd(this, e); 1177 if (layer) layer->measureEnd(this, e);
1180 if (m_measureCursor1) setCursor(*m_measureCursor1); 1178 if (m_measureCursor1) setCursor(*m_measureCursor1);
1181 update(); 1179 update();
1182 } 1180 }
1183 1181
1266 1264
1267 } else if (mode == ViewManager::MeasureMode) { 1265 } else if (mode == ViewManager::MeasureMode) {
1268 1266
1269 if (m_measureCursor2) setCursor(*m_measureCursor2); 1267 if (m_measureCursor2) setCursor(*m_measureCursor2);
1270 1268
1271 Layer *layer = getSelectedLayer(); 1269 Layer *layer = getTopLayer();
1272 if (layer) layer->measureDrag(this, e); 1270 if (layer) layer->measureDrag(this, e);
1273 1271
1274 if (hasTopLayerTimeXAxis()) { 1272 if (hasTopLayerTimeXAxis()) {
1275 edgeScrollMaybe(e->x()); 1273 edgeScrollMaybe(e->x());
1276 } 1274 }