Mercurial > hg > svgui
comparison layer/Layer.h @ 268:70537b0434c4
* Use a command for adding layer measurements
author | Chris Cannam |
---|---|
date | Tue, 26 Jun 2007 11:08:21 +0000 |
parents | 4ed1446ad604 |
children | 7b58c5e91f20 |
comparison
equal
deleted
inserted
replaced
267:4ed1446ad604 | 268:70537b0434c4 |
---|---|
25 #include <QRect> | 25 #include <QRect> |
26 #include <QXmlAttributes> | 26 #include <QXmlAttributes> |
27 #include <QMutex> | 27 #include <QMutex> |
28 | 28 |
29 #include <map> | 29 #include <map> |
30 #include <set> | |
30 | 31 |
31 class ZoomConstraint; | 32 class ZoomConstraint; |
32 class Model; | 33 class Model; |
33 class QPainter; | 34 class QPainter; |
34 class View; | 35 class View; |
394 void modelChanged(size_t startFrame, size_t endFrame); | 395 void modelChanged(size_t startFrame, size_t endFrame); |
395 void modelReplaced(); | 396 void modelReplaced(); |
396 | 397 |
397 void layerParametersChanged(); | 398 void layerParametersChanged(); |
398 void layerParameterRangesChanged(); | 399 void layerParameterRangesChanged(); |
400 void layerMeasurementRectsChanged(); | |
399 void layerNameChanged(); | 401 void layerNameChanged(); |
400 | 402 |
401 void verticalZoomChanged(); | 403 void verticalZoomChanged(); |
402 | 404 |
403 protected: | 405 protected: |
404 struct MeasureRect { | 406 struct MeasureRect { |
407 | |
405 mutable QRect pixrect; | 408 mutable QRect pixrect; |
406 long startFrame; // only valid for a layer that hasTimeXAxis | 409 bool haveFrames; |
410 long startFrame; // only valid if haveFrames | |
407 long endFrame; // ditto | 411 long endFrame; // ditto |
412 | |
413 bool operator<(const MeasureRect &mr) const; | |
408 }; | 414 }; |
409 | 415 |
410 typedef std::vector<MeasureRect> MeasureRectList; // should be x-ordered | 416 class AddMeasurementRectCommand : public Command |
411 MeasureRectList m_measureRectList; | 417 { |
418 public: | |
419 AddMeasurementRectCommand(Layer *layer, MeasureRect rect) : | |
420 m_layer(layer), m_rect(rect) { } | |
421 | |
422 virtual QString getName() const; | |
423 virtual void execute(); | |
424 virtual void unexecute(); | |
425 | |
426 private: | |
427 Layer *m_layer; | |
428 MeasureRect m_rect; | |
429 }; | |
430 | |
431 void addMeasureRect(const MeasureRect &r) { | |
432 m_measureRects.insert(r); | |
433 emit layerMeasurementRectsChanged(); | |
434 } | |
435 | |
436 void deleteMeasureRect(const MeasureRect &r) { | |
437 m_measureRects.erase(r); | |
438 emit layerMeasurementRectsChanged(); | |
439 } | |
440 | |
441 typedef std::set<MeasureRect> MeasureRectSet; | |
442 MeasureRectSet m_measureRects; | |
412 MeasureRect m_draggingRect; | 443 MeasureRect m_draggingRect; |
413 bool m_haveDraggingRect; | 444 bool m_haveDraggingRect; |
445 | |
446 void paintMeasurementRect(View *v, QPainter &paint, MeasureRect &r); | |
414 | 447 |
415 private: | 448 private: |
416 mutable QMutex m_dormancyMutex; | 449 mutable QMutex m_dormancyMutex; |
417 mutable std::map<const void *, bool> m_dormancy; | 450 mutable std::map<const void *, bool> m_dormancy; |
418 }; | 451 }; |