/home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_workflow/include/workflow/item_observer.h Source File

MathVizAnimator: /home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_workflow/include/workflow/item_observer.h Source File
MathVizAnimator  0.0.1
item_observer.h
1 /* mathvizanimator
2  * Copyright (C) 2023 codingwithmagga
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef LIBS_MVA_WORKFLOW_INCLUDE_WORKFLOW_ITEM_OBSERVER_H_
19 #define LIBS_MVA_WORKFLOW_INCLUDE_WORKFLOW_ITEM_OBSERVER_H_
20 
21 #include <QObject>
22 #include <QVariantMap>
23 
24 #include "abstract_animation.h"
25 #include "basic_item.h"
26 
27 class ItemObserver : public QObject {
28  public:
29  explicit ItemObserver(BasicItem* const item, QObject* parent = nullptr);
30 
31  void setTimeProgressive(const qreal time);
32  void setTime(const qreal time);
33 
34  void addAnimation(const QSharedPointer<AbstractAnimation>& animation);
35  void addAnimations(const QList<QSharedPointer<AbstractAnimation>>& animations);
36  void removeAnimation(const QSharedPointer<AbstractAnimation>& animation);
37  void removeAnimation(const qint32 animation_number);
38 
39  void updateItemProperty(const QString& property, const QVariant& value);
40 
41  QJsonObject toJson() const;
42 
43  BasicItem* item() const;
44  AbstractItem* abstractitem() const;
45 
46  QList<QSharedPointer<AbstractAnimation>> animations() const;
47 
48  private:
49  void sortAnimations();
50  void applyStartProperties();
51 
52  BasicItem* m_item;
53  QList<QSharedPointer<AbstractAnimation>> m_animations;
54 
55  PropertyMap m_item_start_property_values;
56  PropertyMap m_basic_item_start_property_values;
57 };
58 
59 inline BasicItem* ItemObserver::item() const { return m_item; }
60 
61 inline AbstractItem* ItemObserver::abstractitem() const { return m_item->abstractItem(); }
62 
63 inline QList<QSharedPointer<AbstractAnimation>> ItemObserver::animations() const { return m_animations; }
64 
65 #endif // LIBS_MVA_WORKFLOW_INCLUDE_WORKFLOW_ITEM_OBSERVER_H_
An abstract class representing a visible item like a circle or a rectangle.
Definition: abstractitem.h:56
Definition: basic_item.h:28
Definition: item_observer.h:27
Map which stores key (QString) value (QVariant) pairs.
Definition: abstractitem.h:37