Equalizer  1.6.1
share/Equalizer/examples/eqPly/config.h
1 
2 /* Copyright (c) 2006-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2011-2012, Daniel Nachbaur <danielnachbaur@gmail.com>
4  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * - Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  * - Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  * - Neither the name of Eyescale Software GmbH nor the names of its
15  * contributors may be used to endorse or promote products derived from this
16  * software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef EQ_PLY_CONFIG_H
32 #define EQ_PLY_CONFIG_H
33 
34 // members
35 #include "localInitData.h"
36 #include "frameData.h"
37 #include "cameraAnimation.h"
38 
39 #include <eq/eq.h>
40 #include <eq/admin/base.h>
41 
42 namespace eqPly
43 {
44  class View;
45 
53  class Config : public eq::Config
54  {
55  public:
56  Config( eq::ServerPtr parent );
57 
59  virtual bool init();
61  virtual bool exit();
62 
64  virtual uint32_t startFrame();
65 
66  void setInitData( const LocalInitData& data ) { _initData = data; }
67  const InitData& getInitData() const { return _initData; }
68 
70  bool loadData( const eq::uint128_t& initDataID );
71 
73  const Model* getModel( const eq::uint128_t& id );
74 
76  virtual bool handleEvent( const eq::ConfigEvent* event );
77  virtual bool handleEvent( eq::EventICommand command );
78 
80  bool isIdleAA();
81 
83  bool needRedraw();
84 
86  uint32_t getAnimationFrame();
87 
88  protected:
89  virtual ~Config();
90 
92  virtual co::uint128_t sync(
93  const co::uint128_t& version = co::VERSION_HEAD );
94 
95  private:
96  int _spinX, _spinY;
97  int _advance;
98  eq::Canvas* _currentCanvas;
99 
100  LocalInitData _initData;
101  FrameData _frameData;
102 
103  Models _models;
104  ModelDists _modelDist;
105  lunchbox::Lock _modelLock;
106 
107  CameraAnimation _animation;
108 
109  uint64_t _messageTime;
110 
111  bool _redraw;
112  bool _useIdleAA;
113 
114  int32_t _numFramesAA;
115 
116  eq::admin::ServerPtr _admin;
117 
118  void _loadModels();
119  void _registerModels();
120  void _loadPath();
121  void _deregisterData();
122 
123  bool _needNewFrame();
124  bool _handleKeyEvent( const eq::KeyEvent& event );
125 
126  void _switchCanvas();
127  void _switchView();
128  void _switchViewMode();
129  void _switchModel();
130  void _freezeLoadBalancing( const bool onOff );
131  void _adjustEyeBase( const float delta );
132  void _adjustTileSize( const int delta );
133  void _adjustResistance( const int delta );
134  void _adjustModelScale( const float factor );
135  void _switchLayout( int32_t increment );
136  void _toggleEqualizer();
137 
138  void _setHeadMatrix( const eq::Matrix4f& matrix );
139  const eq::Matrix4f& _getHeadMatrix() const;
140  void _changeFocusDistance( const float delta );
141  void _setFocusMode( const eq::FocusMode mode );
142 
144  eq::admin::ServerPtr _getAdminServer();
145  void _closeAdminServer();
146 
147  View* _getCurrentView();
148  const View* _getCurrentView() const;
149 
150  void _setMessage( const std::string& message );
151  void _updateData();
152  };
153 }
154 
155 #endif // EQ_PLY_CONFIG_H
A configuration is a visualization session driven by an application.
virtual uint32_t startFrame()
A command specialization for config events.
Definition: eventICommand.h:38
virtual ~Config()
Destruct a config.
uint32_t getAnimationFrame()
A canvas represents a logical 2D projection surface.
Definition: client/canvas.h:51
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
virtual bool handleEvent(const eq::ConfigEvent *event)
const Model * getModel(const eq::uint128_t &id)
Loads sequence of camera positions and interpolates them on a per-frame basis.
virtual bool init()
Manages the argument parsing and non-distributed part of the initialization data. ...
virtual co::uint128_t sync(const co::uint128_t &version=co::VERSION_HEAD)
Synchronize config and admin copy.
Event for a key press or release.
Definition: event.h:128
bool loadData(const eq::uint128_t &initDataID)
Map per-config data to the local node process.
virtual bool exit()
The configuration, run be the EqPly application.