osgEarth 2.1.1
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends

osgEarth::Util::Controls::ControlNode Class Reference

Collaboration diagram for osgEarth::Util::Controls::ControlNode:

List of all members.

Classes

struct  PerViewData

Public Member Functions

 ControlNode (Control *control, float priority=0.0f)
ControlgetControl () const
float getPriority () const
optional< osg::Vec2f > & anchorPoint ()
const optional< osg::Vec2f > & anchorPoint () const
virtual void traverse (osg::NodeVisitor &nv)
virtual osg::BoundingSphere computeBound () const

Protected Types

typedef std::map< osg::View
*, PerViewData
PerViewDataMap

Protected Member Functions

PerViewDatagetData (osg::View *view)

Protected Attributes

PerViewDataMap _perViewData
osg::ref_ptr< Control_control
float _priority
optional< osg::Vec2f > _anchor

Friends

class ControlNodeBin

Detailed Description

A control wrapped in a node that you can place anywhere in the scene graph. Its scene location will control its 2D screen position, and it can participate in conflict resolution.

Definition at line 571 of file Controls.


Member Typedef Documentation

typedef std::map<osg::View*,PerViewData> osgEarth::Util::Controls::ControlNode::PerViewDataMap [protected]

Definition at line 606 of file Controls.


Constructor & Destructor Documentation

ControlNode::ControlNode ( Control control,
float  priority = 0.0f 
)

Constructs a new control node with an embedded control.

Definition at line 1809 of file Controls.cpp.

                                                           :
_control ( control ),
_priority( priority )
{
    setCullingActive( false );
}

Member Function Documentation

optional<osg::Vec2f>& osgEarth::Util::Controls::ControlNode::anchorPoint ( ) [inline]

The point (in screen-space, relative to the lower-left of the control) that should anchor to the scene

Definition at line 584 of file Controls.

{ return _anchor; }

Here is the caller graph for this function:

const optional<osg::Vec2f>& osgEarth::Util::Controls::ControlNode::anchorPoint ( ) const [inline]

Definition at line 585 of file Controls.

{ return _anchor; }
osg::BoundingSphere ControlNode::computeBound ( ) const [virtual]

Definition at line 1817 of file Controls.cpp.

{
    return osg::BoundingSphere( osg::Vec3(0,0,0), 0.5 );
}
Control* osgEarth::Util::Controls::ControlNode::getControl ( ) const [inline]

The control encaspulated in this node

Definition at line 578 of file Controls.

{ return _control.get(); }

Here is the caller graph for this function:

PerViewData& osgEarth::Util::Controls::ControlNode::getData ( osg::View *  view) [inline, protected]

Definition at line 613 of file Controls.

{ return _perViewData[view]; }

Here is the caller graph for this function:

float osgEarth::Util::Controls::ControlNode::getPriority ( ) const [inline]

The draw priority of this control

Definition at line 581 of file Controls.

{ return _priority; }

Here is the caller graph for this function:

void ControlNode::traverse ( osg::NodeVisitor &  nv) [virtual]

Definition at line 1823 of file Controls.cpp.

{
    if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
    {
        static osg::Vec3d s_zero(0,0,0);
        static osg::Vec4d s_zero_w(0,0,0,1);
        osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>( &nv );

        //setCullingActive( true );
        //cv->setSmallFeatureCullingPixelSize(0);

        // pull up the per-view data for this view:
        PerViewData& data = _perViewData[cv->getCurrentCamera()->getView()];

        // if it's uninitialized, find the corresponding control canvas and 
        // cache a reference to its control node bin:
        if ( !data._canvas.valid() )
        {
            data._canvas = ControlCanvas::get( cv->getCurrentCamera()->getView(), true );
            if ( data._canvas.valid() )
            {
                ControlNodeBin* bin = static_cast<ControlCanvas*>(data._canvas.get())->getControlNodeBin();
                bin->addNode( this );
            }
        }

        if ( data._canvas.valid() )
        {
            // calculate its screen position:
            //data._screenPos = s_zero * (*cv->getMVPW());

            osg::Vec4d clip = s_zero_w * (*cv->getModelViewMatrix()) * (*cv->getProjectionMatrix());
            osg::Vec3d clip_ndc( clip.x()/clip.w(), clip.y()/clip.w(), clip.z()/clip.w() );
            data._screenPos = clip_ndc * cv->getWindowMatrix();

            if ( clip_ndc.z() > 1.0 ) // node is behind the near clip plane
            {
                data._obscured = true;
            }
            else if ( data._obscured == true )
            {
                data._obscured = false;
                data._visibleTime = cv->getFrameStamp()->getReferenceTime();
            }
        }

        data._visitFrame = cv->getFrameStamp()->getFrameNumber();
    }

    // ControlNode has no children, so no point in calling traverse.
    osg::Node::traverse(nv);
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class ControlNodeBin [friend]

Definition at line 615 of file Controls.


Member Data Documentation

Definition at line 611 of file Controls.

Definition at line 609 of file Controls.

Definition at line 608 of file Controls.

Definition at line 610 of file Controls.


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