Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
SceneModel.h
1/*
2Copyright (C) 2015,2018,2019,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef AEONGAMES_SCENEMODEL_H
18#define AEONGAMES_SCENEMODEL_H
19#include <QAbstractItemModel>
20#include <vector>
21#include "aeongames/Scene.hpp"
22#include "aeongames/Node.hpp"
23
24namespace AeonGames
25{
27 class SceneModel : public QAbstractItemModel
28 {
29 Q_OBJECT
30 public:
35 SceneModel ( QObject *parent = nullptr );
37 virtual ~SceneModel();
39
40
45 QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const override;
49 QModelIndex parent ( const QModelIndex & index ) const override;
53 int rowCount ( const QModelIndex & index = QModelIndex() ) const override;
57 int columnCount ( const QModelIndex & index = QModelIndex() ) const override;
62 QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
68 QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
72 bool hasChildren ( const QModelIndex & index = QModelIndex() ) const override;
76 Qt::ItemFlags flags ( const QModelIndex & index ) const override;
82 bool setData ( const QModelIndex & index, const QVariant & value, int role ) override;
90 bool moveRows ( const QModelIndex & sourceParent, int sourceRow, int count, const QModelIndex & destinationParent, int destinationRow ) override;
93 Qt::DropActions supportedDropActions() const override;
101 bool dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ) override;
105 QMimeData * mimeData ( const QModelIndexList & indexes ) const override;
108 QStringList mimeTypes() const override;
110
116 void InsertNode ( int row, const QModelIndex & parent = QModelIndex(), std::unique_ptr<Node> aNode = {} );
122 void RemoveNode ( int row, const QModelIndex & parent = QModelIndex() );
127 void SetCameraNode ( const QModelIndex & index = QModelIndex() );
133 std::string Serialize ( bool aAsBinary = true ) const;
138 void Deserialize ( const std::string& aSerializedScene );
141 const Scene& GetScene() const;
142 private:
143 Scene mScene{};
144 };
145}
146#endif
Header for the Scene class.
Scene class. Scene is the container for all elements in a game level, takes care of collision,...
Definition Scene.hpp:40
QMimeData * mimeData(const QModelIndexList &indexes) const override
Return serialized MIME data for the given model indexes.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handle data supplied by a drag-and-drop operation.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Return the index of the item at the given row and column under parent.
int rowCount(const QModelIndex &index=QModelIndex()) const override
Return the number of rows under the given parent.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Return the header data for the given section, orientation, and role.
const Scene & GetScene() const
Get a const reference to the underlying scene.
std::string Serialize(bool aAsBinary=true) const
Serialize the scene to a string.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Set the data for the given index and role.
void Deserialize(const std::string &aSerializedScene)
Deserialize a scene from a string.
QModelIndex parent(const QModelIndex &index) const override
Return the parent of the given model index.
int columnCount(const QModelIndex &index=QModelIndex()) const override
Return the number of columns for children of the given parent.
void InsertNode(int row, const QModelIndex &parent=QModelIndex(), std::unique_ptr< Node > aNode={})
Insert a node into the scene tree.
bool hasChildren(const QModelIndex &index=QModelIndex()) const override
Return whether the given parent index has any children.
Qt::ItemFlags flags(const QModelIndex &index) const override
Return the item flags for the given model index.
SceneModel(QObject *parent=nullptr)
Construct the scene model.
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationRow) override
Move rows from one parent to another.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Return the data for the given index and role.
void SetCameraNode(const QModelIndex &index=QModelIndex())
Set the camera to the node at the given index.
Qt::DropActions supportedDropActions() const override
Return the drop actions supported by this model.
void RemoveNode(int row, const QModelIndex &parent=QModelIndex())
Remove a node from the scene tree.
virtual ~SceneModel()
Destructor.
QStringList mimeTypes() const override
Return the list of MIME types that can be used to describe model indexes.
<- This is here just for the literals
Definition AABB.hpp:31