Equalizer  1.6.1
addWindow.h
1 
2 /* Copyright (c) 2010, Stefan Eilemann <eile@eyescale.ch>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer. Redistributions in binary
9  * form must reproduce the above copyright notice, this list of conditions and
10  * the following disclaimer in the documentation and/or other materials provided
11  * with the distribution. Neither the name of Eyescale Software GmbH nor the
12  * names of its contributors may be used to endorse or promote products derived
13  * from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef EQ_ADMIN_ADD_WINDOW_H
29 #define EQ_ADMIN_ADD_WINDOW_H
30 
31 #include "findPipe.h"
32 
33 #include <eq/admin/base.h>
34 
35 namespace eqAdmin
36 {
37 
38 inline bool addWindow( eq::admin::ServerPtr server, const bool passiveStereo )
39 {
40  if( !server )
41  return false;
42 
43  // Find first pipe...
44  eq::admin::Pipe* pipe = findPipe( server );
45  if( !pipe )
46  return false;
47 
48  // Add window (->channel->segment->canvas->layout->view)
49  eq::admin::Config* config = pipe->getConfig();
50  eq::admin::Window* window = new eq::admin::Window( pipe );
51  eq::admin::Channel* channel = new eq::admin::Channel( window );
52  eq::admin::Canvas* canvas = new eq::admin::Canvas( config );
53  eq::admin::Segment* segment = new eq::admin::Segment( canvas );
54  eq::admin::Layout* layout = new eq::admin::Layout( config );
55  eq::admin::View* view = new eq::admin::View( layout );
56  eq::admin::Observer* observer = new eq::admin::Observer( config );
57 
58  window->setPixelViewport( eq::fabric::PixelViewport( 100, 100, 400, 300 ));
59  channel->setName( "Runtime-created channel" );
60  canvas->setName( "Runtime-created canvas" );
61  layout->setName( "Runtime-created layout" );
62  view->setName( "Runtime-created view" );
63  observer->setName( "Runtime-created observer" );
64  view->changeMode( eq::admin::View::MODE_STEREO );
65 
66  if( passiveStereo )
67  {
68  window->setName( "Passive stereo window" );
69  window->setPixelViewport(
70  eq::fabric::PixelViewport( 500, 100, 400, 300 ));
71  segment->setEyes( eq::fabric::EYE_CYCLOP ); // Mono
72  view->changeMode( eq::admin::View::MODE_MONO );
73 
74  // Passive stereo
75  eq::admin::Channel* channelLeft = new eq::admin::Channel( window );
76  eq::admin::Channel* channelRight = new eq::admin::Channel( window );
77 
78  eq::admin::Segment* segmentLeft = new eq::admin::Segment( canvas );
79  eq::admin::Segment* segmentRight = new eq::admin::Segment( canvas );
80 
81  channelLeft->setViewport( eq::fabric::Viewport( .0f, 0.f, .5f, 1.f ));
82  segmentLeft->setEyes( eq::fabric::EYE_LEFT );
83  segmentLeft->setChannel( channelLeft );
84 
85  channelRight->setViewport( eq::fabric::Viewport( .5f, 0.f, .5f, 1.f ));
86  segmentRight->setEyes( eq::fabric::EYE_RIGHT );
87  segmentRight->setChannel( channelRight );
88 
89  channelLeft->setName( "Runtime-created left eye channel" );
90  channelRight->setName( "Runtime-created right eye channel" );
91  }
92  else
93  window->setName( "Active stereo window" );
94 
95  view->setObserver( observer );
96  view->setWall( eq::fabric::Wall( eq::fabric::Vector3f(-.4f,-.3f,-1.f ),
97  eq::fabric::Vector3f( .4f,-.3f,-1.f ),
98  eq::fabric::Vector3f(-.4f, .3f,-1.f )));
99  segment->setChannel( channel );
100  canvas->addLayout( layout );
101 
102  config->commit();
103  return true;
104 }
105 
106 }
107 
108 #endif // EQ_ADMIN_ADD_WINDOW_H
monoscopic &#39;middle&#39; eye
Definition: fabric/eye.h:38
vmml::vector< 3, float > Vector3f
A three-component float vector.
Definition: vmmlib.h:46
A wall defining a view frustum.
Definition: wall.h:38
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
A fractional viewport with methods for manipulation.
Definition: viewport.h:36