[vtkusers] Interactor on vtkWidget

rakesh patil prakeshofficial at gmail.com
Tue Sep 21 12:56:39 EDT 2010


Well,

In order to delete a widget, one has to pick it. How do you implement
picking? Once picking is done, deleting is easy. Coz, if there are multiple
distance wizards, key events of each n every distance widgets will be
executed and all of them will be deleted..

Do you have any other technique to pick a widget? or atleast indicate that
among set of widgets, this widget i need to delete.

Regards
Rakesh Patil

On Tue, Sep 21, 2010 at 8:18 PM, Leonardo M. Ramé <l.rame at griensu.com>wrote:

> Well, maybe. The distance widget is just an example, in my app I want to
> add distance widgets, angle widgets and also "text" widgets, to let the
> user annotate a Dicom Image, and in some cases, the user would want to
> use more than one instance of those widgets.
>
>
> On 2010-09-21 15:46:19 +0100, Jothy wrote:
> > Whenever I click the distance button it create a new widget and places in
> > the active render window and able to manipulate independently. But the
> only
> > problem is when I want to delete anyone, all goes off!
> >
> > I don't know if you want to use multiple distance widget in a single
> render
> > window.
> >
> >
> > Jothy
> >
> > On Tue, Sep 21, 2010 at 3:30 PM, Leonardo M. Ramé <l.rame at griensu.com
> >wrote:
> >
> > > On 2010-09-21 15:25:34 +0100, Jothy wrote:
> > > >
> > > > On Tue, Sep 21, 2010 at 3:20 PM, Leonardo M. Ramé <
> l.rame at griensu.com
> > > >wrote:
> > > >
> > > > > Hi, I created a vtkDistanceWidget, and added an observer to catch
> the
> > > > > "delete" key on that widget, to be able to delete it from the
> scene.
> > > > >
> > > > > The problem is that key events are captured for the whole
> interactor,
> > > > > and not for my specific widget. How can I know what was the active
> > > > > widget at the moment of pressing the delete key?.
> > > > >
> > > > >
> > > > > This is my code:
> > > > >
> > > > > void widgetPickObserver(vtkObject* caller, unsigned long eid, void*
> > > > > clientdata, void *calldata)
> > > > > {
> > > > >
>  qDebug(static_cast<vtkRenderWindowInteractor*>(caller)->GetKeySym());
> > > > > }
> > > > >
> > > > > void myClass::addDistanceWidget()
> > > > > {
> > > > >  distanceWidget = vtkDistanceWidget::New();
> > > > >  distanceWidget->SetInteractor(this->GetInteractor());
> > > > >  distanceWidget->CreateDefaultRepresentation();
> > > > >  static_cast<vtkDistanceRepresentation
> > > > > *>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.3g
> mm");
> > > > >
> > > > >  vtkSmartPointer<vtkCallbackCommand> Callback =
> > > > > vtkSmartPointer<vtkCallbackCommand>::New();
> > > > >  Callback->SetCallback(widgetPickObserver);
> > > > >  Callback->SetClientData(distanceWidget);
> > > > >
> > > > >
> > >
>  distanceWidget->GetInteractor()->AddObserver(vtkCommand::KeyPressEvent,
> > > > > Callback);
> > > > >  distanceWidget->On();
> > > > > }
> > > > >
> > > > >
> > > > > --
> > > > > Leonardo M. Ramé
> > > > > http://leonardorame.blogspot.com
> > >
> > > > What I did in my Qt program was - used a toggle button on the toolbar
> to
> > > > enable and disable the distance widget.
> > > >
> > > > Jothy
> > >
> > > Yes, but what if you need more than one distance widgets? how do you
> > > know which one is selected?
> > >
> > > --
> > > Leonardo M. Ramé
> > > http://leonardorame.blogspot.com
> > >
>
> --
> Leonardo M. Ramé
> http://leonardorame.blogspot.com
> _______________________________________________
> 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/20100921/e4ac5a5e/attachment.htm>


More information about the vtkusers mailing list