]> git.mxchange.org Git - flightgear.git/blob - src/Model/panelnode.hxx
Replace a program segmentation fault by an annoying message
[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 #include <osg/Version>
8
9 #include <memory>
10 #include <simgear/structure/SGSharedPtr.hxx>
11 #include <simgear/props/props.hxx>
12
13 class FGPanel;
14 class SGPropertyNode;
15
16 // PanelNode defines an OSG drawable wrapping the 2D panel drawing code
17
18 class FGPanelNode : public osg::Drawable
19 {
20 public:  
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
35     virtual osg::BoundingBox
36 #if OSG_VERSION_LESS_THAN(3,3,2)
37     computeBound()
38 #else
39     computeBoundingBox()
40 #endif
41     const;
42
43
44     /** Return true, FGPanelNode does support accept(PrimitiveFunctor&). */
45     virtual bool supports(const osg::PrimitiveFunctor&) const { return true; }
46   
47     virtual void accept(osg::PrimitiveFunctor& functor) const;
48   
49     static osg::Node* load(SGPropertyNode *n);
50     static osg::Node* create2DPanelNode();
51   
52     osg::Matrix transformMatrix() const;
53   
54     void setPanelPath(const std::string& panel);
55     void lazyLoad();
56   
57     /**
58       * is visible in 2D mode or not?
59       */
60     bool isVisible2d() const;
61 private:
62     FGPanelNode(); // for 2D panels
63     
64     void commonInit();
65     void initWithPanel();
66     
67     bool panelMouseClickCommand(const SGPropertyNode * arg);
68     
69     const bool _is2d;
70     SGSharedPtr<FGPanel> _panel;
71     std::string _panelPath;
72   
73     bool _resizeToViewport;
74     bool _depthTest;
75   
76     // Panel corner coordinates
77     osg::Vec3 _bottomLeft, _topLeft, _bottomRight;
78
79     int _xmin, _ymin, _xmax, _ymax;
80   
81     // The matrix that results, which transforms 2D x/y panel
82     // coordinates into 3D coordinates of the panel quadrilateral.
83     osg::Matrix _xform;  
84   
85     SGPropertyChangeListener* _listener;
86     std::auto_ptr<SGPropertyChangeListener> _pathListener;
87     
88     /// should the 2D panel auto-hide when the view orientation changes
89     mutable SGPropertyNode_ptr _autoHide2d;
90     
91     /// should the 2D panel be hidden in views other than the default (view 0)
92     mutable SGPropertyNode_ptr _hideNonDefaultViews;
93 };
94
95
96 #endif // FG_PANELNODE_HXX