[vtkusers] Re: [vtk-developers] Problems using vtkCommand::ProcessEvent with Qt 3 by using vtkEventQtSlotConnect - Sorry by last ugly subject

Clinton Stimpson clinton at elemtech.com
Thu May 4 15:07:35 EDT 2006


Here's probably enough for you to work from:

========================
  this->EventQtSlot = vtkEventQtSlotConnect::New();
  ....
  vtkPExodusReader *exodusReader = vtkPExodusReader::New();

  this->EventQtSlot->Connect(exodusReader,vtkCommand::ProgressEvent,
    this,SLOT(ExodusReaderProgress(vtkObject *, unsigned long, 
void*,void*)));

  exodusReader->  do some stuff and read the file

  this->EventQtSlot->Disconnect(exodusReader,vtkCommand::ProgressEvent,
    this,SLOT(ExodusReaderProgress(vtkObject *, unsigned long, 
void*,void*)));

=============================

void PMainWindow::ExodusReaderProgress(vtkObject *, unsigned long, 
void*, void* progress)
{
    double* amount=(double*)progress;
    int step=(int)*amount*100;
    this->ProgressWidget->SetSubProgress(step);
}

Clint



Wagner Sales wrote:
> Hi VTK Developers,
>
> I was posted this message at vtk-users, but unfortunatelly, no answer was sended back. 
> Then, i'm posting here and put more two considerations:
> 1 - I suggest to include an example about this topic in future vtk releases ( Examples/GUI/Qt/Events ).
>
>
> 2 - I was tried just with the vtkDICOMImageReader, not with others filters. In ITK this problem only occurs with readers, but I was gived the desired behaviour with others filters (e.g segmentation filters). May be in VTK are the same?
>
>
>
> Since I'm using Qt, i'm familiar with the slot/connection facilty, but not so familiar with the add observer pattern, just by I was readed in vtk books. 
>
> Thks a lot by any suggestions, example...
>
>
> Wagner sales
>
>
> --- POSTED MESSAGE:
> Hi all,
>
> I'm trying to use the progress event from a vtkDICOMImageReader to
> change the status ( percent ) on a QProgressBar widget.
> I was readed the Examples/GUI/Qt, and based on this, StartEvent and
>
>
> EndEvent are working fine to me by using the following code:
>
>    // my connections, based on vtkEventQtSlotConnect
>     m_connector->Connect( m_dicomReader, vtkCommand::EndEvent, this,
> SLOT(slotEnded(vtkObject*)));
>
>
>     m_connector->Connect( m_dicomReader, vtkCommand::StartEvent, this,
> SLOT(slotStarted(vtkObject*)));
>    // my slots:
> void MyWidget::slotStarted(vtkObject* obj)
> {
>     std::cout << "---> Dicom reader started!" << endl;
>
>
> }
> void MyWidget::slotEnded(vtkObject* obj)
> {
>      std::cout << "---> Dicom reader ended!" << endl;
> }
>
> Well, before to set my QProgressBar progress I was just put some output
>
>
> to std::cout ( code are at the end ).
> Then, I'm trying to do the same with the ProgressEvent, but only one
> time are showed to me the message:
> -- Progress: 0
> -- Progress Text:
>
> Someone have some help or example how to use?
>
>
> The code to understand are here:
>
> //connection
> m_connector->Connect( m_dicomReader, vtkCommand::ProgressEvent, this,
> SLOT(slotProgressChanged(vtkObject*)));
>
> //slot
> void MyWidget::slotProgressChanged(vtkObject* obj)
>
>
> {
>     vtkDICOMImageReader *r = vtkDICOMImageReader::SafeDownCast(obj);
>     std::cout << "-- Progress: " << r->GetProgress() << endl;
>     std::cout << "-- Progress text: " << r->GetProgressText() << endl;
>
>
> }
>
> Thnks in advance,
>
> Wagner Sales
>
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>   




More information about the vtkusers mailing list