[vtkusers] OrientationMarkerWidget question from VTK newbie

Andrew Maclean andrew.amaclean at gmail.com
Tue Sep 26 19:37:34 EDT 2006


Hi Romy,
Here is a bit of code I use - it is just a function based on the Tcl example
in the VTK widget stuff.
In view of the fact that this question arises so often, perhaps this
code snippet could go on in the Wiki. I would be glad to put it up if
someone can tell me the procedure, or someone else can do it for me.

Obviously you can fiddle with the commented out areas. If you need the cube
bits, look at the Tcl example.

Andrew




On 9/23/06, Romy Schneider <romy at tacc.utexas.edu> wrote:
>
> Dean,
> Thanks for the reply.    I'm probably using this widget incorrectly, but
> what I want is a small set of 3D axes in the lower left hand corner, like
> Paraview has.   I don't want any sort of axes around the data.  The issue
> is, I can produce the small set of axes in the corner just as I want them
> (small, non-interactive, etc), but I also have a set of axes drawn near my
> data set.  Actually, what VTK draws is really tiny axes with huge axes
> labels.  Calls to SetFontSize( i ) have absolutely no effect (although I can
> change the font type, bold, italicize, etc:  I'm running VTK with Carbon on
> an Intel MacBook Pro, I figure this is just a bug).  Here's my code (I'm
> just starting out at VTK...).
>
>
> ...
>
>
> # add orientation axes
> vtkAxesActor axes
>
>
> vtkOrientationMarkerWidget marker
> marker SetOrientationMarker axes
> marker SetViewport 0.0 0.0 0.15 0.2
>
>
> #  RENDERER
> vtkRenderer ren1
> ren1 AddActor imageActor
> ren1 AddActor axes
> ren1 SetBackground 0.0 0.0 0.0
>
>
> #  RENDER WINDOW
> vtkRenderWindow renWin
> renWin AddRenderer ren1
>
>
> set vtkw [vtkTkRenderWidget .ren -width 600 -height 600 -rw renWin]
> # launch the vtk/tk interactor (command line) window
> wm deiconify .vtkInteract
>
>
> #
> # Setup Tk bindings and VTK observers for that widget.
> #
> ::vtk::bind_tk_render_widget $vtkw
>
>
> # set interactor for the render widget and orientation marker?
> set iact [[$vtkw GetRenderWindow] GetInteractor]
> vtkInteractorStyleTrackballCamera style
> $iact SetInteractorStyle style
>
>
> marker SetInteractor $iact
> marker SetEnabled 1
> marker InteractiveOff
> ...
>
>
>
>
> I've attached a screenshot, but I'm not sure if it will come through (I
> haven't seen any other attachments in the mailinglist).  The unwanted axes
> appear right next to the data slice, there's a small green dot (for the
> incredibly tiny axes it's drawing) and large white X, Y, Z, overlain on each
> other.   So, how do I make those go away while keeping the small orientation
> marker in the lower left hand corner?
>
>
> Thanks for your help!
>
>
> Romy
>
>
>
>
>
>
>
>  On Sep 21, 2006, at 9:43 PM, Dean Inglis wrote:
>
>  Hi Romy,
>
>
> I'm not sure what you want here.  The axes actor has
> 3D polydata representing the axes as tubes with cones
> for arrows and text for labels.  The axes are
> the "marker" that marks out the orientation.  You can
> also have a marker that is a cube with labels for
> different directions.  The whole idea when I wrote this
> class was to use the widget to accommodate the x-y-z arrow axes
> as seen in ParaView and the cube with anatomical direction labels
> as seen in VolView.  the widget allows the user to move it
> around the render window for interactive placement.
> Can you be a bit more specific about what you want to visualize?
>
>
> Dean
>
>
>
> however I don't want the main set of axes visible, just the
> orientation marker.  How do I accomplish this?  When I set the
> vtkAxesActor visibility off with VisibilityOff(), the orientation
> maker widget goes away as well.  I searched around and tinkered a
>
>
>
>
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>


-- 

___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.cas.edu.au/
___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060927/4d499d3a/attachment.htm>
-------------- next part --------------

//! This is the callback for the orientation marker widget.
/*!
    Almost direct translation from the TCL example by Andrew Maclean.
    This will set up an orientation marker by default in the lower-left corner of the window.

    To use it do something like this:

    \code
     ...
     iren->Initialize();
     ren1->Render();
    
     ...
     OrientationMarker(iren);
     ...
     iren->Start();
    \endcode

    @param iren - the render window interactor.

*/
void OrientationMarker ( vtkRenderWindowInteractor * iren )
{
  // Let's add an axis actor.
  vtkSmartPointer<vtkAxesActor> axes = vtkSmartPointer<vtkAxesActor>::New();

  // simulate a left-handed coordinate system
  // if transform->RotateY(90) is in the pipeline.
  //
  vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
  transform->Identity();
  //transform->RotateY(90);
  axes->SetShaftTypeToCylinder();
  axes->SetUserTransform( transform );
  //axes2->SetXAxisLabelText( "w" );
  //axes2->SetYAxisLabelText( "v" );
  //axes2->SetZAxisLabelText( "u" );

  axes->SetTotalLength( 1.5, 1.5, 1.5 );
  axes->SetCylinderRadius( 0.500 * axes->GetCylinderRadius() );
  axes->SetConeRadius    ( 1.025 * axes->GetConeRadius() );
  axes->SetSphereRadius  ( 1.500 * axes->GetSphereRadius() );

  vtkTextProperty *tprop = axes->GetXAxisCaptionActor2D()->
    GetCaptionTextProperty();
  tprop->ItalicOn();
  tprop->ShadowOn();
  tprop->SetFontFamilyToTimes();

  axes->GetYAxisCaptionActor2D()->GetCaptionTextProperty()->ShallowCopy( tprop );
  axes->GetZAxisCaptionActor2D()->GetCaptionTextProperty()->ShallowCopy( tprop );

  // combine orientation markers into one with an assembly
  //
  vtkSmartPointer<vtkPropAssembly> assembly = vtkPropAssembly::New();
  assembly->AddPart( axes );
  //assembly->AddPart( cube );

  // set up the widget
  //
  vtkSmartPointer<vtkOrientationMarkerWidget> widget = vtkOrientationMarkerWidget::New();
  widget->SetOutlineColor( 0.9300, 0.5700, 0.1300 );
  widget->SetOrientationMarker( assembly );
  widget->SetInteractor( iren );
  widget->SetViewport( 0.0, 0.0, 0.4, 0.4 );
  widget->SetEnabled( 1 );
  widget->InteractiveOff();
  widget->InteractiveOn();

}


More information about the vtkusers mailing list