Equalizer  2.1.0
Parallel Rendering Framework
fabric/window.h
1 
2 /* Copyright (c) 2010-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2014, Daniel Nachbaur <danielnachbaur@gmail.com>
4  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQFABRIC_WINDOW_H
21 #define EQFABRIC_WINDOW_H
22 
23 #include <eq/fabric/object.h> // base class
24 
25 #include <eq/fabric/drawableConfig.h> // enum
26 #include <eq/fabric/paths.h>
27 #include <eq/fabric/pixelViewport.h>
28 #include <eq/fabric/viewport.h>
29 #include <eq/fabric/windowSettings.h>
30 
31 namespace eq
32 {
33 namespace fabric
34 {
36 template <class P, class W, class C, class Settings = WindowSettings>
37 class Window : public Object
38 {
39 public:
41  typedef std::vector<C*> Channels;
44 
48  void init();
49 
51  const P* getPipe() const { return _pipe; }
53  P* getPipe() { return _pipe; }
55  const Channels& getChannels() const { return _channels; }
58  {
59  return _data.drawableConfig;
60  }
61 
65  EQFABRIC_INL const PixelViewport& getPixelViewport() const;
66 
71  const Viewport& getViewport() const { return _data.vp; }
73  EQFABRIC_INL void setName(const std::string& name) final;
74 
84  EQFABRIC_INL virtual void setPixelViewport(const PixelViewport& pvp);
85 
95  EQFABRIC_INL void setViewport(const Viewport& vp);
96 
98  bool hasFixedViewport() const { return _data.fixedVP; }
100  virtual void notifyViewportChanged();
101 
109  EQFABRIC_INL VisitorResult accept(Visitor& visitor);
110 
112  EQFABRIC_INL VisitorResult accept(Visitor& visitor) const;
113 
115 
119  EQFABRIC_INL void setSettings(const Settings& settings);
120 
122  EQFABRIC_INL const Settings& getSettings() const;
123 
125  EQFABRIC_INL void setIAttribute(const WindowSettings::IAttribute attr,
126  const int32_t value);
127 
129  EQFABRIC_INL int32_t
130  getIAttribute(const WindowSettings::IAttribute attr) const;
131 
133  EQFABRIC_INL static const std::string& getIAttributeString(
134  const WindowSettings::IAttribute attr);
136 
138  EQFABRIC_INL WindowPath getPath() const;
139 
142  EQFABRIC_INL virtual void backup();
143  EQFABRIC_INL virtual void restore();
144  void create(C** channel);
145  void release(C* channel);
146  virtual void output(std::ostream&) const {}
147 
148  EQFABRIC_INL virtual uint128_t commit(
149  const uint32_t incarnation = CO_COMMIT_NEXT);
151 
152 protected:
154  explicit Window(P* parent);
155 
156  EQFABRIC_INL virtual ~Window();
157 
158  virtual void attach(const uint128_t& id, const uint32_t instanceID);
159 
161  EQFABRIC_INL virtual void serialize(co::DataOStream& os,
162  const uint64_t dirtyBits);
164  EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
165  const uint64_t dirtyBits);
166 
167  EQFABRIC_INL virtual void notifyDetach();
168 
170  EQFABRIC_INL virtual void setDirty(const uint64_t bits);
171 
173  void _setDrawableConfig(const DrawableConfig& drawableConfig);
174 
176  virtual ChangeType getChangeType() const { return UNBUFFERED; }
177  C* _findChannel(const uint128_t& id);
178 
180  enum DirtyBits
181  {
182  DIRTY_SETTINGS = Object::DIRTY_CUSTOM << 0,
183  DIRTY_CHANNELS = Object::DIRTY_CUSTOM << 1,
184  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 2,
185  DIRTY_DRAWABLECONFIG = Object::DIRTY_CUSTOM << 3,
186  DIRTY_WINDOW_BITS = DIRTY_SETTINGS | DIRTY_CHANNELS | DIRTY_VIEWPORT |
187  DIRTY_DRAWABLECONFIG | DIRTY_OBJECT_BITS
188  };
189 
191  virtual uint64_t getRedistributableBits() const
192  {
193  return DIRTY_WINDOW_BITS;
194  }
195 
196 private:
198  P* const _pipe;
199 
201  Channels _channels;
202 
203  struct BackupData
204  {
205  BackupData();
206 
208  Settings windowSettings;
209 
211  DrawableConfig drawableConfig;
212 
214  PixelViewport pvp;
215 
217  Viewport vp;
218 
221  bool fixedVP;
222  } _data, _backup;
223 
224  struct Private;
225  Private* _private; // placeholder for binary-compatible changes
226 
227  friend class Channel<W, C>;
229  void _addChannel(C* channel);
230 
232  EQFABRIC_INL bool _removeChannel(C* channel);
233 
235  bool _mapNodeObjects() { return _pipe->_mapNodeObjects(); }
236  typedef co::CommandFunc<Window<P, W, C, Settings>> CmdFunc;
237  bool _cmdNewChannel(co::ICommand& command);
238  bool _cmdNewChannelReply(co::ICommand& command);
239 };
240 
241 template <class P, class W, class C, class Settings>
242 EQFABRIC_INL std::ostream& operator<<(std::ostream& os,
243  const Window<P, W, C, Settings>& window);
244 }
245 }
246 
247 #endif // EQFABRIC_WINDOW_H
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
virtual EQFABRIC_INL void setDirty(const uint64_t bits)
const Viewport & getViewport() const
Definition: fabric/window.h:71
const Channels & getChannels() const
Definition: fabric/window.h:55
DirtyBits
The changed parts of the object since the last pack().
Definition: object.h:107
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Perform a depth-first traversal of this window.
A visitor to traverse non-leaf elements and their children in a tree.
EQFABRIC_INL const Settings & getSettings() const
EQFABRIC_INL const PixelViewport & getPixelViewport() const
EQFABRIC_INL void setSettings(const Settings &settings)
Set the settings of this window.
EQFABRIC_INL void setIAttribute(const WindowSettings::IAttribute attr, const int32_t value)
Set a window attribute.
bool hasFixedViewport() const
Definition: fabric/window.h:98
std::vector< C * > Channels
A vector of pointers to channels.
Definition: fabric/window.h:41
virtual EQFABRIC_INL void setPixelViewport(const PixelViewport &pvp)
Set the window&#39;s pixel viewport wrt its parent pipe.
The Equalizer client library.
Definition: eq/agl/types.h:23
std::ostream & operator<<(std::ostream &os, const AxisEvent &event)
Print the axis event to the given output stream.
Definition: axisEvent.h:49
ElementVisitor< W, LeafVisitor< C > > Visitor
The Window visitor type.
Definition: fabric/window.h:43
Base data transport class for windows.
Base data transport class for channels.
const P * getPipe() const
Definition: fabric/window.h:51
const DrawableConfig & getDrawableConfig() const
Definition: fabric/window.h:57
EQFABRIC_INL int32_t getIAttribute(const WindowSettings::IAttribute attr) const
Stores the characteristics of a window&#39;s frame buffer configuration.
EQFABRIC_INL void setName(const std::string &name) final
Set the window&#39;s name/caption.
EQFABRIC_INL void setViewport(const Viewport &vp)
Set the window&#39;s viewport wrt its parent pipe.
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34