comparison layer/Layer.h @ 283:86a112b5b319

* Make it possible to "measure" a feature on the spectrogram by double- clicking in measure mode * Make shift-click-drag (for zoom to region) work in measure mode as well as navigate mode. It would be nice to be able to shift-doubleclick to zoom on a feature directly using a combination of these last two features, but that isn't possible yet. * Make Del delete the measurement under the mouse pointer.
author Chris Cannam
date Thu, 05 Jul 2007 15:36:37 +0000
parents 3c402c6052f6
children cd2492c5fe45
comparison
equal deleted inserted replaced
282:4edaff85875d 283:86a112b5b319
1
2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
3 2
4 /* 3 /*
5 Sonic Visualiser 4 Sonic Visualiser
6 An audio file viewer and annotation editor. 5 An audio file viewer and annotation editor.
170 virtual void measureStart(View *, QMouseEvent *); 169 virtual void measureStart(View *, QMouseEvent *);
171 virtual void measureDrag(View *, QMouseEvent *); 170 virtual void measureDrag(View *, QMouseEvent *);
172 virtual void measureEnd(View *, QMouseEvent *); 171 virtual void measureEnd(View *, QMouseEvent *);
173 virtual void measureDoubleClick(View *, QMouseEvent *); 172 virtual void measureDoubleClick(View *, QMouseEvent *);
174 173
174 virtual bool haveCurrentMeasureRect() const {
175 return m_haveCurrentMeasureRect;
176 }
177 virtual void deleteCurrentMeasureRect(); // using a command
178
175 /** 179 /**
176 * Open an editor on the item under the mouse (e.g. on 180 * Open an editor on the item under the mouse (e.g. on
177 * double-click). If there is no item or editing is not 181 * double-click). If there is no item or editing is not
178 * supported, return false. 182 * supported, return false.
179 */ 183 */
459 private: 463 private:
460 Layer *m_layer; 464 Layer *m_layer;
461 MeasureRect m_rect; 465 MeasureRect m_rect;
462 }; 466 };
463 467
468 class DeleteMeasurementRectCommand : public Command
469 {
470 public:
471 DeleteMeasurementRectCommand(Layer *layer, MeasureRect rect) :
472 m_layer(layer), m_rect(rect) { }
473
474 virtual QString getName() const;
475 virtual void execute();
476 virtual void unexecute();
477
478 private:
479 Layer *m_layer;
480 MeasureRect m_rect;
481 };
482
464 void addMeasureRectToSet(const MeasureRect &r) { 483 void addMeasureRectToSet(const MeasureRect &r) {
465 m_measureRects.insert(r); 484 m_measureRects.insert(r);
466 emit layerMeasurementRectsChanged(); 485 emit layerMeasurementRectsChanged();
467 } 486 }
468 487
473 492
474 typedef std::set<MeasureRect> MeasureRectSet; 493 typedef std::set<MeasureRect> MeasureRectSet;
475 MeasureRectSet m_measureRects; 494 MeasureRectSet m_measureRects;
476 MeasureRect m_draggingRect; 495 MeasureRect m_draggingRect;
477 bool m_haveDraggingRect; 496 bool m_haveDraggingRect;
497 mutable bool m_haveCurrentMeasureRect;
498 mutable QPoint m_currentMeasureRectPoint;
478 499
479 // Note that pixrects are only correct for a single view. 500 // Note that pixrects are only correct for a single view.
480 // So we should update them at the start of the paint procedure 501 // So we should update them at the start of the paint procedure
481 // (painting is single threaded) and only use them after that. 502 // (painting is single threaded) and only use them after that.
482 void updateMeasurePixrects(View *v) const; 503 void updateMeasurePixrects(View *v) const;
483 504
484 virtual void updateMeasureRectYCoords(View *v, const MeasureRect &r) const; 505 virtual void updateMeasureRectYCoords(View *v, const MeasureRect &r) const;
485 virtual void setMeasureRectYCoord(View *v, MeasureRect &r, bool start, int y) const; 506 virtual void setMeasureRectYCoord(View *v, MeasureRect &r, bool start, int y) const;
507 virtual void setMeasureRectFromPixrect(View *v, MeasureRect &r, QRect pixrect) const;
486 508
487 // This assumes updateMeasurementPixrects has been called 509 // This assumes updateMeasurementPixrects has been called
488 MeasureRectSet::const_iterator findFocusedMeasureRect(QPoint) const; 510 MeasureRectSet::const_iterator findFocusedMeasureRect(QPoint) const;
489 511
490 void paintMeasurementRect(View *v, QPainter &paint, 512 void paintMeasurementRect(View *v, QPainter &paint,