Well, <br><br>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..<br>
<br>Do you have any other technique to pick a widget? or atleast indicate that among set of widgets, this widget i need to delete.<br><br>Regards<br>Rakesh Patil<br><br><div class="gmail_quote">On Tue, Sep 21, 2010 at 8:18 PM, Leonardo M. Ramé <span dir="ltr"><<a href="mailto:l.rame@griensu.com">l.rame@griensu.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Well, maybe. The distance widget is just an example, in my app I want to<br>
add distance widgets, angle widgets and also "text" widgets, to let the<br>
user annotate a Dicom Image, and in some cases, the user would want to<br>
use more than one instance of those widgets.<br>
<div><div></div><div class="h5"><br>
<br>
On 2010-09-21 15:46:19 +0100, Jothy wrote:<br>
> Whenever I click the distance button it create a new widget and places in<br>
> the active render window and able to manipulate independently. But the only<br>
> problem is when I want to delete anyone, all goes off!<br>
><br>
> I don't know if you want to use multiple distance widget in a single render<br>
> window.<br>
><br>
><br>
> Jothy<br>
><br>
> On Tue, Sep 21, 2010 at 3:30 PM, Leonardo M. Ramé <<a href="mailto:l.rame@griensu.com">l.rame@griensu.com</a>>wrote:<br>
><br>
> > On 2010-09-21 15:25:34 +0100, Jothy wrote:<br>
> > ><br>
> > > On Tue, Sep 21, 2010 at 3:20 PM, Leonardo M. Ramé <<a href="mailto:l.rame@griensu.com">l.rame@griensu.com</a><br>
> > >wrote:<br>
> > ><br>
> > > > Hi, I created a vtkDistanceWidget, and added an observer to catch the<br>
> > > > "delete" key on that widget, to be able to delete it from the scene.<br>
> > > ><br>
> > > > The problem is that key events are captured for the whole interactor,<br>
> > > > and not for my specific widget. How can I know what was the active<br>
> > > > widget at the moment of pressing the delete key?.<br>
> > > ><br>
> > > ><br>
> > > > This is my code:<br>
> > > ><br>
> > > > void widgetPickObserver(vtkObject* caller, unsigned long eid, void*<br>
> > > > clientdata, void *calldata)<br>
> > > > {<br>
> > > > qDebug(static_cast<vtkRenderWindowInteractor*>(caller)->GetKeySym());<br>
> > > > }<br>
> > > ><br>
> > > > void myClass::addDistanceWidget()<br>
> > > > {<br>
> > > > distanceWidget = vtkDistanceWidget::New();<br>
> > > > distanceWidget->SetInteractor(this->GetInteractor());<br>
> > > > distanceWidget->CreateDefaultRepresentation();<br>
> > > > static_cast<vtkDistanceRepresentation<br>
> > > > *>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.3g mm");<br>
> > > ><br>
> > > > vtkSmartPointer<vtkCallbackCommand> Callback =<br>
> > > > vtkSmartPointer<vtkCallbackCommand>::New();<br>
> > > > Callback->SetCallback(widgetPickObserver);<br>
> > > > Callback->SetClientData(distanceWidget);<br>
> > > ><br>
> > > ><br>
> > distanceWidget->GetInteractor()->AddObserver(vtkCommand::KeyPressEvent,<br>
> > > > Callback);<br>
> > > > distanceWidget->On();<br>
> > > > }<br>
> > > ><br>
> > > ><br>
> > > > --<br>
> > > > Leonardo M. Ramé<br>
> > > > <a href="http://leonardorame.blogspot.com" target="_blank">http://leonardorame.blogspot.com</a><br>
> ><br>
> > > What I did in my Qt program was - used a toggle button on the toolbar to<br>
> > > enable and disable the distance widget.<br>
> > ><br>
> > > Jothy<br>
> ><br>
> > Yes, but what if you need more than one distance widgets? how do you<br>
> > know which one is selected?<br>
> ><br>
> > --<br>
> > Leonardo M. Ramé<br>
> > <a href="http://leonardorame.blogspot.com" target="_blank">http://leonardorame.blogspot.com</a><br>
> ><br>
<br>
</div></div>--<br>
<div class="im">Leonardo M. Ramé<br>
<a href="http://leonardorame.blogspot.com" target="_blank">http://leonardorame.blogspot.com</a><br>
</div><div><div></div><div class="h5">_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br>