FlightGear next
WindowSystemAdapter.cxx
Go to the documentation of this file.
1// Copyright (C) 2008 Tim Moore
2//
3// This program is free software; you can redistribute it and/or
4// modify it under the terms of the GNU General Public License as
5// published by the Free Software Foundation; either version 2 of the
6// License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful, but
9// WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16#ifdef HAVE_CONFIG_H
17# include <config.h>
18#endif
19
20#include<algorithm>
21#include <functional>
22
23#include "CameraGroup.hxx"
25
26#include <osg/Camera>
27#include <osg/GraphicsContext>
28#include <osg/Viewport>
29
30using namespace osg;
31using namespace std;
32
33namespace flightgear {
34
35ref_ptr<WindowSystemAdapter> WindowSystemAdapter::_wsa;
36
37void GraphicsContextOperation::operator()(GraphicsContext* gc)
38{
39 run(gc);
40 ++done;
41}
42
47
50 const string& windowName)
51{
52 GraphicsWindow* window = new GraphicsWindow(gc, windowName,
54 windows.push_back(window);
55 return window;
56}
57
59{
60 auto it = std::find_if(windows.begin(), windows.end(),
61 [&name](const auto& window) {
62 return window->name == name;
63 });
64 if (it == windows.end()) {
65 return nullptr;
66 }
67 return (*it).get();
68}
69
71{
72 auto it = std::find_if(windows.begin(), windows.end(),
73 [](const auto& window) {
74 return window->flags & GraphicsWindow::GUI;
75 });
76 if (it == windows.end()) {
77 return nullptr;
78 }
79 return (*it).get();
80}
81
82} // namespace flightgear
virtual void operator()(osg::GraphicsContext *gc)
Don't override this!
virtual void run(osg::GraphicsContext *gc)=0
The body of the operation.
A window with a graphics context and an integer ID.
GraphicsWindow * getGUIWindow() const
Get the first window marked as GUI (there should only be one).
GraphicsWindow * findWindow(const std::string &name) const
Find a window by name.
WindowVector windows
Vector of all the registered windows.
GraphicsWindow * registerWindow(osg::GraphicsContext *gc, const std::string &windowName)
Register a window, assigning it an ID.
static osg::ref_ptr< WindowSystemAdapter > _wsa
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
const char * name
Definition AIBase.hxx:25