[vtkusers] QT, VTK, and ITK combined program exit problem

Xiaopeng Yang yxp233 at postech.ac.kr
Fri Jun 24 22:26:21 EDT 2011


I did what you told. But still I cannot select seed point unless I call
Start().

 

This is the code in main():

 

  vtkSmartPointer<vtkPointHandleRepresentation2D> handle = 

     vtkSmartPointer<vtkPointHandleRepresentation2D>::New();

  

  handle->GetProperty()->SetColor(1,0,0);

 

  vtkSmartPointer<vtkSeedRepresentation> rep = 

    vtkSmartPointer<vtkSeedRepresentation>::New();

  rep->SetHandleRepresentation(handle);

  

  // Seed widget

  vtkSmartPointer<vtkSeedWidget> seedWidget = 

    vtkSmartPointer<vtkSeedWidget>::New();

 
seedWidget->SetInteractor(this->ui->qvtkWidget_4->GetRenderWindow()->GetInte
ractor());

  seedWidget->SetRepresentation(rep);

  vtkSmartPointer<vtkSeedCallback> seedCallback = 

  vtkSmartPointer<vtkSeedCallback>::New();

  seedCallback->SetRepresentation(rep);

  seedWidget->AddObserver(vtkCommand::PlacePointEvent,seedCallback);

  seedWidget->AddObserver(vtkCommand::InteractionEvent,seedCallback);

  

  seedWidget->On();

 

  this->ui->qvtkWidget_4->GetRenderWindow()->GetInteractor()->Start();

 

And this is the code for interaction:

 

class vtkSeedCallback : public vtkCommand

{

  public:

    static vtkSeedCallback *New()

    { 

      return new vtkSeedCallback; 

    }

    vtkSeedCallback() {}

    virtual void Execute(vtkObject*, unsigned long event, void *calldata)

    {

         

         Seed_Selection_Portal = true;

         Seed_Selection_Tumor = true;

 

      if(event == vtkCommand::PlacePointEvent)

      {

        std::cout << "Point placed, total of: " 

            << this->SeedRepresentation->GetNumberOfSeeds() << std::endl;

      }

      if(event == vtkCommand::InteractionEvent)

      {

        if(calldata)

        {

          std::cout << "Interacting with seed : " 

              << *(static_cast< int * >(calldata)) << std::endl;

        }

      }

  

      std::cout << "List of seeds (Display coordinates):" << std::endl;

      .

}

 

Thank you,

Xiaopeng

From: Clinton Stimpson [mailto:clinton at elemtech.com] 
Sent: Saturday, June 25, 2011 10:41 AM
To: Xiaopeng Yang
Cc: 'vtk'; insight-users at itk.org
Subject: Re: [vtkusers] QT, VTK, and ITK combined program exit problem

 

 

On Jun 24, 2011, at 7:36 PM, Xiaopeng Yang wrote:





Hi Clint,

 

Actually I tried to use QVTKInteractor as follows:

 

imageViewer1_open->SetupInteractor(this->ui->qvtkWidget->GetRenderWindow()->
GetInteractor());

.

this->ui->qvtkWidget->GetRenderWindow()->GetInteractor()->Start();

 

Don't call Start() for a Qt application.  Use QApplication::exec() in your
main() instead.





 

However, still the same problem occurred. Could you please let me know what
mistakes I made?

 

I'm not sure why your seed point selection isn't working.

 

Clint





 

Thank you,

 

Best regards,

Xiaopeng

From: clinton at elemtech.com [mailto:clinton at elemtech.com] 
Sent: Saturday, June 25, 2011 10:04 AM
To: Xiaopeng Yang; 'vtk'; insight-users at itk.org
Subject: Re: [vtkusers] QT, VTK, and ITK combined program exit problem

 

If you are using Qt, the event loop should be handled by Qt, not VTK with
the iren->start.
Also be sure to use the QVTKInteractor instead of the type from the factory
method vtkRenderWindowInteractor::New.

Clint

----- Reply message -----
From: "Xiaopeng Yang" <yxp233 at postech.ac.kr>
Date: Fri, Jun 24, 2011 6:42 pm
Subject: [vtkusers] QT, VTK, and ITK combined program exit problem
To: "&apos;vtk&apos;" <vtkusers at vtk.org>, <insight-users at itk.org>

Hi All,

 

I found where the problem is: "iren->Start()". "iren" is the
vtkRenderWindowInteractor I defined in my program. If I delete this sentence
"iren->Start()", then I can close both GUI and console windows without
warning message "QObject::killTimers: timers cannot be stopped from another
thread". Otherwise, the problem I described in the previous Email will
occur.

 

However, for seed point selection, I need "iren->Start()". Then what should
I do to solve the problem?

 

Best,

Xiaopeng

 

From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
Of Xiaopeng Yang
Sent: Friday, June 24, 2011 4:07 PM
To: 'vtk'; insight-users at itk.org
Subject: [vtkusers] QT, VTK, and ITK combined program exit problem

 

Dear Users,

 

I made a program based on QT, VTK, and ITK. When I run the program, there
are GUI window and console window. When I click "exit" button in the GUI
window, the GUI window exits but the console window doesn't. When I click
"exit" button in the console window, there is a message:
QObject::killTimers: timers cannot be stopped from another thread. If
someone already had a similar experience, please could you share your
knowledge?

 

Thank you very much.

 

Best regards,

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110625/e04c505c/attachment.htm>


More information about the vtkusers mailing list