[vtkusers] How do I get the current state of a filter ?

dean.inglis at camris.ca dean.inglis at camris.ca
Fri Aug 8 00:03:35 EDT 2003


Hmmm, here is some source code that hopefully illustrates progress ...


<snip...some initialization method where this could be an app specific
obect that manages vtk object creation and gui management>

//create the reader which is a process object...

  m_Reader = vtkImageReader::New();
  m_Reader->SetStartMethod(&BeginGauge ,static_cast<void*>(this));
  m_Reader->SetEndMethod(&EndGauge ,static_cast<void*>(this));
  m_Reader->SetProgressMethod(&UpdateProgress ,static_cast<void*>(this));

<snip>

<snip...some file input method specific to the app>

  m_currentProcess = m_Reader;
  m_Reader->Update();
  m_currentProcess = NULL;

<snip>

//the next methods are very platform dependent:  Borland C++ Builder,
//but there is a gui component, a gauge, that paints itself to 
//a status bar so that it appears as a colored progress meter in one
//of the panels of the multi-panel status bar. 
//m_currentProcess is a pointer to any vtkProcessObject, used here
//to monitor loading of 3D image files... 

void TMainForm::BeginGauge(void* arg)
{
    TMainForm* self = reinterpret_cast<TMainForm*>(arg);
    if (!self )
      {
      return;
      }
    if( self->m_currentProcess == NULL )
      {
      return;
      }
    self->m_abort = false;

    self->m_currentProcess->AbortExecuteOff();
    Screen->Cursor = crHourGlass;
    const int index = 2;
    RECT RPanel;
    SNDMSG(self->StatusBar->Handle, SB_GETRECT, index,
           reinterpret_cast<LPARAM>(&RPanel));
    InflateRect(&RPanel, -1, -1);
    self->CGauge->Parent = self->StatusBar;
    self->CGauge->BoundsRect = RPanel;
    self->CGauge->Progress = 0;
    self->CGauge->Show();
}

void TMainForm::EndGauge(void* arg)
{
  TMainForm* self = reinterpret_cast<TMainForm*>(arg);
  if (!self )
    {
    return;
    }

  Screen->Cursor = crDefault;
  self->CGauge->Progress = 0;
  self->CGauge->Hide();
  self->CGauge->Parent->Update();
  Application->ProcessMessages();
}

void TMainForm::UpdateProgress(void* arg)
{
  TMainForm* self = reinterpret_cast<TMainForm*>(arg);
  if (!self )
    {
    return;
    }

   self->CGauge->Progress = (int)(self->m_currentProcess->GetProgress()*100);
   Application->ProcessMessages();
   if ( self->m_abort )
     {
     self->m_currentProcess->AbortExecuteOn();
     }
}


best regards,
Dean




More information about the vtkusers mailing list