[vtkusers] vtkTransform::Pop() and vtkTransform::Push()

Maarten Beek beekmaarten at yahoo.com
Mon Aug 11 17:09:11 EDT 2014


I realize I could put a stack of transforms in my interactor style, but looking at the source code, I get the impression that the possibility is already built into vtkTransform and I would like to take advantage of this

Maarten



On Monday, August 11, 2014 4:18:29 PM, "Meehan, Bernard" <MEEHANBT at nv.doe.gov> wrote:
 


forgot to hit reply all
From: <Meehan>, Tim Meehan <meehanbt at nv.doe.gov>
Date: Monday, August 11, 2014 12:59 PM
To: Maarten Beek <beekmaarten at yahoo.com>
Subject: Re: [vtkusers] vtkTransform::Pop() and vtkTransform::Push()


Most of the transforms that I end up messing with look similar to:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/AffineWidget

I'm not entirely sure how to use the Push/Pop thing ... can't figure out what the transform stack is either.

For the "undo" case, it seems like you could just copy the actors original transform. You then would operate directly on the actor's transform ... and if you decide that you liked it the way the old transform had it set up, just set the actors transform to be the stored copy.

I haven't run or tested this, but perhaps something like:


cone = vtk.vtkConeSource()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(cone.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)

old_transform = vtkTransform()
if actor.GetUserTransform() is not None:
  old_transform.DeepCopy(actor.GetUserTransform())

<do stuff with the actor>

<set the transform to the old transform>
actor.SetUserTransform(old_transform)

From: Maarten Beek <beekmaarten at yahoo.com>
Reply-To: Maarten Beek <beekmaarten at yahoo.com>
Date: Monday, August 11, 2014 11:35 AM
To: Tim Meehan <meehanbt at nv.doe.gov>, vtkusers <vtkusers at vtk.org>
Subject: Re: [vtkusers] vtkTransform::Pop() and vtkTransform::Push()


Aaa
So I wouldn't be using:

vtkTransform* Y = vtkTransform::New();
< do stuff with Y >
X->Concatenate(Y);
X->Push();
Y->Delete();

(X would be the usertransform of the actor - Y the subtransformation created by interaction)

Maarten




On Monday, August 11, 2014 2:18:39 PM, "Meehan, Bernard" <MEEHANBT at nv.doe.gov> wrote:





Are you pre-multiplying or post-multiplying your transformations?
I got tangled up a bit before I realized that the default mode was premultiply ... which means that if you do this:

xform = vtk.vtkTransform()
xform.Push(A)
xform.Push(B)
xform.Push(C)

you get the following matrix operation on the vector x:

A B C x

when you might have wanted:

xform.PostMultiply()
xform.Push(A)
xform.Push(B)
xform.Push(C)

which would give you:

C B A xFrom: Maarten Beek via vtkusers <vtkusers at vtk.org>
Reply-To: Maarten Beek <beekmaarten at yahoo.com>
Date: Monday, August 11, 2014 10:49 AM
To: vtkusers <vtkusers at vtk.org>
Subject: [vtkusers] vtkTransform::Pop() and vtkTransform::Push()


Hi all,

I am trying to get some king of 'undo' feature in my interactor style, so that Ctrl-Z would undo the last transformation to the currently selected actor. I am currently looking at vtkTransform::Push()) and Pop(), but haven't been able to get something working. 


Any suggestions?

Another way of phrasing my question would be: How am I supposed to use the Pop() and Push() functions?


Thanks - Maarten
_______________________________________________
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://public.kitware.com/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://public.kitware.com/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140811/06509aab/attachment.html>


More information about the vtkusers mailing list