QWidgetImage 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef QWIDGETIMAGE
  14. #define QWIDGETIMAGE
  15. #include <osgQt/QGraphicsViewAdapter>
  16. #include <osg/Image>
  17. namespace osgQt
  18. {
  19. class OSGQT_EXPORT QWidgetImage : public osg::Image
  20. {
  21. public:
  22. QWidgetImage( QWidget* widget=0 );
  23. QWidget* getQWidget() { return _widget; }
  24. QGraphicsViewAdapter* getQGraphicsViewAdapter() { return _adapter; }
  25. virtual bool requiresUpdateCall() const { return true; }
  26. virtual void update( osg::NodeVisitor* /*nv*/ ) { render(); }
  27. void clearWriteBuffer();
  28. void render();
  29. /// Overridden scaleImage used to catch cases where the image is
  30. /// fullscreen and the window is resized.
  31. virtual void scaleImage(int s,int t,int r, GLenum newDataType);
  32. virtual bool sendFocusHint(bool focus);
  33. virtual bool sendPointerEvent(int x, int y, int buttonMask);
  34. virtual bool sendKeyEvent(int key, bool keyDown);
  35. virtual void setFrameLastRendered(const osg::FrameStamp* frameStamp);
  36. protected:
  37. QPointer<QGraphicsViewAdapter> _adapter;
  38. QPointer<QWidget> _widget;
  39. };
  40. }
  41. #endif