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