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
"
24
#include "
WindowSystemAdapter.hxx
"
25
26
#include <osg/Camera>
27
#include <osg/GraphicsContext>
28
#include <osg/Viewport>
29
30
using namespace
osg
;
31
using namespace
std;
32
33
namespace
flightgear
{
34
35
ref_ptr<WindowSystemAdapter>
WindowSystemAdapter::_wsa
;
36
37
void
GraphicsContextOperation::operator()
(GraphicsContext* gc)
38
{
39
run
(gc);
40
++done;
41
}
42
43
WindowSystemAdapter::WindowSystemAdapter
() :
44
_nextWindowID
(0)
45
{
46
}
47
48
GraphicsWindow
*
49
WindowSystemAdapter::registerWindow
(GraphicsContext* gc,
50
const
string
& windowName)
51
{
52
GraphicsWindow
* window =
new
GraphicsWindow
(gc, windowName,
53
_nextWindowID
++);
54
windows
.push_back(window);
55
return
window;
56
}
57
58
GraphicsWindow
*
WindowSystemAdapter::findWindow
(
const
string
&
name
)
const
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
70
GraphicsWindow
*
WindowSystemAdapter::getGUIWindow
()
const
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
CameraGroup.hxx
WindowSystemAdapter.hxx
flightgear::GraphicsContextOperation::operator()
virtual void operator()(osg::GraphicsContext *gc)
Don't override this!
Definition
WindowSystemAdapter.cxx:37
flightgear::GraphicsContextOperation::run
virtual void run(osg::GraphicsContext *gc)=0
The body of the operation.
flightgear::GraphicsWindow
A window with a graphics context and an integer ID.
Definition
WindowSystemAdapter.hxx:41
flightgear::WindowSystemAdapter::WindowSystemAdapter
WindowSystemAdapter()
Definition
WindowSystemAdapter.cxx:43
flightgear::WindowSystemAdapter::getGUIWindow
GraphicsWindow * getGUIWindow() const
Get the first window marked as GUI (there should only be one).
Definition
WindowSystemAdapter.cxx:70
flightgear::WindowSystemAdapter::findWindow
GraphicsWindow * findWindow(const std::string &name) const
Find a window by name.
Definition
WindowSystemAdapter.cxx:58
flightgear::WindowSystemAdapter::windows
WindowVector windows
Vector of all the registered windows.
Definition
WindowSystemAdapter.hxx:105
flightgear::WindowSystemAdapter::_nextWindowID
int _nextWindowID
Definition
WindowSystemAdapter.hxx:132
flightgear::WindowSystemAdapter::registerWindow
GraphicsWindow * registerWindow(osg::GraphicsContext *gc, const std::string &windowName)
Register a window, assigning it an ID.
Definition
WindowSystemAdapter.cxx:49
flightgear::WindowSystemAdapter::_wsa
static osg::ref_ptr< WindowSystemAdapter > _wsa
Definition
WindowSystemAdapter.hxx:133
flightgear
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition
Addon.cxx:53
flightgear::name
const char * name
Definition
subsystemFactory.cxx:307
osg
Definition
AIBase.hxx:25
src
Viewer
WindowSystemAdapter.cxx
Generated on Tue Jun 3 2025 12:58:42 for FlightGear by
1.13.2