pqTimelinePainter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqTimelinePainter_h
5 #define pqTimelinePainter_h
6 
8 
9 #include <QObject>
10 
11 #include <memory> // for std::unique_ptr
12 
13 class QPainter;
14 class QStyleOptionViewItem;
15 class QStandardItem;
16 
30 {
31  Q_OBJECT
32  typedef QObject Superclass;
33 
34 public:
35  pqTimelinePainter(QObject* parent = nullptr);
36  ~pqTimelinePainter() override;
37 
41  void paint(QPainter* painter, const QModelIndex& index, const QStyleOptionViewItem& option);
42 
48  void setSceneStartTime(double time);
52  void setSceneEndTime(double time);
54  void setSceneCurrentTime(double time);
56  double getSceneCurrentTime();
58  void setSceneLockStart(bool lock);
60  void setSceneLockEnd(bool lock);
62 
64 
67  void setDisplayTimeRange(double start, double end);
68  QPair<double, double> displayTimeRange();
70 
74  bool hasStartEndLabels();
78  QRect getStartLabelRect();
80  QRect getEndLabelRect();
82 
84 
89  double positionFromTime(double time, const QStyleOptionViewItem& option);
90  double positionFromTime(double time);
92 
97  double indexTimeFromPosition(
99  double pos, const QStyleOptionViewItem& option, const QModelIndex& index);
100  double timeFromPosition(double pos, const QStyleOptionViewItem& option);
101  double timeFromPosition(double pos);
103 
107  bool isTimeTrack(QStandardItem* item);
111  bool isAnimationTrack(QStandardItem* item);
113  std::vector<double> getTimes(QStandardItem* item);
115  double getSourceTime(QStandardItem* item);
117  QString getLabel(QStandardItem* item, int index);
119 
120 protected:
126  void paintBackground(QPainter* painter, const QStyleOptionViewItem& option, bool alternate);
131  void paintTimeline(QPainter* painter, const QStyleOptionViewItem& option, QStandardItem* item,
132  bool paintLabels, const QStyleOptionViewItem& labelsOption);
134  void paintTimeTrack(QPainter* painter, const QStyleOptionViewItem& option, QStandardItem* item);
136  void paintSourceTrack(QPainter* painter, const QStyleOptionViewItem& option, QStandardItem* item);
138  void paintAnimationTrack(
139  QPainter* painter, const QStyleOptionViewItem& option, QStandardItem* item);
141  void paintSourcePipelineTime(
142  QPainter* painter, const QStyleOptionViewItem& option, QStandardItem* item);
144  void paintSceneCurrentTime(QPainter* painter, const QStyleOptionViewItem& option);
148  bool paintTick(QPainter* painter, const QStyleOptionViewItem& option, QStandardItem* item,
149  double time, bool paintLabels, const QStyleOptionViewItem& labelsOption, const QString& label);
151  void paintTimeMark(QPainter* painter, const QStyleOptionViewItem& option, double pos);
154  bool paintLabel(QPainter* painter, const QStyleOptionViewItem& option, QStandardItem* item,
155  double time, const QString& label);
157 
158  double SceneCurrentTime = 0;
159  double SceneStartTime = 0;
160  double SceneEndTime = 1;
161 
162  double DisplayStartTime = 0.;
163  double DisplayEndTime = 1.;
164 
165  bool SceneLockStart = false;
166  bool SceneLockEnd = false;
167 
168 private:
169  struct pqInternals;
170  std::unique_ptr<pqInternals> Internals;
171 };
172 
173 #endif
#define PQAPPLICATIONCOMPONENTS_EXPORT
time
pqTimelineItemDelegate draws timeline in cells.
index