00001 //------------------------------------------------------------------------ 00002 // 00003 // Joe Kniss 00004 // 8-29-02 00005 // ________ ____ ___ 00006 // | \ / | / / 00007 // +---+ \/ |/ / 00008 // +--+| |\ /| < 00009 // | || | \ / | |\ \ 00010 // | | \/ | | \ \ 00011 // \_____| |__| \__\ 00012 // Copyright 2001 00013 // Joe Michael Kniss 00014 // <<< jmk@cs.utah.edu >>> 00015 // "All Your Base are Belong to Us" 00016 //------------------------------------------------------------------------- 00017 00018 /////////////////////////////////////////////////////////////////////////// 00019 /// A BasicQGL that knows about renderables. 00020 00021 #ifndef __RENDERABLE_QGL_DOT_H 00022 #define __RENDERABLE_QGL_DOT_H 00023 00024 #include "BasicQGL.h" 00025 #include <renderable/Renderable.h> 00026 #include <widget/WidgetBase.h> 00027 00028 //////////////////////////////////////////////////////////////////////////// 00029 //////////////////////////////////////////////////////////////////////////// 00030 /// Renderable QT openGl class 00031 //////////////////////////////////////////////////////////////////////////// 00032 //////////////////////////////////////////////////////////////////////////// 00033 00034 class RenderableQGL : public BasicQGL 00035 { 00036 Q_OBJECT 00037 public: 00038 RenderableQGL(QWidget *parent=0, const char *name=0); 00039 virtual ~RenderableQGL(); 00040 00041 //////////////////////////////////////// 00042 ///@name Get/Set/Del Renderables 00043 ///@{ 00044 virtual void addRenderable(Renderable *r); 00045 virtual Renderable *getRenderable(unsigned int i); 00046 virtual void delRenderable(unsigned int i); 00047 virtual void delRenderable(Renderable *r); 00048 00049 virtual RenderableVec getRenderables() const; 00050 virtual void setRenderables(RenderableVec &v); 00051 ///@} 00052 //////////////////////////////////////// 00053 00054 protected: 00055 00056 ///@name events from BasicQGL 00057 ///@{ 00058 virtual void mouseMoveEvent( QMouseEvent * e); 00059 virtual void mousePressEvent( QMouseEvent * e); 00060 virtual void mouseReleaseEvent ( QMouseEvent * e ); 00061 virtual void mouseDoubleClickEvent ( QMouseEvent *e ); 00062 ///@} 00063 00064 protected: 00065 00066 ////////////////////////////////////////////////////// 00067 /// overide this draw function to implement new 00068 /// behaviors in subclasses 00069 virtual void draw(); 00070 00071 ////////////////////////////////////////////////////// 00072 /// pick (GL style) a renderable or widget 00073 /// returns true if something was picked, false otherwize 00074 /// also sets the picked object... 00075 /// TODO: unify renderables and widgets... done 00076 virtual bool pickGL(gutz::MouseEventSP me); 00077 /// casts the picked object (renderable or widget right now) 00078 /// to the right thing based on the name identifier 00079 virtual bool castPick(unsigned int name, unsigned int ptr); 00080 00081 ///////////////////////////////////////////////////////// 00082 /// call this one to simply cycle through the renderables 00083 /// calling draw on each one. 00084 virtual void drawRenderables(); 00085 00086 RenderableVec _rens; ///< all renderables 00087 00088 bool _picking; 00089 RenderableSP _picked; 00090 00091 00092 private: 00093 gutz::MouseEventSP _curMouse; 00094 gutz::MouseMoveEventSP _curMove; 00095 }; 00096 00097 00098 #endif 00099