Changeset 8833
- Timestamp:
- 09/06/08 00:18:56
- Files:
-
- OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/examples/osgwidgetwindow/osgwidgetwindow.cpp (modified) (2 diffs)
- OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/include/osgWidget/WindowManager (modified) (3 diffs)
- OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/ViewerEventHandlers.cpp (modified) (1 diff)
- OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/Window.cpp (modified) (1 diff)
- OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/WindowManager.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/examples/osgwidgetwindow/osgwidgetwindow.cpp
r8778 r8833 163 163 // std::cout << *box << std::endl << *boxCopy << std::endl; 164 164 165 // Add our event handler; is this better as a MatrixManipulator? Add a few other166 // 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 175 165 // Setup our OSG objects for our scene; note the use of the utility function 176 166 // createOrthoCamera, which is just a helper for setting up a proper viewing area. … … 183 173 osg::Node* model = osgDB::readNodeFile("cow.osg"); 184 174 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 185 186 // Set our first non-UI node to be something other than the mask we created our 186 187 // WindowManager with to avoid picking. OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/include/osgWidget/WindowManager
r8693 r8833 92 92 void resizeAllWindows (bool = true); 93 93 94 XYCoord windowXY (double, double) const; 95 XYCoord localXY (double, double) const; 96 94 97 // Methods all called by the ViewerEventHandlers::MouseHandler object, or 95 98 // by some customer caller of your own. Examples of this to come... … … 242 245 _height = h; 243 246 } 247 248 void setWindowSize(point_type w, point_type h) { 249 _windowWidth = w; 250 _windowHeight = h; 251 } 244 252 245 253 // Wrappers around the real calls. These only pertains to mouse buttons, … … 285 293 point_type _width; 286 294 point_type _height; 295 point_type _windowWidth; 296 point_type _windowHeight; 287 297 point_type _zNear; 288 298 point_type _zFar; OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/ViewerEventHandlers.cpp
r8829 r8833 182 182 183 183 else _camera->setProjectionMatrix(osg::Matrix::ortho2D(0.0f, w, 0.0f, h)); 184 185 _wm->setSize(w, h); 184 186 } 185 187 186 _wm->set Size(w, h);188 _wm->setWindowSize(w, h); 187 189 _wm->resizeAllWindows(); 188 190 OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/Window.cpp
r8831 r8833 373 373 } 374 374 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()); 376 379 } 377 380 } OpenSceneGraph/branches/OpenSceneGraph-osgWidget-dev/src/osgWidget/WindowManager.cpp
r8829 r8833 24 24 _width (width), 25 25 _height (height), 26 _windowWidth (width), 27 _windowHeight (height), 26 28 _zNear (0.0f), 27 29 _zFar (-1.0f), … … 457 459 } 458 460 461 // Returns the application window coordinates of the WindowManager XY position. 462 XYCoord 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. 467 XYCoord WindowManager::localXY(double x, double y) const { 468 return XYCoord((_width / _windowWidth) * x, (_height / _windowHeight) * y); 469 } 470 459 471 // This is called by a ViewerEventHandler/MouseHandler (or whatever) as the pointer moves 460 472 // around and intersects with objects. It also resets our state data (_widget, _leftDown,
