1 // Copyright (C) 2009 - 2012 Mathias Froehlich - Mathias.Froehlich@web.de
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Library General Public License for more details.
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.
18 #ifndef HLAViewerFederate_hxx
19 #define HLAViewerFederate_hxx
21 #include <osg/ref_ptr>
22 #include <osg/observer_ptr>
25 #include <osgDB/Options>
27 #include <simgear/hla/HLAFederate.hxx>
29 #include "HLASceneObjectClass.hxx"
30 #include "HLAView.hxx"
31 #include "HLAViewClass.hxx"
32 #include "HLAPerspectiveViewer.hxx"
33 #include "HLAPerspectiveViewerClass.hxx"
34 #include "HLAMPAircraftClass.hxx"
40 class HLAViewerFederate : public simgear::HLAFederate {
43 virtual ~HLAViewerFederate();
45 const HLAPerspectiveViewer* getViewer() const;
46 HLAPerspectiveViewer* getViewer();
47 void setViewer(HLAPerspectiveViewer* viewer);
49 const HLAView* getView() const;
51 void setView(HLAView* view);
53 virtual simgear::HLAObjectClass* createObjectClass(const std::string& name);
56 virtual bool update();
57 virtual bool shutdown();
59 /// The node containing all the dynamic models attached to this viewer
60 osg::Node* getDynamicModelNode();
61 void addDynamicModel(osg::Node* node);
62 void removeDynamicModel(osg::Node* node);
64 /// Dynamic models use this options struct for loading/paging
65 osg::ref_ptr<const osgDB::Options> getReaderWriterOptions() const;
67 /// Called by the viewer.
68 void attachToViewer(Viewer* viewer);
70 /// Temporary application management
71 void insertView(HLAView* view);
72 void eraseView(HLAView* view);
75 /// Explicitly known object classes
76 SGSharedPtr<HLAPerspectiveViewerClass> _perspectiveViewerClass;
77 SGSharedPtr<HLAViewClass> _viewClass;
79 /// The perspective viewer of this viewer federate. FIXME: also allow orthographic viewers for instruments!
80 SGSharedPtr<HLAPerspectiveViewer> _perspectiveViewer;
82 /// The default absolute view
83 SGSharedPtr<HLAView> _defaultView;
85 /// A list of all available views
86 typedef std::list<SGSharedPtr<HLAView> > ViewList;
89 /// The openscenegraphs side of this component
90 osg::ref_ptr<osg::Group> _group;
92 /// The backward reference to the viewer
93 osg::observer_ptr<Viewer> _viewer;
96 } // namespace fgviewer