[vtkusers] (Resend) PlaneWidget and InteractorStyle in vtkBorlan dRenderWindow
Xianjin Yang
Yang at AGIUSA.COM
Thu Nov 20 08:58:16 EST 2003
Hi vtkusers,
The code appended below is adapted from
\VTK\Hybrid\Testing\Cxx\TestPlaneWidget.cxx. Here are the problems
associated with InteractorStyle and PlaneWidget in vtkBorlandRenderWindow.
vtkWindow1 below is a vtkBorlandRenderWindow.
(1) With default InteractorStyle (trackballcamera??), the outlineActor shows
up normally. But when I press "i" key to bring up the planewidget, I get an
"Access Violation" in
//----------- vtk source --------
void vtkInteractorObserver::ProcessEvents(vtkObject* vtkNotUsed(object),
unsigned long event, void* clientdata, void* vtkNotUsed(calldata)) {
vtkInteractorObserver* self
= reinterpret_cast<vtkInteractorObserver *>( clientdata );
//look for char and delete events
switch(event)
{
case vtkCommand::CharEvent:
self->OnChar(); <<========= Access Violation here =======
break;
case vtkCommand::DeleteEvent:
//self->Interactor = NULL; //commented out, can't write to a
//self->Enabled = 0; //deleted object
break;
}
}
//-------------------------
(2) With vtkWindow1->GetInteractor()->SetInteractorStyle(planeWidget),
outlineActor becomes static (frozen). After pressing "I" key, the
planewidget shows up normally and interaction is OK, but outlineActor
remains static.
FYI, after some minor changes, \VTK\Hybrid\Testing\Cxx\TestPlaneWidget.cxx
was compiled successfully with my Borland bcc32.exe and it worked as
expected without any problems.
Thanks a lot for your help.
Yang
// ========= Code ===================
class vtkTPWCallback : public vtkCommand
{
public:
static vtkTPWCallback *New()
{ return new vtkTPWCallback; }
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
vtkPlaneWidget *planeWidget =
reinterpret_cast<vtkPlaneWidget*>(caller);
planeWidget->GetPolyData(this->PolyData);
this->Actor->VisibilityOn();
}
vtkTPWCallback():PolyData(0),Actor(0) {}
vtkPolyData *PolyData;
vtkActor *Actor;
};
//--------------------------------------------------------------------------
-
void __fastcall TVTK_Form::Button1Click(TObject *Sender)
{
vtkPLOT3DReader *pl3d = vtkPLOT3DReader::New();
pl3d->SetXYZFileName("combxyz.bin");
pl3d->SetQFileName("combq.bin");
pl3d->SetScalarFunctionNumber(100);
pl3d->SetVectorFunctionNumber(202);
pl3d->Update();
vtkPolyData *plane = vtkPolyData::New();
vtkProbeFilter *probe = vtkProbeFilter::New();
probe->SetInput(plane);
probe->SetSource(pl3d->GetOutput());
vtkPolyDataMapper *probeMapper = vtkPolyDataMapper::New();
probeMapper->SetInput(probe->GetPolyDataOutput());
probeMapper->SetScalarRange(pl3d->GetOutput()->GetScalarRange());
vtkActor *probeActor = vtkActor::New();
probeActor->SetMapper(probeMapper);
probeActor->VisibilityOff();
// An outline is shown for context.
vtkStructuredGridOutlineFilter *outline =
vtkStructuredGridOutlineFilter::New();
outline->SetInput(pl3d->GetOutput());
vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
outlineMapper->SetInput(outline->GetOutput());
vtkActor *outlineActor = vtkActor::New();
outlineActor->SetMapper(outlineMapper);
vtkTPWCallback *myCallback = vtkTPWCallback::New();
myCallback->PolyData = plane;
myCallback->Actor = probeActor;
vtkPlaneWidget *planeWidget = vtkPlaneWidget::New();
//vtkWindow1->GetInteractor()->SetInteractorStyle(planeWidget);
planeWidget->SetInteractor(vtkWindow1->GetInteractor());
planeWidget->SetInput(pl3d->GetOutput());
planeWidget->NormalToXAxisOn();
planeWidget->SetResolution(20);
planeWidget->SetRepresentationToOutline();
planeWidget->PlaceWidget();
planeWidget->AddObserver(vtkCommand::InteractionEvent,myCallback);
vtkWindow1->GetRenderer()->AddActor(probeActor);
vtkWindow1->GetRenderer()->AddActor(outlineActor);
vtkWindow1->Invalidate();
vtkWindow1->GetInteractor()->Initialize();
vtkWindow1->GetInteractor()->Start();
// Delete() ....
}
-----Original Message-----
From: Dean Inglis [mailto:dean.inglis at camris.ca]
Sent: Thursday, November 06, 2003 1:49 PM
To: vtkusers archive
Subject: Re: [vtkusers] InteractorStyle in vtkBorlandRenderWindow
Hi Yang,
>I use a vtkPlaneWidget to "probe" a volume data set and render my image
>on a vtkBorlandRenderWindow (RenWin). This works OK and I could
>interact with the planewidget (see attachment). The problem is that I
>had to set
>RenWin->GetInteractor()->SetInteractorStyle(planeWidget);
this should not be done and it would be surprising if wierd behaviour were
not happening. You should only be doing:
planeWidget->SetInteractor(RenWin->GetInteractor());
the other actors are static wehn you set the interactorstyle to the widget
because planeWidget is not an interactorstyle in the usual sense.
>But other actors are static and never respond to any mouse action after
>I
press "i"
>key to exit planewidget interaction.
Were the actors interactive before you activated the plane widget with the
"i" key? Why do you have to disable the rotation? You could set the
interactorstyle of the borland renderwindow component to
vtkInteractorStyleImage which has no left mouse button rotation capability.
Dean
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
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/20031120/32014eb4/attachment.htm>
More information about the vtkusers
mailing list