myInteractor(QtRenderWindowInteractor::New())
{
myInteractor->Delete();
+
+ setMouseTracking(true);
}
::SetRenderWindow(vtkRenderWindow *theRenderWindow)
{
myInteractor->SetRenderWindow(theRenderWindow);
-#ifndef WNT
- theRenderWindow->SetDisplayId((void*)x11Display());
-#endif
- theRenderWindow->SetWindowId((void*)winId());
theRenderWindow->DoubleBufferOn();
- setMouseTracking(true);
-
- // To avoid UnbindContext: Assertion `vb.context == ctx' failed
- // Initialize();
}
vtkRenderWindow*
//----------------------------------------------------------------------------
void
QVTK_RenderWindowInteractor
-::Initialize()
+::InvokeEvent(unsigned long theEvent, void* theCallData)
{
- myInteractor->Initialize();
+ myInteractor->InvokeEvent(theEvent,theCallData);
}
//----------------------------------------------------------------------------
void
QVTK_RenderWindowInteractor
-::InvokeEvent(unsigned long theEvent, void* theCallData)
+::show()
{
- myInteractor->InvokeEvent(theEvent,theCallData);
+ QWidget::show();
+ update(); // needed for initial contents display on Win32
}
//----------------------------------------------------------------------------
void
QVTK_RenderWindowInteractor
-::UpdateSize(int w, int h)
+::polish()
+{
+ // Final initialization just before the widget is displayed.
+ myInteractor->SetSize(width(),height());
+#ifndef WNT
+ GetRenderWindow()->SetDisplayId((void*)x11Display());
+#endif
+ GetRenderWindow()->SetWindowId((void*)winId());
+ myInteractor->Enable();
+ myInteractor->ConfigureEvent();
+}
+
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::resize(int w, int h)
{
myInteractor->UpdateSize(w,h);
}
QVTK_RenderWindowInteractor
::paintEvent( QPaintEvent* theEvent )
{
- myInteractor->Render();
+ if(myInteractor->GetEnabled()){
+ if(!myInteractor->GetInitialized())
+ myInteractor->Initialize();
+ else
+ myInteractor->Render();
+ }
}
int aWidth = aSize[0];
int aHeight = aSize[1];
- UpdateSize( width(), height() );
+ //myInteractor->SetSize(width(),height());
+ myInteractor->UpdateSize(width(),height());
+ myInteractor->ConfigureEvent();
if( aWidth != width() || aHeight != height() )
{
aCamera->SetParallelScale(aScale*aCoeff);
}
}
+
+ update();
}
vtkRenderWindow*
GetRenderWindow();
- // Description:
- // Initializes the event handlers without an XtAppContext. This is
- // good for when you don`t have a user interface, but you still
- // want to have mouse interaction.
- void
- Initialize();
-
virtual
void
InvokeEvent(unsigned long theEvent, void* theCallData);
- // Description:
- // Event loop notification member for Window size change
- virtual
- void
- UpdateSize(int x,int y);
+ public slots:
+ virtual void show();
+ virtual void polish();
+ virtual void resize(int w, int h);
protected:
virtual void paintEvent( QPaintEvent* );
myInteractor = theInteractor;
if(myInteractor){
- myInteractor->SetRenderWindow(myRenderWindow.GetPointer());
-
connect(myInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
this,SIGNAL(KeyPressed(QKeyEvent*)) );
connect(myInteractor,SIGNAL(KeyReleased(QKeyEvent*)),
myInteractor->setFocusPolicy(StrongFocus);
myInteractor->setFocus();
setFocusProxy(myInteractor);
+
+ myInteractor->SetRenderWindow(myRenderWindow.GetPointer());
}
}
myInteractor->InvokeEvent(theEvent,theCallData);
}
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorHolder
-::Initialize()
-{
- myInteractor->Initialize();
-}
-
//----------------------------------------------------------------------------
void
SVTK_InteractorHolder