Changeset 8833

Show
Ignore:
Timestamp:
09/06/08 00:18:56
Author:
jeremymoles
Message:

Added methods to WindowManager? (::localXY, ::windowXY) to convert between
application window and WindowManager? coordinates. This lets us setup
CL_SCISSOR easier in the Window::update() method, although I had to also
introduce WindowManager?::setWindowSize() to accomodate this. At any rate,
being able to determine the difference between osgWidget's WindowManager? size
and the REAL application Window size is going to be very important.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/examples/osgwidgetwindow/osgwidgetwindow.cpp

    r8778 r8833  
    163163        // std::cout << *box << std::endl << *boxCopy << std::endl; 
    164164 
    165         // Add our event handler; is this better as a MatrixManipulator? Add a few other 
    166         // helpful ViewerEventHandlers. 
    167         viewer.addEventHandler(new osgWidget::MouseHandler(wm)); 
    168         viewer.addEventHandler(new osgWidget::KeyboardHandler(wm)); 
    169         viewer.addEventHandler(new osgViewer::StatsHandler()); 
    170         viewer.addEventHandler(new osgViewer::WindowSizeHandler()); 
    171         viewer.addEventHandler(new osgGA::StateSetManipulator( 
    172                 viewer.getCamera()->getOrCreateStateSet() 
    173         )); 
    174  
    175165        // Setup our OSG objects for our scene; note the use of the utility function 
    176166        // createOrthoCamera, which is just a helper for setting up a proper viewing area. 
     
    183173        osg::Node*   model  = osgDB::readNodeFile("cow.osg"); 
    184174 
     175        // Add our event handler; is this better as a MatrixManipulator? Add a few other 
     176        // helpful ViewerEventHandlers. 
     177        viewer.addEventHandler(new osgWidget::MouseHandler(wm)); 
     178        viewer.addEventHandler(new osgWidget::KeyboardHandler(wm)); 
     179        viewer.addEventHandler(new osgWidget::ResizeHandler(wm, camera, false)); 
     180        viewer.addEventHandler(new osgViewer::StatsHandler()); 
     181        viewer.addEventHandler(new osgViewer::WindowSizeHandler()); 
     182        viewer.addEventHandler(new osgGA::StateSetManipulator( 
     183                viewer.getCamera()->getOrCreateStateSet() 
     184        )); 
     185 
    185186        // Set our first non-UI node to be something other than the mask we created our 
    186187        // WindowManager with to avoid picking. 
  • OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/include/osgWidget/WindowManager

    r8693 r8833  
    9292        void resizeAllWindows (bool = true); 
    9393 
     94        XYCoord windowXY (double, double) const; 
     95        XYCoord localXY  (double, double) const; 
     96 
    9497        // Methods all called by the ViewerEventHandlers::MouseHandler object, or 
    9598        // by some customer caller of your own. Examples of this to come... 
     
    242245            _height = h; 
    243246        } 
     247 
     248        void setWindowSize(point_type w, point_type h) { 
     249            _windowWidth  = w; 
     250            _windowHeight = h; 
     251        } 
    244252 
    245253        // Wrappers around the real calls. These only pertains to mouse buttons,  
     
    285293        point_type         _width; 
    286294        point_type         _height; 
     295        point_type         _windowWidth; 
     296        point_type         _windowHeight; 
    287297        point_type         _zNear; 
    288298        point_type         _zFar; 
  • OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/ViewerEventHandlers.cpp

    r8829 r8833  
    182182 
    183183        else _camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0f, w, 0.0f, h)); 
     184 
     185        _wm->setSize(w, h); 
    184186    } 
    185187     
    186     _wm->setSize(w, h); 
     188    _wm->setWindowSize(w, h); 
    187189    _wm->resizeAllWindows(); 
    188190 
  • OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/Window.cpp

    r8831 r8833  
    373373        } 
    374374 
    375         _scissor()->setScissor(nx, ny, nw, nh); 
     375        XYCoord sOrigin = _wm->windowXY(nx, ny); 
     376        XYCoord sSize   = _wm->windowXY(nw, nh); 
     377 
     378        _scissor()->setScissor(sOrigin.x(), sOrigin.y(), sSize.x(), sSize.y()); 
    376379    } 
    377380} 
  • OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/WindowManager.cpp

    r8829 r8833  
    2424_width          (width), 
    2525_height         (height), 
     26_windowWidth    (width), 
     27_windowHeight   (height), 
    2628_zNear          (0.0f), 
    2729_zFar           (-1.0f), 
     
    457459} 
    458460 
     461// Returns the application window coordinates of the WindowManager XY position. 
     462XYCoord WindowManager::windowXY(double x, double y) const { 
     463    return XYCoord((_windowWidth / _width) * x, (_windowHeight / _height) * y); 
     464} 
     465 
     466// Returns the WindowManager coordinates of the application window XY position. 
     467XYCoord WindowManager::localXY(double x, double y) const { 
     468    return XYCoord((_width / _windowWidth) * x, (_height / _windowHeight) * y); 
     469} 
     470 
    459471// This is called by a ViewerEventHandler/MouseHandler (or whatever) as the pointer moves 
    460472// around and intersects with objects. It also resets our state data (_widget, _leftDown,