Walls And Holes  1
simpletexturedscene.h
Go to the documentation of this file.
1 #ifndef SIMPLETEXTUREDSCENE_H
2 #define SIMPLETEXTUREDSCENE_H
3 
4 // Using std::shared_ptr because I need std::enable_shared_from_this
5 #include <memory>
6 
7 #include <QVector>
8 #include <QSharedPointer>
9 
10 #include "dereferencingiterator.h"
12 
13 #include "abstractscene.h"
14 
15 #include "simpletexturedobject.h"
16 
17 #include "objtools.h"
18 
19 
20 class SimpleTexturedScene : public AbstractScene, public std::enable_shared_from_this<SimpleTexturedScene>
21 {
22  Q_OBJECT
23 
24 public:
25 
26  using SharedSimpleTexturedScene = std::shared_ptr<SimpleTexturedScene>;
27 
28 
34 
35 
36  virtual ~SimpleTexturedScene();
37 
41  void clear();
42 
47  void addObject(QSharedPointer<SimpleTexturedObject> object);
48 
53  void removeObject(QSharedPointer<SimpleTexturedObject> object);
54 
55 
60  void commitChanges();
61 
62  /* Iterators for accessing objects in the scene */
63  auto begin()
64  {
65  auto itr = mObjects.begin();
67  }
68 
69  auto end()
70  {
71  auto itr = mObjects.end();
73  }
74 
75 
76  auto begin() const
77  {
78  auto itr = mObjects.begin();
80  }
81 
82  auto end() const
83  {
84  auto itr = mObjects.end();
86  }
87 
91  SharedOBJModel exportOBJ() override;
92 
93 signals:
98  void objectAdded(const SimpleTexturedObject &obj);
99 
106  void objectRemoved(const SimpleTexturedObject &obj);
107 
111  void sceneCleared();
112 
116  void changesCommitted();
117 
118 protected:
119 
124 
129  QSharedPointer<AbstractRenderer> makeRenderer() override;
130 
131 
132  QVector<QSharedPointer<SimpleTexturedObject>> mObjects;
133 };
134 
135 
137 
138 #endif // SIMPLETEXTUREDSCENE_H
Definition: abstractscene.h:12
auto end() const
Definition: simpletexturedscene.h:82
auto begin()
Definition: simpletexturedscene.h:63
A helper class to provide an iterator into a collection of pointers such that when the iterator is de...
Definition: dereferencingiterator.h:11
SimpleTexturedScene::SharedSimpleTexturedScene SharedSimpleTexturedScene
Definition: simpletexturedscene.h:136
QSharedPointer< AbstractRenderer > makeRenderer() override
Creates and returns a SimpleTexturedRenderer.
Definition: simpletexturedscene.cpp:48
void objectAdded(const SimpleTexturedObject &obj)
Emitted when an object is added.
QVector< QSharedPointer< SimpleTexturedObject > > mObjects
Definition: simpletexturedscene.h:132
A helper class to provide an iterator into a collection of pointers such that when the iterator is de...
Definition: dereferencingconstiterator.h:13
auto begin() const
Definition: simpletexturedscene.h:76
void changesCommitted()
Emitted when changes to the scene are committed and should be rendered.
void sceneCleared()
Emitted when all objects are removed from the scene.
void addObject(QSharedPointer< SimpleTexturedObject > object)
Adds an object to the scene.
Definition: simpletexturedscene.cpp:30
SimpleTexturedScene()
Creates an empty scene.
Definition: simpletexturedscene.cpp:5
auto end()
Definition: simpletexturedscene.h:69
The SimpleTexturedObject class represents an object with Phong lighting information and a single text...
Definition: simpletexturedobject.h:23
virtual ~SimpleTexturedScene()
Definition: simpletexturedscene.cpp:19
QSharedPointer< OBJModel > SharedOBJModel
Definition: objtools.h:71
static SharedSimpleTexturedScene makeScene()
Creates an empty scene.
Definition: simpletexturedscene.cpp:13
std::shared_ptr< SimpleTexturedScene > SharedSimpleTexturedScene
Definition: simpletexturedscene.h:26
void objectRemoved(const SimpleTexturedObject &obj)
Emitted when an object is about to be removed.
void removeObject(QSharedPointer< SimpleTexturedObject > object)
Removes an object from the scene.
Definition: simpletexturedscene.cpp:36
SharedOBJModel exportOBJ() override
export all renderable object as a single OBJModel
Definition: simpletexturedscene.cpp:60
Definition: simpletexturedscene.h:20
void clear()
Removes all objects from the scene.
Definition: simpletexturedscene.cpp:24
void commitChanges()
Commits the changes to the scene, possibly causing it to be rerendered.
Definition: simpletexturedscene.cpp:42