Commit e8d8e2ae authored by Clinton Stimpson's avatar Clinton Stimpson

Add code to handle IsDirect() and SupportsOpenGL() in QVTKWidget2.

parent 3f59cbc0
......@@ -364,6 +364,8 @@ public:
WindowIsCurrentEvent,
WindowFrameEvent,
HighlightEvent,
WindowSupportsOpenGLEvent,
WindowIsDirectEvent,
UserEvent = 1000
};
//ETX
......
......@@ -64,6 +64,8 @@ void QVTKGraphicsItem::SetRenderWindow(vtkGenericOpenGLRenderWindow* win)
mConnect->Disconnect(mWin, vtkCommand::EndEvent, this, SLOT(End()));
mConnect->Disconnect(mWin, vtkCommand::WindowFrameEvent, this, SLOT(Update()));
mConnect->Disconnect(mWin, vtkCommand::WindowIsCurrentEvent, this, SLOT(IsCurrent(vtkObject*, unsigned long, void*, void*)));
mConnect->Disconnect(mWin, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*)));
mConnect->Disconnect(mWin, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*)));
}
mIren->SetRenderWindow(win);
......@@ -83,6 +85,8 @@ void QVTKGraphicsItem::SetRenderWindow(vtkGenericOpenGLRenderWindow* win)
mConnect->Connect(mWin, vtkCommand::EndEvent, this, SLOT(End()));
mConnect->Connect(mWin, vtkCommand::WindowFrameEvent, this, SLOT(Update()));
mConnect->Connect(mWin, vtkCommand::WindowIsCurrentEvent, this, SLOT(IsCurrent(vtkObject*, unsigned long, void*, void*)));
mConnect->Connect(mWin, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*)));
mConnect->Connect(mWin, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*)));
}
}
......@@ -155,6 +159,19 @@ void QVTKGraphicsItem::IsCurrent(vtkObject*, unsigned long, void*, void* call_da
}
}
void QVTKGraphicsItem::IsDirect(vtkObject*, unsigned long, void*, void* call_data)
{
int* ptr = reinterpret_cast<int*>(call_data);
*ptr = 1;
}
void QVTKGraphicsItem::SupportsOpenGL(vtkObject*, unsigned long, void*, void* call_data)
{
int* ptr = reinterpret_cast<int*>(call_data);
*ptr = QGLFormat::hasOpenGL();
}
#if QT_VERSION >= 0x040600
void QVTKGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*)
#else
......
......@@ -76,6 +76,10 @@ class QVTK_EXPORT QVTKGraphicsItem : public QGraphicsWidget
virtual void End();
// slot called when vtk wants to know if the context is current
virtual void IsCurrent(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
// slot called when vtk wants to know if a window is direct
virtual void IsDirect(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
// slot called when vtk wants to know if a window supports OpenGL
virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
protected:
......
......@@ -139,6 +139,8 @@ void QVTKWidget2::SetRenderWindow(vtkGenericOpenGLRenderWindow* w)
mConnect->Disconnect(mRenWin, vtkCommand::WindowFrameEvent, this, SLOT(Frame()));
mConnect->Disconnect(mRenWin, vtkCommand::StartEvent, this, SLOT(Start()));
mConnect->Disconnect(mRenWin, vtkCommand::EndEvent, this, SLOT(End()));
mConnect->Disconnect(mRenWin, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*)));
mConnect->Disconnect(mRenWin, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*)));
}
// now set the window
......@@ -178,6 +180,8 @@ void QVTKWidget2::SetRenderWindow(vtkGenericOpenGLRenderWindow* w)
mConnect->Connect(mRenWin, vtkCommand::WindowFrameEvent, this, SLOT(Frame()));
mConnect->Connect(mRenWin, vtkCommand::StartEvent, this, SLOT(Start()));
mConnect->Connect(mRenWin, vtkCommand::EndEvent, this, SLOT(End()));
mConnect->Connect(mRenWin, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*)));
mConnect->Connect(mRenWin, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*)));
}
}
......@@ -412,6 +416,18 @@ void QVTKWidget2::IsCurrent(vtkObject*, unsigned long, void*, void* call_data)
*ptr = QGLContext::currentContext() == this->context();
}
void QVTKWidget2::IsDirect(vtkObject*, unsigned long, void*, void* call_data)
{
int* ptr = reinterpret_cast<int*>(call_data);
*ptr = this->context()->format().directRendering();
}
void QVTKWidget2::SupportsOpenGL(vtkObject*, unsigned long, void*, void* call_data)
{
int* ptr = reinterpret_cast<int*>(call_data);
*ptr = QGLFormat::hasOpenGL();
}
void QVTKWidget2::Frame()
{
if(mRenWin->GetSwapBuffers())
......
......@@ -88,6 +88,10 @@ protected Q_SLOTS:
virtual void Start();
// slot called when vtk wants to end the render
virtual void End();
// slot called when vtk wants to know if a window is direct
virtual void IsDirect(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
// slot called when vtk wants to know if a window supports OpenGL
virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
protected:
// overloaded resize handler
......
......@@ -107,6 +107,20 @@ bool vtkGenericOpenGLRenderWindow::IsCurrent()
return current;
}
int vtkGenericOpenGLRenderWindow::SupportsOpenGL()
{
int supports_ogl = 0;
this->InvokeEvent(vtkCommand::WindowSupportsOpenGLEvent, &supports_ogl);
return supports_ogl;
}
int vtkGenericOpenGLRenderWindow::IsDirect()
{
int is_direct = 0;
this->InvokeEvent(vtkCommand::WindowIsDirectEvent, &is_direct);
return is_direct;
}
void vtkGenericOpenGLRenderWindow::PushState()
{
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
......
......@@ -53,6 +53,16 @@ public:
//! responsibility to watch for WindowIsCurrentEvent and set the bool* flag
//! passed through the call data parameter.
bool IsCurrent();
//! Returns if OpenGL is supported. It is the class user's
//! responsibility to watch for WindowSupportsOpenGLEvent and set the int* flag
//! passed through the call data parameter.
int SupportsOpenGL();
//! Returns if the context is direct. It is the class user's
//! responsibility to watch for WindowIsDirectEvent and set the int* flag
//! passed through the call data parameter.
int IsDirect();
// {@
//! set the drawing buffers to use
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment