VTK ActiViz to reset object to original view

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

VTK ActiViz to reset object to original view

nickxtsui
This post was updated on .
I am trying to reset the 3D object to its original view (something
orthogonal, sagital, say) after its interaction.

Here is my code how I try to reset, unsuccessful though:

private vtkAxesActor axes;
private vtkOrientationMarkerWidget widget;

public void ResetView()
        {
          //  axes.InitPathTraversal();
            if (axes != null)
            {
                if (axes.GetUserMatrix() != null)
                    axes.GetUserMatrix().Identity();
                axes.GetMatrix().Identity();
                axes.SetOrigin(0,0,0);
                axes.SetOrientation(0, 0, 0);
                axes.SetScale(1, 1, 1);
                axes.SetPosition(0, 0, 0);
            }

            if (widget != null)
            {
                widget.SetOrientationMarker(axes);
            }


            ForceWindowToRender();
        }

How should I do this? Thanks a lot.

EDIT:
Here are my VTK objects . I think it must be one of the them that should be removed, and then re-added to make the new coordinate system kick in:

   private vtkAxesActor axes;
        private vtkCamera camera;
        private List<vtkImageChangeInformation> changeFilters;

        //private vtkTIFFReader reader;
        private vtkImageAppendComponents componentAdaptor;
        private List<vtkStringArray> fileNameArrays;
        private List<vtkImageFlip> flippers;
        private vtkRenderWindowInteractor iren;

        // these two arrays specify the color range for the components specified by the array indexes
        private int[] lowerThreshold = { 0, 0, 0, 0 };
        private List<vtkTIFFReader> readers;
        private vtkRenderer renderer;
        private vtkRenderWindow renderWindow;
        private RenderWindowControl renWindowControl;
        private int[] upperThreshold = { MaxGrayScaleLevel, MaxGrayScaleLevel, MaxGrayScaleLevel, MaxGrayScaleLevel };
        private vtkVolumeProperty volProperty;
        private vtkVolume volume;
        private vtkFixedPointVolumeRayCastMapper volumeMapper;
        private vtkOrientationMarkerWidget widget;
 
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: VTK ActiViz to reset object to original view

alethea
Have you tried setting axes.Modified()?
I've found you have to call this after setting the user matrix to tell the pipeline to recompute.

nickxtsui wrote
I am trying to reset the 3D object to its original view (something
orthogonal, sagital, say) after its interaction.

Here is my code how I try to reset, unsuccessful though:

private vtkAxesActor axes;
private vtkOrientationMarkerWidget widget;

public void ResetView()
        {
          //  axes.InitPathTraversal();
            if (axes != null)
            {
                if (axes.GetUserMatrix() != null)
                    axes.GetUserMatrix().Identity();
                axes.GetMatrix().Identity();
                axes.SetOrigin(0,0,0);
                axes.SetOrientation(0, 0, 0);
                axes.SetScale(1, 1, 1);
                axes.SetPosition(0, 0, 0);
            }

            if (widget != null)
            {
                widget.SetOrientationMarker(axes);
            }


            ForceWindowToRender();
        }

How should I do this? Thanks a lot.
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: VTK ActiViz to reset object to original view

nickxtsui
Seems not working still.

On Tue, Dec 3, 2013 at 3:35 PM, alethea <[hidden email]> wrote:

> Have you tried setting axes.Modified()?
> I've found you have to call this after setting the user matrix to tell the
> pipeline to recompute.
>
>
> nickxtsui wrote
>> I am trying to reset the 3D object to its original view (something
>> orthogonal, sagital, say) after its interaction.
>>
>> Here is my code how I try to reset, unsuccessful though:
>>
>> private vtkAxesActor axes;
>> private vtkOrientationMarkerWidget widget;
>>
>> public void ResetView()
>>         {
>>           //  axes.InitPathTraversal();
>>             if (axes != null)
>>             {
>>                 if (axes.GetUserMatrix() != null)
>>                     axes.GetUserMatrix().Identity();
>>                 axes.GetMatrix().Identity();
>>                 axes.SetOrigin(0,0,0);
>>                 axes.SetOrientation(0, 0, 0);
>>                 axes.SetScale(1, 1, 1);
>>                 axes.SetPosition(0, 0, 0);
>>             }
>>
>>             if (widget != null)
>>             {
>>                 widget.SetOrientationMarker(axes);
>>             }
>>
>>
>>             ForceWindowToRender();
>>         }
>>
>> How should I do this? Thanks a lot.
>> _______________________________________________
>> 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
>
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/VTK-ActiViz-to-reset-object-to-original-view-tp5724801p5724805.html
> Sent from the VTK - Users mailing list archive at Nabble.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
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: VTK ActiViz to reset object to original view

alethea
It looks like you are using a vtkOrientationMarkerWidget. I am not familiar with this widget, but after a glance at the code, it looks like the Orientation Prop must be set before enabling the widget. From what you posted, I assume the widget has already been enabled by the time you call your "resetview". Perhaps try calling widget.Off(), then widget.SetOrientationMarker(axes), then widget.On().

nickxtsui wrote
Seems not working still.

On Tue, Dec 3, 2013 at 3:35 PM, alethea <[hidden email]> wrote:
> Have you tried setting axes.Modified()?
> I've found you have to call this after setting the user matrix to tell the
> pipeline to recompute.
>
>
> nickxtsui wrote
>> I am trying to reset the 3D object to its original view (something
>> orthogonal, sagital, say) after its interaction.
>>
>> Here is my code how I try to reset, unsuccessful though:
>>
>> private vtkAxesActor axes;
>> private vtkOrientationMarkerWidget widget;
>>
>> public void ResetView()
>>         {
>>           //  axes.InitPathTraversal();
>>             if (axes != null)
>>             {
>>                 if (axes.GetUserMatrix() != null)
>>                     axes.GetUserMatrix().Identity();
>>                 axes.GetMatrix().Identity();
>>                 axes.SetOrigin(0,0,0);
>>                 axes.SetOrientation(0, 0, 0);
>>                 axes.SetScale(1, 1, 1);
>>                 axes.SetPosition(0, 0, 0);
>>             }
>>
>>             if (widget != null)
>>             {
>>                 widget.SetOrientationMarker(axes);
>>             }
>>
>>
>>             ForceWindowToRender();
>>         }
>>
>> How should I do this? Thanks a lot.
>> _______________________________________________
>> 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
>
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/VTK-ActiViz-to-reset-object-to-original-view-tp5724801p5724805.html
> Sent from the VTK - Users mailing list archive at Nabble.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
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: VTK ActiViz to reset object to original view

nickxtsui
I simply did this to get the job done:

camera.SetPosition(DoubleArrayToIntPtr(defaultCamPos));
            camera.SetViewUp(DoubleArrayToIntPtr(defaultCamViewup));
           
            camera.SetFocalPoint(DoubleArrayToIntPtr(defaultCamFocus));
           
            renderer.ResetCamera();
            renderer.GetActiveCamera();
            ForceWindowToRender();

Thanks for the help.