NorMIT-nav  18.04
An IGT application
cxTimelineWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXTIMELINEWIDGET_H_
13 #define CXTIMELINEWIDGET_H_
14 
15 #include "cxResourceWidgetsExport.h"
16 
17 #include <QWidget>
18 
19 #include "vtkForwardDeclarations.h"
20 #include "cxForwardDeclarations.h"
21 #include "cxVector3D.h"
22 #include "cxPlaybackTime.h"
23 
24 
25 namespace cx
26 {
27 
38 class cxResourceWidgets_EXPORT TimelineWidget : public QWidget
39 {
40 Q_OBJECT
41 
42 public:
43  TimelineWidget(QWidget* parent);
44  virtual ~TimelineWidget();
45 
46 
47  void setEvents(std::vector<TimelineEvent> events);
48 // void setRegions(std::vector<std::pair<double, double> > validRegions);
49  void setRange(double start, double stop);
50  void setPos(double pos);
51  double getPos() const;
52 
53 signals:
54  void positionChanged();
55 
56 protected slots:
57 
58 protected:
59  virtual bool event(QEvent *event);
60  virtual void mousePressEvent(QMouseEvent* event);
61  virtual void mouseReleaseEvent(QMouseEvent* event);
62  virtual void mouseMoveEvent(QMouseEvent* event);
63  virtual void resizeEvent(QResizeEvent* evt);
64  virtual void paintEvent(QPaintEvent* event);
65  virtual QSize sizeHint() const;
66  QSize minimumSizeHint() const;
67 
68 private:
69  int mapTime2PlotX(double time) const;
70  double mapPlotX2Time(int plotX) const;
71  bool showHelp(QPoint pos);
72 
73  void setPositionFromScreenPos(int x, int y);
74  void createCompactingTransforms();
75  double findCompactedTime(double timeInterval, double totalUsedTime, double totalTime) const;
76 
77 // std::vector<std::pair<double, double> > mValidRegions;
78  std::vector<TimelineEvent> mEvents;
79  int mBorder;
80  double mStart, mStop, mPos;
81  QRect mFullArea;
82  QRect mPlotArea;
83  bool mCloseToGlyph;
84  int mTolerance_p;
85  QStringList mContinousEvents; //< list of all continous events, used for stacked display
86  std::vector<TimelineEvent> mNoncompactedIntervals;
87 // std::vector<QColor> mEventColors; ///< use to color continous events
88 
89  vtkPiecewiseFunctionPtr mBackward;
90  vtkPiecewiseFunctionPtr mForward;
91 
92 };
93 
94 } /* namespace cx */
95 
96 #endif /* CXTIMELINEWIDGET_H_ */
widget for displaying a timeline for events.
vtkSmartPointer< class vtkPiecewiseFunction > vtkPiecewiseFunctionPtr
Namespace for all CustusX production code.