<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3627" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009>Hi!</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>I am trying to get
signal and slot work with QVTK. I have 2 threads, one to compute and one to do
the rendering. When the compute thread sends a signal, I want this one to be
picked up in order to update the scene. In my visualisation widget I call
initialView which creates a sphere. The result is that as the compute threads is
running, the sphere is being rendered. However, When a signal is emited, this
one is not picked up. If I replace initialView with another member which does
nothing, the signal is being delivered. So my guess is that the vtkRenderWindow
is overwritting my original Widget, perhaps with a different eventloop...
In fact, the window title is even reset to 'Visualisation toolkit - openGL" when
I use initialView, whereas I get the correct Window title that I set in the
constructor when I use the empty member... but with nothing in the
window.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>Could anyone tell me
what I am doing wrong? </SPAN></FONT><FONT face=Arial size=2><SPAN
class=259541514-25112009>I guess the best thing is to give some lines of
codes...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>Best
Regards,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>
-Pierre.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009>main.cpp:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2>#include <QApplication></FONT></DIV>
<DIV><FONT face=Arial size=2>#include "MyWidget.h"</FONT></DIV>
<DIV><FONT face=Arial size=2>int main(int argc, char* argv[])<BR>{<BR>
QApplication app(argc, argv);<BR> MyWidget* widget;<BR> widget = new
MyWidget(argc, argv);<BR> widget->show();</FONT></DIV>
<DIV><FONT face=Arial><FONT size=2> return app.exec();<BR>}<BR><SPAN
class=259541514-25112009>-----------------------------------------------------------------------------</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009>MyWidget.h</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>#include
<QWidget><BR>#include <QVTKWidget.h></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>#include
"computethread.h"</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>class MyWidget :
public QVTKWidget<BR>{<BR> Q_OBJECT</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009> public:<BR> MyWidget(int argc, char **argv,
QVTKWidget *parent = 0);<BR> QSize minimumSizeHint() const;<BR>
QSize sizeHint() const;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>private
slots:<BR> void updateView();</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>private:<BR>
ComputeThread* thread;<BR> void initialView();<BR> void
initialView2();</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009> QVTKWidget
*vtkwidget;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>};<BR><SPAN
class=259541514-25112009>-----------------------------------------------------------------------------</SPAN></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009>MyWidget.cpp</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=259541514-25112009>MyWidget::MyWidget(int argc, char **argv, QVTKWidget
*parent) : QVTKWidget(parent)<BR>{</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009> // start
compute thread<BR> thread = new
ComputeThread(argc,argv);</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>
thread->start(); </SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>
initialView();<BR> setWindowTitle(tr("Visualization Window -
v0.1"));<BR> resize(400, 300);<BR> connect(thread,
SIGNAL(computeStuff()), this, SLOT(updateView()));</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>}<BR>void
MyWidget::initialView2()<BR>{<BR>}<BR>void
MyWidget::initialView()<BR>{<BR> //create a rendering window and
renderer<BR> vtkRenderer *ren = vtkRenderer::New();<BR>
vtkRenderWindow *renderWindow = vtkRenderWindow::New();<BR>
renderWindow->AddRenderer( ren );<BR> renderWindow->SetSize( 500,
500 );</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009> //Create a
window interactor<BR> vtkRenderWindowInteractor *interactor =
vtkRenderWindowInteractor::New();<BR> interactor->SetRenderWindow(
renderWindow );</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009> //create and
actor and give it ball geometry</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>
vtkSphereSource* Sphere = vtkSphereSource::New();<BR>
Sphere->SetCenter(0.0, 0.0, 0.0);<BR>
Sphere->SetRadius(5.0);<BR> <BR> //create a mapper<BR>
vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New();<BR>
Mapper->SetInput(Sphere->GetOutput());<BR> <BR> // create an
actor<BR> vtkActor *Actor = vtkActor::New();<BR>
Actor->SetMapper(Mapper);<BR> // sphere color blue<BR>
Actor->GetProperty()->SetColor(0,0,1);</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009> //assign our
actor to the renderer<BR> ren->AddActor(Actor);</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>
renderWindow->AddRenderer(ren);</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009> //render the
scene and start the interactor<BR> renderWindow->Render();<BR>
interactor->Start();</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=259541514-25112009>
vtkwidget->SetRenderWindow(renderWindow);<BR>
renderWindow->Delete();<BR>}<BR></SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV> <br>
********************************************************************<br>
This email and any attachments are confidential to the intended<br>
recipient and may also be privileged. If you are not the intended<br>
recipient please delete it from your system and notify the sender.<br>
You should not copy it or use it for any purpose nor disclose or<br>
distribute its contents to any other person.<br>
********************************************************************<br>
<br>
</body></HTML>