]> git.mxchange.org Git - flightgear.git/blob - src/Model/panelnode.hxx
Improve transponder instrumentation: new version
[flightgear.git] / src / Model / panelnode.hxx
1 #ifndef FG_PANELNODE_HXX
2 #define FG_PANELNODE_HXX
3
4 #include <osg/Vec3>
5 #include <osg/Matrix>
6 #include <osg/Drawable>
7
8 #include <simgear/structure/SGSharedPtr.hxx>
9 #include <simgear/props/props.hxx>
10
11 class FGPanel;
12 class SGPropertyNode;
13
14 // PanelNode defines an OSG drawable wrapping the 2D panel drawing code
15
16 class FGPanelNode : public osg::Drawable
17 {
18 public:
19     FGPanelNode();
20   
21     FGPanelNode(SGPropertyNode* props);
22     virtual ~FGPanelNode();
23
24     // OSGFIXME
25     virtual osg::Object* cloneType() const { return 0; }
26     virtual osg::Object* clone(const osg::CopyOp& copyop) const { return 0; }        
27
28     FGPanel* getPanel() { return _panel; }
29
30     virtual void drawImplementation(osg::RenderInfo& renderInfo) const
31     { drawImplementation(*renderInfo.getState()); }
32   
33     void drawImplementation(osg::State& state) const;
34     virtual osg::BoundingBox computeBound() const;
35
36     /** Return true, FGPanelNode does support accept(PrimitiveFunctor&). */
37     virtual bool supports(const osg::PrimitiveFunctor&) const { return true; }
38   
39     virtual void accept(osg::PrimitiveFunctor& functor) const;
40   
41     static osg::Node* load(SGPropertyNode *n);
42     static osg::Node* create2DPanelNode();
43   
44     osg::Matrix transformMatrix() const;
45   
46     void setPanelPath(const std::string& panel);
47     void lazyLoad();
48   
49     /**
50       * is visible in 2D mode or not?
51       */
52     bool isVisible2d() const;
53 private:
54     void commonInit();
55     void initWithPanel();
56     
57     SGSharedPtr<FGPanel> _panel;
58     std::string _panelPath;
59   
60     bool _resizeToViewport;
61     bool _depthTest;
62   
63     // Panel corner coordinates
64     osg::Vec3 _bottomLeft, _topLeft, _bottomRight;
65
66     int _xmin, _ymin, _xmax, _ymax;
67   
68     // The matrix that results, which transforms 2D x/y panel
69     // coordinates into 3D coordinates of the panel quadrilateral.
70     osg::Matrix _xform;  
71   
72     /// should the 2D panel auto-hide when the view orientation changes
73     mutable SGPropertyNode_ptr _autoHide2d;
74     
75     /// should the 2D panel be hidden in views other than the default (view 0)
76     mutable SGPropertyNode_ptr _hideNonDefaultViews;
77 };
78
79
80 #endif // FG_PANELNODE_HXX