Line data Source code
1 :
2 : /* Copyright (c) 2009-2016, Stefan Eilemann <eile@equalizergraphics.com>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #include "layout.h"
19 :
20 : #include "canvas.h"
21 : #include "channel.h"
22 : #include "config.h"
23 : #include "segment.h"
24 : #include "view.h"
25 : #include "window.h"
26 :
27 : #include <co/dataOStream.h>
28 : #include <eq/fabric/commands.h>
29 : #include <eq/fabric/paths.h>
30 :
31 : namespace eq
32 : {
33 : namespace server
34 : {
35 : typedef fabric::Layout<Config, Layout, View> Super;
36 :
37 644 : Layout::Layout(Config* parent)
38 : : Super(parent)
39 644 : , _state(STATE_ACTIVE)
40 : {
41 644 : }
42 :
43 1284 : Layout::~Layout()
44 : {
45 1284 : }
46 :
47 14 : ServerPtr Layout::getServer()
48 : {
49 14 : Config* config = getConfig();
50 14 : LBASSERT(config);
51 14 : return (config ? config->getServer() : 0);
52 : }
53 :
54 0 : void Layout::postDelete()
55 : {
56 0 : _state = STATE_DELETE;
57 0 : getConfig()->postNeedsFinish();
58 0 : }
59 :
60 0 : void Layout::notifyViewportChanged()
61 : {
62 0 : for (View* view : getViews())
63 : {
64 0 : const Viewport& vp = view->getViewport();
65 0 : for (Channel* channel : view->getChannels())
66 : {
67 0 : Window* window = channel->getWindow();
68 0 : PixelViewport windowPVP = window->getPixelViewport();
69 0 : PixelViewport channelPVP = getPixelViewport();
70 :
71 0 : Segment* segment = channel->getSegment();
72 : const auto segmentVP =
73 0 : segment ? segment->getViewport() : Viewport();
74 0 : const Viewport coverage = vp.getCoverage(segmentVP);
75 :
76 0 : channelPVP.apply(vp);
77 0 : channelPVP.apply(coverage);
78 0 : channelPVP.x = channel->getPixelViewport().x;
79 0 : channelPVP.y = channel->getPixelViewport().y;
80 :
81 0 : if (channel->hasFixedViewport())
82 : {
83 : // resize window to gain target channel pvp
84 0 : const auto& channelVP = channel->getViewport();
85 0 : windowPVP.w = channelPVP.w / channelVP.w;
86 0 : windowPVP.h = channelPVP.h / channelVP.h;
87 0 : window->send(fabric::CMD_WINDOW_RESIZE) << windowPVP;
88 0 : window->setPixelViewport(windowPVP);
89 : }
90 : else
91 : {
92 : // resize channel to fixed size, grow window size if needed
93 0 : if (windowPVP.w < channelPVP.getXEnd() ||
94 0 : windowPVP.h < channelPVP.getYEnd())
95 : {
96 0 : windowPVP.w = std::max(windowPVP.w, channelPVP.getXEnd());
97 0 : windowPVP.h = std::max(windowPVP.h, channelPVP.getYEnd());
98 0 : window->send(fabric::CMD_WINDOW_RESIZE) << windowPVP;
99 0 : window->setPixelViewport(windowPVP);
100 : }
101 0 : channel->setPixelViewport(channelPVP);
102 : }
103 : }
104 : }
105 0 : }
106 :
107 4 : void Layout::trigger(const Canvas* canvas, const bool active)
108 : {
109 4 : LBASSERT(canvas);
110 4 : getConfig()->postNeedsFinish();
111 :
112 8 : for (View* view : getViews())
113 4 : view->trigger(canvas, active);
114 4 : }
115 : }
116 : }
117 :
118 : #include "../fabric/layout.ipp"
119 : #include "nodeFactory.h"
120 :
121 : template class eq::fabric::Layout<eq::server::Config, eq::server::Layout,
122 : eq::server::View>;
123 : /** @cond IGNORE */
124 : template std::ostream& eq::fabric::operator<<(
125 : std::ostream&,
126 : const eq::fabric::Layout<eq::server::Config, eq::server::Layout,
127 60 : eq::server::View>&);
128 : /** @endcond */
|