Line data Source code
1 :
2 : /* Copyright (c) 2013-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 : namespace eq
19 : {
20 : namespace detail
21 : {
22 1 : class InitVisitor : public ConfigVisitor
23 : {
24 : public:
25 1 : InitVisitor(const Strings& activeLayouts, const float modelUnit)
26 1 : : _layouts(activeLayouts)
27 : , _modelUnit(modelUnit)
28 1 : , _update(false)
29 : {
30 1 : }
31 :
32 1 : virtual VisitorResult visit(eq::Observer* observer)
33 : {
34 1 : if (observer->configInit())
35 1 : return TRAVERSE_CONTINUE;
36 0 : LBWARN << *observer << " initialization failed" << std::endl;
37 0 : return TRAVERSE_TERMINATE;
38 : }
39 :
40 7 : virtual VisitorResult visit(eq::View* view)
41 : {
42 7 : if (view->setModelUnit(_modelUnit))
43 0 : _update = true;
44 7 : if (view->configInit())
45 7 : return TRAVERSE_CONTINUE;
46 0 : LBWARN << *view << " initialization failed" << std::endl;
47 0 : return TRAVERSE_TERMINATE;
48 : }
49 :
50 1 : virtual VisitorResult visitPre(eq::Canvas* canvas)
51 : {
52 1 : const Layouts& layouts = canvas->getLayouts();
53 :
54 1 : for (StringsCIter i = _layouts.begin(); i != _layouts.end(); ++i)
55 : {
56 0 : const std::string& name = *i;
57 0 : for (LayoutsCIter j = layouts.begin(); j != layouts.end(); ++j)
58 : {
59 0 : const eq::Layout* layout = *j;
60 0 : if (layout && layout->getName() == name &&
61 0 : canvas->useLayout(j - layouts.begin()))
62 : {
63 0 : _update = true;
64 : }
65 : }
66 : }
67 1 : return TRAVERSE_CONTINUE;
68 : }
69 :
70 1 : bool needsUpdate() const { return _update; }
71 : private:
72 : const Strings& _layouts;
73 : const float _modelUnit;
74 : bool _update;
75 : };
76 : }
77 : }
|