Show
Ignore:
Timestamp:
07/24/14 16:14:35 (19 hours ago)
Author:
robert
Message:

Added support for changing background colour of LineEdit? widget when focus changes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgViewer/ViewerEventHandlers.cpp

    r13245 r13376  
    717717} 
    718718 
    719 bool InteractiveImageHandler::computeIntersections(osgViewer::View* view, float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask) const 
    720 { 
    721     float local_x, local_y = 0.0; 
    722     const osg::Camera* camera; 
    723     if (_fullscreen) 
    724     { 
    725         if (!_camera) return false; 
    726         camera = _camera.get(); 
    727         local_x = x; 
    728         local_y = y; 
    729     } 
    730     else 
    731     { 
    732         if (!view->getCamera() || nodePath.empty()) return false; 
    733         camera = view->getCameraContainingPosition(x, y, local_x, local_y); 
    734         if (!camera) camera = view->getCamera(); 
    735     } 
    736  
    737     osg::ref_ptr< osgUtil::LineSegmentIntersector > picker; 
    738     if (_fullscreen) 
    739     { 
    740         picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, local_x, local_y); 
    741     } 
    742     else 
    743     { 
    744         osg::Matrixd matrix; 
    745         if (nodePath.size()>1) 
    746         { 
    747             osg::NodePath prunedNodePath(nodePath.begin(),nodePath.end()-1); 
    748             matrix = osg::computeLocalToWorld(prunedNodePath); 
    749         } 
    750  
    751         matrix.postMult(camera->getViewMatrix()); 
    752         matrix.postMult(camera->getProjectionMatrix()); 
    753  
    754         double zNear = -1.0; 
    755         double zFar = 1.0; 
    756         if (camera->getViewport()) 
    757         { 
    758             matrix.postMult(camera->getViewport()->computeWindowMatrix()); 
    759             zNear = 0.0; 
    760             zFar = 1.0; 
    761         } 
    762  
    763         osg::Matrixd inverse; 
    764         inverse.invert(matrix); 
    765  
    766         osg::Vec3d startVertex = osg::Vec3d(local_x,local_y,zNear) * inverse; 
    767         osg::Vec3d endVertex = osg::Vec3d(local_x,local_y,zFar) * inverse; 
    768  
    769         picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::MODEL, startVertex, endVertex); 
    770     } 
    771  
    772     osgUtil::IntersectionVisitor iv(picker.get()); 
    773     iv.setTraversalMask(traversalMask); 
    774  
    775     if (_fullscreen) 
    776     { 
    777         const_cast<osg::Camera*>(camera)->accept(iv); 
    778     } 
    779     else 
    780     { 
    781         nodePath.back()->accept(iv); 
    782     } 
    783  
    784     if (picker->containsIntersections()) 
    785     { 
    786         intersections = picker->getIntersections(); 
    787         return true; 
    788     } 
    789     else 
    790     { 
    791         intersections.clear(); 
    792         return false; 
    793     } 
    794 } 
    795  
    796719bool InteractiveImageHandler::mousePosition(osgViewer::View* view, osg::NodeVisitor* nv, const osgGA::GUIEventAdapter& ea, int& x, int &y) const 
    797720{ 
     721    if (!view) return false; 
     722     
    798723    osgUtil::LineSegmentIntersector::Intersections intersections; 
    799     bool foundIntersection = view==0 ? false : 
    800         (nv==0 ? view->computeIntersections(ea.getX(), ea.getY(), intersections) : 
    801                  //view->computeIntersections(ea.getX(), ea.getY(), nv->getNodePath(), intersections)); 
    802                  computeIntersections(view, ea.getX(), ea.getY(), nv->getNodePath(), intersections)); 
     724    bool foundIntersection = (nv==0) ? view->computeIntersections(ea, intersections) : 
     725                                       view->computeIntersections(ea, nv->getNodePath(), intersections); 
    803726 
    804727    if (foundIntersection)