osgEarth 2.1.1
Public Member Functions | Public Attributes

osgEarth::Util::Controls::ViewportHandler Struct Reference

Collaboration diagram for osgEarth::Util::Controls::ViewportHandler:

List of all members.

Public Member Functions

 ViewportHandler (ControlCanvas *cs)
bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)

Public Attributes

ControlCanvas_cs
int _width
int _height
bool _first

Detailed Description

Definition at line 1711 of file Controls.cpp.


Constructor & Destructor Documentation

osgEarth::Util::Controls::ViewportHandler::ViewportHandler ( ControlCanvas cs) [inline]

Definition at line 1713 of file Controls.cpp.

: _cs(cs), _width(0), _height(0), _first(true) { }

Member Function Documentation

bool osgEarth::Util::Controls::ViewportHandler::handle ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
) [inline]

Definition at line 1715 of file Controls.cpp.

        {
            if ( ea.getEventType() == osgGA::GUIEventAdapter::RESIZE || _first )
            {
                osg::Camera* cam = aa.asView()->getCamera();
                if ( cam && cam->getViewport() )
                {
                    const osg::Viewport* vp = cam->getViewport();
                    if ( _first || vp->width() != _width || vp->height() != _height )
                    {
                        _cs->setProjectionMatrix(osg::Matrix::ortho2D( 0, vp->width()-1, 0, vp->height()-1 ) );

                        ControlContext cx;
                        cx._view = aa.asView();
                        cx._vp = new osg::Viewport( 0, 0, vp->width(), vp->height() );
                        cx._viewContextID = aa.asView()->getCamera()->getGraphicsContext()->getState()->getContextID();
                        _cs->setControlContext( cx );

                        _width  = (int)vp->width();
                        _height = (int)vp->height();
                    }
                    if ( vp->width() != 0 && vp->height() != 0 )
                    {
                        _first = false;
                    }
                }
            }
            return false;
        }

Here is the call graph for this function:


Member Data Documentation

Definition at line 1744 of file Controls.cpp.

Definition at line 1746 of file Controls.cpp.

Definition at line 1745 of file Controls.cpp.

Definition at line 1745 of file Controls.cpp.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines