Commit f1324f7b authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri 💬
Browse files

Allow widgets to change cursor when using QVTKOpenGLWindow

parent 67efbc03
......@@ -156,6 +156,7 @@ void QVTKOpenGLWindow::SetRenderWindow(vtkGenericOpenGLRenderWindow* w)
this->EventSlotConnector->Connect(this->RenderWindow, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*)));
this->EventSlotConnector->Connect(this->RenderWindow, vtkCommand::WindowStereoTypeChangedEvent, this, SLOT(UpdateStereoType(vtkObject*, unsigned long, void*, void*)));
this->EventSlotConnector->Connect(this->RenderWindow, vtkCommand::WindowResizeEvent, this, SLOT(ResizeToVTKWindow()));
this->EventSlotConnector->Connect(this->RenderWindow, vtkCommand::CursorChangedEvent, this, SLOT(ChangeCursor(vtkObject*, unsigned long, void*, void*)));
}
//-----------------------------------------------------------------------------
......@@ -571,3 +572,56 @@ bool QVTKOpenGLWindow::isCurrent()
return QOpenGLContext::currentContext() == this->context();
}
//-----------------------------------------------------------------------------
void QVTKOpenGLWindow::ChangeCursor(vtkObject*, unsigned long, void*,
void* call_data)
{
if (!this->RenderWindow)
{
return;
}
int* cShape = reinterpret_cast<int*> (call_data);
if (!cShape)
{
return;
}
switch (*cShape)
{
case VTK_CURSOR_CROSSHAIR:
this->setCursor(QCursor(Qt::CrossCursor));
break;
case VTK_CURSOR_ARROW:
this->setCursor(QCursor(Qt::ArrowCursor));
break;
case VTK_CURSOR_SIZEALL:
this->setCursor(QCursor(Qt::SizeAllCursor));
break;
case VTK_CURSOR_SIZENS:
this->setCursor(QCursor(Qt::SizeVerCursor));
break;
case VTK_CURSOR_SIZEWE:
this->setCursor(QCursor(Qt::SizeHorCursor));
break;
case VTK_CURSOR_SIZENE:
this->setCursor(QCursor(Qt::SizeBDiagCursor));
break;
case VTK_CURSOR_SIZENW:
this->setCursor(QCursor(Qt::SizeFDiagCursor));
break;
case VTK_CURSOR_SIZESE:
this->setCursor(QCursor(Qt::SizeFDiagCursor));
break;
case VTK_CURSOR_SIZESW:
this->setCursor(QCursor(Qt::SizeBDiagCursor));
break;
case VTK_CURSOR_HAND:
this->setCursor(QCursor(Qt::PointingHandCursor));
break;
default:
this->setCursor(QCursor(Qt::ArrowCursor));
break;
}
}
......@@ -188,6 +188,12 @@ public slots:
virtual void UpdateStereoType(vtkObject* caller, unsigned long vtk_event,
void* client_data, void* call_data);
/*
* slot to change the cursor
*/
virtual void ChangeCursor(vtkObject* caller, unsigned long vtk_event,
void* client_data, void* call_data);
/**
* slot to process events coming from the widget containing this window
*/
......
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