[Paraview] Pthreads and Multiples render Windows.

Jan Palach palach16 at yahoo.com.br
Fri Jun 23 14:39:06 EDT 2006


Hi,

I have the following problem and I am wondering if someone could help 
me.

I'm implementing a specific Widget like a vtkXYPlotwidget but, the 
result should
be rendered on a separeted vtkRenderWindow instead of the ParaView's 
viewport.

I can implement the widget using one thread for each window and that 
window
doesn't block Paraview's interaction. Both works.

The problem is that I can open only one window each time.  If I try to 
open
multiple windows, I can only close them in the inverse order that I 
opened.

For example:
   Creating:  Create window 1
              Create window 2
   Deleting:  Close window 2
              Close window 1

Anyone knows why I have problems when closing the first window before 
the
second?

The code used to open the window and the method of my thread is above:

//Method Thread.

void *ThreadFunction(void *arg)
{
  vtkHMXYPlot **localXYplot;
  localXYplot = (vtkHMXYPlot **) arg;
  
  vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New(); 
  
  vtkRenderWindow *renderWindow = vtkRenderWindow::New();
 
  vtkRenderer *renderer = vtkRenderer::New();
  
  //Configuring the renderwindow.
  renderWindow->SetSize(500, 400);
  renderWindow->SetWindowName("HeMoLab 2D Plot.");
  
  //Configuring the renderer.
  renderer->SetBackground(0,0,0);
  
  renderer->AddActor2D(localXYplot[0]);
  renderer->AddActor2D(localXYplot[1]);
  renderer->AddActor2D(localXYplot[2]);

  renderWindow->AddRenderer(renderer);
  interactor->SetRenderWindow(renderWindow);
  interactor->Initialize();
  renderWindow->Render();
  interactor->Start();

  localXYplot[0]->Delete();
  localXYplot[1]->Delete();
  localXYplot[2]->Delete();
  
  interactor->Delete();
  renderer->Delete();
  renderWindow->Delete();
  std::cout << "Thread Finished!!!" << endl;
  //pthread_exit((void*)arg);
  pthread_exit(NULL);
}



Methodo Que cria as threads.
void vtkHMXYPlotWidget::ShowHMXYPlotWidget(vtkHMXYPlot **xyplot)
{
  int i, rc, rc2;
 
  int PTHREAD_CREATE_DETACHED, PTHREAD_SCOPE_PROCESS;
  
  pthread_t id;
  pthread_attr_t attr;
 
  pthread_attr_init(&attr);
  pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  rc = pthread_create(&id, &attr, ThreadFunction, (void *) xyplot);

}



/(        )`
                              \ \___   / |
                              /- _  `-/  '
                             (/\/ \ \   /\
                             / /   | `    \
                             O O   ) /     |
                             `-^--'`<      '
                             (_.)  _  )   /
                             `.___/`    / 
                               `-----' /
                  <----.     __ / __   \
                  <----|====O)))==) \) /====
                  <----'    `--' `.__,' \
                                |        |
                                \       /       /\
                          ______( (_  / \______/
                         ,'  ,-----'   |  Jan Palach, programador:
                         `--{__________)  Python, C/C++
 		
---------------------------------
 Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/paraview/attachments/20060623/5e9170b6/attachment.htm


More information about the ParaView mailing list