]> git.mxchange.org Git - flightgear.git/blob - src/Model/panelnode.hxx
#738: crash when switching 2D panels
[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 <simgear/structure/SGSharedPtr.hxx>
8
9 class FGPanel;
10 class SGPropertyNode;
11
12 // PanelNode defines an OSG drawable wrapping the 2D panel drawing code
13
14 class FGPanelNode : public osg::Drawable
15 {
16 public:
17     FGPanelNode(FGPanel* panel);
18   
19     FGPanelNode(SGPropertyNode* props);
20     virtual ~FGPanelNode();
21
22     // OSGFIXME
23     virtual osg::Object* cloneType() const { return 0; }
24     virtual osg::Object* clone(const osg::CopyOp& copyop) const { return 0; }        
25
26     FGPanel* getPanel() { return _panel; }
27
28     virtual void drawImplementation(osg::RenderInfo& renderInfo) const
29     { drawImplementation(*renderInfo.getState()); }
30   
31     void drawImplementation(osg::State& state) const;
32     virtual osg::BoundingBox computeBound() const;
33
34     /** Return true, FGPanelNode does support accept(PrimitiveFunctor&). */
35     virtual bool supports(const osg::PrimitiveFunctor&) const { return true; }
36   
37     virtual void accept(osg::PrimitiveFunctor& functor) const;
38   
39     static osg::Node* load(SGPropertyNode *n);
40     static osg::Node* createNode(FGPanel* panel);
41   
42     osg::Matrix transformMatrix() const;
43   
44 private:
45     void initWithPanel();
46     
47     SGSharedPtr<FGPanel> _panel;
48   
49     bool _resizeToViewport;
50
51     // Panel corner coordinates
52     osg::Vec3 _bottomLeft, _topLeft, _bottomRight;
53
54     int _xmin, _ymin, _xmax, _ymax;
55   
56     // The matrix that results, which transforms 2D x/y panel
57     // coordinates into 3D coordinates of the panel quadrilateral.
58     osg::Matrix _xform;  
59 };
60
61
62 #endif // FG_PANELNODE_HXX