QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgstemporalnavigationobject.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstemporalnavigationobject.h
3  ---------------
4  begin : March 2020
5  copyright : (C) 2020 by Samweli Mwakisambwe
6  email : samweli at kartoza dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #ifndef QGSTEMPORALNAVIGATIONOBJECT_H
20 #define QGSTEMPORALNAVIGATIONOBJECT_H
21 
22 #include "qgis_core.h"
23 #include "qgsrange.h"
24 #include "qgsinterval.h"
25 #include "qgstemporalcontroller.h"
27 
28 #include <QList>
29 #include <QTimer>
30 
31 class QgsMapLayer;
32 
40 {
41  Q_OBJECT
42 
43  public:
44 
48  QgsTemporalNavigationObject( QObject *parent SIP_TRANSFERTHIS = nullptr );
49 
52  {
56  };
57 
60  {
63  Idle,
64  };
65 
71  void setAnimationState( AnimationState state );
72 
78  AnimationState animationState() const;
79 
85  void setNavigationMode( const NavigationMode mode );
86 
92  NavigationMode navigationMode() const { return mNavigationMode; }
93 
102  void setTemporalExtents( const QgsDateTimeRange &extents );
103 
110  QgsDateTimeRange temporalExtents() const;
111 
120  void setCurrentFrameNumber( long long frame );
121 
127  long long currentFrameNumber() const;
128 
136  void setFrameDuration( QgsInterval duration );
137 
143  QgsInterval frameDuration() const;
144 
151  QgsDateTimeRange dateTimeRangeForFrameNumber( long long frame ) const;
152 
161  void setFramesPerSecond( double rate );
162 
171  double framesPerSecond() const;
172 
178  void setTemporalRangeCumulative( bool state );
179 
185  bool temporalRangeCumulative() const;
186 
190  long long totalFrameCount();
191 
197  bool isLooping() const;
198 
204  void setLooping( bool loop );
205 
207 
208  signals:
209 
213  void stateChanged( AnimationState state );
214 
218  void navigationModeChanged( NavigationMode mode );
219 
223  void temporalExtentsChanged( const QgsDateTimeRange &extent );
224 
228  void temporalFrameDurationChanged( const QgsInterval &interval );
229 
230 
231  public slots:
232 
237  void play();
238 
248  void pause();
249 
253  void playForward();
254 
258  void playBackward();
259 
266  void next();
267 
274  void previous();
275 
279  void rewindToStart();
280 
284  void skipToEnd();
285 
286  private slots:
287 
289  void timerTimeout();
290 
291  private:
292 
294  QgsDateTimeRange mTemporalExtents;
295 
296  NavigationMode mNavigationMode = NavigationOff;
297 
299  long long mCurrentFrameNumber = 0;
300 
302  QgsInterval mFrameDuration;
303 
305  double mFramesPerSecond = 1;
306 
308  QTimer *mNewFrameTimer = nullptr;
309 
311  AnimationState mPlayBackMode = Idle;
312 
313  bool mLoopAnimation = false;
314 
315  bool mCumulativeTemporalRange = false;
316 
317  int mBlockUpdateTemporalRangeSignal = 0;
318 
320  QgsTemporalNavigationObject &operator= ( const QgsTemporalNavigationObject & ) = delete;
321 };
322 
323 #endif // QGSTEMPORALNAVIGATIONOBJECT_H
QgsTemporalNavigationObject::Animated
@ Animated
Temporal navigation relies on frames within a datetime range.
Definition: qgstemporalnavigationobject.h:54
QgsTemporalNavigationObject::Reverse
@ Reverse
Animation is playing in reverse.
Definition: qgstemporalnavigationobject.h:62
qgsinterval.h
QgsTemporalNavigationObject::navigationMode
NavigationMode navigationMode() const
Returns the currenttemporal navigation mode.
Definition: qgstemporalnavigationobject.h:92
QgsExpressionContextScopeGenerator
Abstract interface for generating an expression context scope.
Definition: qgsexpressioncontextscopegenerator.h:29
qgsrange.h
QgsTemporalNavigationObject::NavigationMode
NavigationMode
Represents the current temporal navigation mode.
Definition: qgstemporalnavigationobject.h:52
QgsTemporalNavigationObject::Forward
@ Forward
Animation is playing forward.
Definition: qgstemporalnavigationobject.h:61
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
qgstemporalcontroller.h
QgsTemporalController
A controller base class for temporal objects, contains a signal for notifying updates of the objects ...
Definition: qgstemporalcontroller.h:42
QgsTemporalNavigationObject::Idle
@ Idle
Animation is paused.
Definition: qgstemporalnavigationobject.h:63
QgsTemporalNavigationObject
Implements a temporal controller based on a frame by frame navigation and animation.
Definition: qgstemporalnavigationobject.h:40
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext.
Definition: qgsexpressioncontext.h:112
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsInterval
A representation of the interval between two datetime values.
Definition: qgsinterval.h:41
QgsTemporalNavigationObject::NavigationOff
@ NavigationOff
Temporal navigation is disabled.
Definition: qgstemporalnavigationobject.h:53
QgsTemporalNavigationObject::AnimationState
AnimationState
Represents the current animation state.
Definition: qgstemporalnavigationobject.h:60
qgsexpressioncontextscopegenerator.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsTemporalNavigationObject::FixedRange
@ FixedRange
Temporal navigation relies on a fixed datetime range.
Definition: qgstemporalnavigationobject.h:55
QgsExpressionContextScopeGenerator::createExpressionContextScope
virtual QgsExpressionContextScope * createExpressionContextScope() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...