Line data Source code
1 :
2 : /* Copyright (c) 2008-2016, Stefan Eilemann <eile@equalizergraphics.com>
3 : * Daniel Nachbaur <danielnachbaur@gmail.com>
4 : *
5 : * This library is free software; you can redistribute it and/or modify it under
6 : * the terms of the GNU Lesser General Public License version 2.1 as published
7 : * by the Free Software Foundation.
8 : *
9 : * This library is distributed in the hope that it will be useful, but WITHOUT
10 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 : * details.
13 : *
14 : * You should have received a copy of the GNU Lesser General Public License
15 : * along with this library; if not, write to the Free Software Foundation, Inc.,
16 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 : */
18 :
19 : #ifndef EQ_VIEW_H
20 : #define EQ_VIEW_H
21 :
22 : #include <eq/api.h>
23 : #include <eq/types.h> // member
24 : #include <eq/visitorResult.h> // enum
25 :
26 : #include <eq/fabric/view.h> // base class
27 : #include <eq/fabric/viewport.h> // member
28 :
29 : namespace eq
30 : {
31 : namespace detail { class View; }
32 :
33 : /**
34 : * A View is a 2D area of a Layout. It is a view of the application's data on a
35 : * model, in the sense used by the MVC pattern. It can be a scene, viewing mode,
36 : * viewing position, or any other representation of the application's data.
37 : *
38 : * @warning Never commit a View. Equalizer does take care of this to correctly
39 : * associate view version with rendering frames.
40 : * @sa fabric::View
41 : */
42 : class View : public fabric::View< Layout, View, Observer >
43 : {
44 : public:
45 : /** Construct a new view. @version 1.0 */
46 : EQ_API explicit View( Layout* parent );
47 :
48 : /** Destruct this view. @version 1.0 */
49 : EQ_API virtual ~View();
50 :
51 : /** @name Data Access. */
52 : //@{
53 : /**
54 : * @return the parent pipe of this view, 0 for non-render client views.
55 : * @version 1.1.2
56 : */
57 0 : Pipe* getPipe() { return _pipe; }
58 :
59 : /**
60 : * @return the parent pipe of this view, 0 for non-render client views.
61 : * @version 1.1.2
62 : */
63 : EQ_API const Pipe* getPipe() const { return _pipe; }
64 :
65 : /** @return the config of this view. @version 1.0 */
66 : EQ_API Config* getConfig();
67 :
68 : /** @return the config of this view. @version 1.0 */
69 : EQ_API const Config* getConfig() const;
70 :
71 : /** @return the Server of this view. @version 1.0 */
72 : EQ_API ServerPtr getServer();
73 : //@}
74 :
75 : /** @name Operations */
76 : //@{
77 : /**
78 : * Handle a received (view) event.
79 : *
80 : * The task of this method is to update the view as necessary. It is
81 : * called by Config::handleEvent on the application main thread for all
82 : * view events. Thread safe.
83 : *
84 : * @param event the received view event.
85 : * @return true when the event was handled, false if not.
86 : * @version 1.0
87 : */
88 : EQ_API virtual bool handleEvent( const Event& event );
89 : //@}
90 :
91 : protected:
92 : /**
93 : * @name Callbacks
94 : *
95 : * Callbacks are called by Equalizer during rendering to execute various
96 : * actions from the application main thread before sending the corresponding
97 : * command to the server.
98 : */
99 : //@{
100 : /** Initialize this view. @version 1.11 */
101 1 : virtual bool configInit() { return true; }
102 : friend class detail::InitVisitor;
103 :
104 : /** Exit this view. @version 1.11 */
105 0 : virtual bool configExit() { return true; }
106 : friend class detail::ExitVisitor;
107 : //@}
108 :
109 : /** @internal */
110 : EQ_API virtual void deserialize( co::DataIStream& is,
111 : const uint64_t dirtyBits );
112 :
113 : /** @return the initial frustum value of this view. */
114 : EQ_API const Frustum& getBaseFrustum() const;
115 :
116 : /** @internal trigger deletion for render-client views. */
117 : EQ_API virtual void detach();
118 :
119 : private:
120 : detail::View* const _impl;
121 :
122 : Pipe* _pipe; // for render-client views
123 : friend class Pipe;
124 : };
125 : }
126 :
127 : #endif //EQ_VIEW_H
|