6#include "SerialTrack.h"
7#include "GeoDataCamera.h"
8#include "GeoDataLookAt.h"
9#include "PlaybackFlyToItem.h"
10#include "PlaybackTourControlItem.h"
11#include "PlaybackWaitItem.h"
12#include "TourPlayback.h"
17SerialTrack::SerialTrack()
21 m_finishedPosition = 0;
22 m_currentPosition = 0;
26SerialTrack::~SerialTrack()
31void SerialTrack::append(PlaybackItem *item)
33 connect(item, &PlaybackItem::progressChanged,
this, &SerialTrack::changeProgress);
34 connect(item, &PlaybackItem::centerOn,
this, &SerialTrack::centerOn);
35 connect(item, &PlaybackItem::finished,
this, &SerialTrack::handleFinishedItem);
36 connect(item, &PlaybackItem::paused,
this, &SerialTrack::pause);
38 if (m_items.size() == 1) {
39 auto flyTo =
dynamic_cast<PlaybackFlyToItem *
>(item);
40 if (flyTo !=
nullptr) {
41 flyTo->setFirst(
true);
46void SerialTrack::play()
49 m_items[m_currentIndex]->play();
52void SerialTrack::pause()
55 m_items[m_currentIndex]->pause();
58void SerialTrack::stop()
61 if (m_items.size() != 0 && m_currentIndex >= 0 && m_currentIndex <= m_items.size() - 1) {
62 m_items[m_currentIndex]->stop();
64 m_finishedPosition = 0;
65 Q_EMIT progressChanged(m_finishedPosition);
69void SerialTrack::seek(
double offset)
71 m_currentPosition = offset;
73 for (
int i = 0; i < m_items.size(); i++) {
74 if (offset < m_items[i]->duration()) {
79 offset -= m_items[i]->duration();
84 index = m_items.size() - 1;
87 if (index < m_items.size() - 1) {
88 for (
int i = index + 1; i < m_items.size(); i++) {
93 if (index > m_currentIndex) {
94 for (
int i = m_currentIndex; i < index; i++) {
95 m_finishedPosition += m_items[i]->duration();
98 for (
int i = m_currentIndex - 1; i >= index && i >= 0; i--) {
99 m_finishedPosition -= m_items[i]->duration();
103 if (m_currentIndex != index && !m_paused) {
104 m_items[index]->play();
107 m_currentIndex = index;
108 if (m_currentIndex != -1) {
109 double t = offset / m_items[m_currentIndex]->duration();
110 Q_ASSERT(t >= 0 && t <= 1);
111 m_items[m_currentIndex]->seek(t);
115double SerialTrack::duration()
const
117 double duration = 0.0;
118 for (PlaybackItem *item : m_items) {
119 duration += item->duration();
124void SerialTrack::clear()
129 m_finishedPosition = 0;
130 m_currentPosition = 0;
134void SerialTrack::handleFinishedItem()
139 if (m_currentIndex + 1 < m_items.size()) {
140 m_finishedPosition += m_items[m_currentIndex]->duration();
142 m_items[m_currentIndex]->play();
143 Q_EMIT itemFinished(m_currentIndex + 1);
150void SerialTrack::changeProgress(
double progress)
152 m_currentPosition = m_finishedPosition + progress;
153 Q_EMIT progressChanged(m_currentPosition);
156int SerialTrack::size()
const
158 return m_items.size();
161PlaybackItem *SerialTrack::at(
int i)
163 return m_items.at(i);
166double SerialTrack::currentPosition()
168 return m_currentPosition;
173#include "moc_SerialTrack.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)