Line data Source code
1 :
2 : /* Copyright (c) 2011-2016, Stefan Eilemann <eile@eyescale.ch>
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 EQSEQUEL_VIEWDATA_H
20 : #define EQSEQUEL_VIEWDATA_H
21 :
22 : #include <seq/api.h>
23 : #include <seq/types.h>
24 : #include <eq/fabric/vmmlib.h>
25 : #include <co/serializable.h> // base class
26 :
27 : namespace seq
28 : {
29 : /** Stores per-view data. */
30 : class ViewData : public co::Serializable
31 : {
32 : public:
33 : /** Construct a new view data. @version 1.0 */
34 : SEQ_API explicit ViewData( View& view );
35 :
36 : /** Destruct this view data. @version 1.0 */
37 : SEQ_API virtual ~ViewData();
38 :
39 : /** @name Operations */
40 : //@{
41 : #ifndef EQ_2_0_API
42 : /**
43 : * Handle the given event.
44 : *
45 : * The default implementation provides a pointer-based camera model and some
46 : * key event handling, all of which can be modified by overwriting this
47 : * method and handling the appropriate events.
48 : * @version 1.0
49 : * @deprecated
50 : */
51 : SEQ_API virtual bool handleEvent( const eq::ConfigEvent* event );
52 : #endif
53 :
54 : /**
55 : * Handle the given event command.
56 : *
57 : * The default implementation provides a pointer-based camera model and some
58 : * key event handling, all of which can be modified by overwriting this
59 : * method and handling the appropriate events.
60 : * @version 1.5.1
61 : */
62 : SEQ_API virtual bool handleEvent( eq::EventICommand command );
63 :
64 : /** Rotate the model matrix by the given increments. @version 1.0 */
65 : SEQ_API void spinModel( const float x, const float y, const float z );
66 :
67 : /** Move the model matrix by the given increments. @version 1.0 */
68 : SEQ_API void moveModel( const float x, const float y, const float z );
69 :
70 : /**
71 : * Enable or disable statistics rendering.
72 : *
73 : * The statistics are rendered in the views where they are enabled. The
74 : * default event handler of this view toggles the statistics rendering state
75 : * when 's' is pressed.
76 : *
77 : * @param on the state of the statistics rendering.
78 : * @version 1.0
79 : */
80 : SEQ_API void showStatistics( const bool on );
81 :
82 : /**
83 : * Enable or disable orthographic rendering.
84 : *
85 : * The default event handler of this view toggles the orthographic rendering
86 : * state when 'o' is pressed.
87 : *
88 : * @param on the state of the orthographic rendering.
89 : * @version 1.2
90 : */
91 : SEQ_API void setOrtho( const bool on );
92 :
93 : /**
94 : * Update the view data.
95 : *
96 : * Called once at the end of each frame to trigger animations. The default
97 : * implementation updates the camera data.
98 : *
99 : * @return true to request a redraw.
100 : * @version 1.0
101 : */
102 : SEQ_API virtual bool update();
103 : //@}
104 :
105 : /** @name Data Access. */
106 : //@{
107 : /** Set the current model matrix (global camera). @version 1.11 */
108 : SEQ_API void setModelMatrix( const Matrix4f& matrix );
109 :
110 : /** @return the current model matrix (global camera). @version 1.0 */
111 0 : const Matrix4f& getModelMatrix() const { return _modelMatrix; }
112 :
113 : /** @return true is statistics are rendered. @version 1.0 */
114 0 : bool getStatistics() const { return _statistics; }
115 : //@}
116 :
117 : /** @return true when orthographic rendering is enabled. @version 1.2 */
118 0 : bool useOrtho() const { return _ortho; }
119 : //@}
120 :
121 : protected:
122 : SEQ_API void serialize( co::DataOStream& os, const uint64_t dirtyBits ) override;
123 : SEQ_API void deserialize( co::DataIStream& is,
124 : const uint64_t dirtyBits ) override;
125 :
126 : /** The changed parts of the object since the last serialize(). */
127 : enum DirtyBits
128 : {
129 : DIRTY_MODELMATRIX = co::Serializable::DIRTY_CUSTOM << 0, // 1
130 : DIRTY_STATISTICS = co::Serializable::DIRTY_CUSTOM << 1, // 2
131 : DIRTY_ORTHO = co::Serializable::DIRTY_CUSTOM << 2, // 4
132 : DIRTY_CUSTOM = co::Serializable::DIRTY_CUSTOM << 3 // 8
133 : };
134 :
135 : private:
136 : bool _handleEvent( const eq::Event& event );
137 :
138 : View& _view;
139 : Matrix4f _modelMatrix;
140 : int32_t _spinX, _spinY;
141 : int32_t _advance;
142 : bool _statistics;
143 : bool _ortho;
144 : };
145 : }
146 : #endif // EQSEQUEL_VIEWDATA_H
|