[vtkusers] Detect which QVTKWidget I am interacting with

girault girault at email.unc.edu
Fri Jul 19 10:26:46 EDT 2013


Hello,

I am a french intern at UNC, Department of Psychiatry, working on a software
which should be able to visualize and compare surfaces using VTK and QT. i
have been working with VTK for the last two weeks only, so I am a total
rookie right now, therefore please do not hesitate to give me advices if I
am making any mistakes.

In order to visualize multiple meshes, i created a new QVTKWidget for each
renderer I had created from my meshes. I append those Widgets in a (
QVector<QVTKWidget *> *widgetList ) so that i can access all of them
whenever needed (when i have to resize them for example) : 

/
      QVTKWidget *meshWidget = new
QVTKWidget(this->scrollAreaWidgetContents);
      this->widgetList->append(meshWidget);
      meshWidget->GetRenderWindow()->AddRenderer(renderer);
/

I was able to display them pretty well : http://bit.ly/1ax9Cqa

*
Right now I would like to tell which one I am interacting with, so that I
can work only on meshes i would select.
I guess the best would be to get their number in the widgetList, since it's
the most easiest thing i can access.
*

So here is was i thought I could do :

*1- I already was able to synchronize them by setting their active camera to
one main camera ( vtkCamera * headcam ), and bu using AddObserver, which
will call back anytime a mesh is rendering ModifiedHandler(), which will
just render every renderWindow :*

/
      for (int i = 0; i < this->widgetList->size(); i++)
      {
          //connect to headcam for synchro
         
this->widgetList->value(i)->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetActiveCamera(headcam);

          //syncronize when rendering
         
this->widgetList->value(i)->GetRenderWindow()->RemoveAllObservers();
         
this->widgetList->value(i)->GetRenderWindow()->AddObserver(vtkCommand::RenderEvent,
this, &ShapePopulationViewer::ModifiedHandler);
      }
/

Therefore i tried to add an observer to my widget Interactor but I could
just call a function without parameters, so i can't get this "i" back.


*2- I also have connections between signals and slots like this, were
"actionOpen_vtk_Files" is a QAction in my GUI menu :*

/
     
connect(this->actionOpen_vtk_Files,SIGNAL(triggered()),this,SLOT(openVTKS()));

Therefore I thought I could also connect a widget to a function using the
"i" :
      for (int i = 0; i < this->widgetList->size(); i++)
      {
           
this->connect((this->widgetList->value(i)),SIGNAL(mousePressEvent),this,SLOT(SelectedWidget(i)));
      }
/

But when it tries to connect, I have this message :

/
      Object::connect: Parentheses expected, signal
QVTKWidget::mousePressEvent in
/home/girault/ShapePopulationViewer/code/ShapePopulationViewer-master/ShapePopulationViewer.cxx:316
      Object::connect:  (receiver name: 'ShapePopulationViewer')
/

Does someone knows if I am heading in the right direction? If yes how could
I make this connection? If not do you know a better way?
PS : my first idea is to select only one by just clicking on it, an
improvement would be to select multiples one using Ctrl+ClicLeft

Thanks a lot for your time.
Alexis Girault.



--
View this message in context: http://vtk.1045678.n5.nabble.com/Detect-which-QVTKWidget-I-am-interacting-with-tp5722074.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list