<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<br>
<div class="moz-cite-prefix">On 8/6/2015 1:35 PM, Cory Quammen
wrote:<br>
</div>
<blockquote
cite="mid:CAB5Fpx6ywGnL8VO2b7xgH2dLHgkDCg_p1AJUcS0mm63+_3=iBQ@mail.gmail.com"
type="cite">
<div dir="ltr">Does your "anActor" have the ability to reset the
rotation? If so, then you can just reset it and then apply the
accumulated rotation as you are doing, e.g.
<div><br>
</div>
<div><span style="font-size:12.8000001907349px">anActor->SetOrientation(0,
0, 0);</span><span class="im"
style="font-size:12.8000001907349px"><br>
anActor->RotateWXYZ(wxyz[0], wxyz[1], wxyz[2], wxyz[3]);</span><br>
</div>
<div><span class="im" style="font-size:12.8000001907349px"><br>
</span></div>
<div><font color="#500050"><span
style="font-size:12.8000001907349px">This would be nice
because you wouldn't need to store the last rotation to
undo it.</span></font></div>
</div>
<div class="gmail_extra"><br>
</div>
</blockquote>
The anActor is just a regular vtkActor (a cone) for now. <br>
<br>
The 'reset' is effectively the line of code:<br>
anActor->RotateWXYZ(-lastAngle, lastWXYZ[1], lastWXYZ[2],
lastWXYZ[3]);<span class=""><br>
<br>
One would need to store this input somewhere in order to do this,
as it would be different each time.<br>
<br>
What I'm looking for is instead to perform incremental rotations,
avoiding the "transforming back", i.e. (reset) part.<br>
<br>
tk<br>
</span><br>
<blockquote
cite="mid:CAB5Fpx6ywGnL8VO2b7xgH2dLHgkDCg_p1AJUcS0mm63+_3=iBQ@mail.gmail.com"
type="cite">
<div class="gmail_extra">
<div class="gmail_quote">On Thu, Aug 6, 2015 at 4:26 PM, Totte
Karlsson <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:totte@dunescientific.com" target="_blank">totte@dunescientific.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Hello Cory,<br>
I was able to use your suggestion and got some code to
work, as follows:<span class=""><br>
<br>
virtual void Execute(vtkObject *caller, unsigned
long, void*)<br>
{<br>
</span><span class=""> static int callCount = 0;<br>
</span> static double lastAngle = 0;<br>
static double lastVec[3] = {0,0,0};<span class=""><br>
vtkSmartPointer<vtkTransform> t =
vtkSmartPointer<vtkTransform>::New();<br>
</span> static vtkSmartPointer<vtkTransform>
lastTransform =
vtkSmartPointer<vtkTransform>::New();<span class=""><br>
vtkBoxWidget *widget =
reinterpret_cast<vtkBoxWidget*>(caller);<br>
widget->GetTransform(t);<br>
<br>
</span> double* wxyz = t->GetOrientationWXYZ();<br>
double* lastWXYZ =
lastTransform->GetOrientationWXYZ();<br>
<br>
if(anActor)<br>
{<br>
cout<<"CallCount:
"<<callCount<<"Current Angle
"<<wxyz[0]<<" Effective angle:"<<
wxyz[0] - lastAngle<<endl;<br>
<br>
//Transform 'back'<br>
anActor->RotateWXYZ(-lastAngle,
lastWXYZ[1], lastWXYZ[2], lastWXYZ[3]);<span class=""><br>
anActor->RotateWXYZ(wxyz[0], wxyz[1],
wxyz[2], wxyz[3]);<br>
}<br>
<br>
</span> //Save transform data<br>
lastAngle = wxyz[0] ;<br>
lastVec[0] =wxyz[1];<br>
lastVec[1] =wxyz[2];<br>
lastVec[2] =wxyz[3];<br>
<br>
lastTransform = t;<br>
callCount++;<br>
}<br>
<br>
In the above code, two transformations of the actor are
done, in order to follow the orientation of the widget. 1)
to rotate the actor to its initial position, and 2),
applying current transformation.<br>
<br>
Although the above code works, is there a way to get the
'incremental' transform somehow? I'm a novice about these
things so sorry if asking something obvious...<span
class="HOEnZb"><font color="#888888"><br>
<br>
tk</font></span><span class=""><br>
<br>
<br>
<div>On 8/6/2015 7:40 AM, Cory Quammen wrote:<br>
</div>
</span>
<div>
<div class="h5">
<blockquote type="cite">
<div dir="ltr">TK,
<div><br>
</div>
<div>You can get the orientation in angle-axis
representation with</div>
<div><br>
</div>
<div>double wxyz[4];</div>
<div>t->GetOrientationWXYZ(wxyz);</div>
<div><br>
</div>
<div>From the docs [1]:</div>
<div><br>
</div>
<div><span
style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px">The
angle (w) is in degrees and the axis (xyz) is
a unit vector.</span><br>
</div>
<div><br>
</div>
<div>You should be able to apply this rotation to
your molecule model's RotateAboutVector
function.</div>
<div><br>
</div>
<div>HTH,</div>
<div>Cory</div>
<div><span
style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px"><br>
</span></div>
<div><span
style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px">[1] </span><font
color="#000000" face="Roboto, sans-serif"><span
style="font-size:14px;line-height:22px"><a
moz-do-not-send="true"
href="http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f"
target="_blank"><a class="moz-txt-link-freetext" href="http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f">http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f</a></a></span></font></div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Aug 5, 2015 at
8:54 PM, Totte Karlsson <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:totte@dunescientific.com"
target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:totte@dunescientific.com">totte@dunescientific.com</a></a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">Hello,<br>
I'm using vtk to visualize 3D models of
molecules.<br>
The actual molecular model is decoupled from
vtk code, and visualization is implemented
using a model-view kind of design.<br>
<br>
Currently I have the following challenge. If a
user wants to manipulate the absolute
orientation of the molecule, it is done by
manipulating the underlying model using
rotation functions, like RotateX, RotateY,
RotateAboutVector, and translation functions
TranslateX, Y etc.<br>
<br>
For now 3D rotations are simply done using two
scrollbars, one horizontal and one vertical,
causing the underlying model being rotated
about the vtk viewUP vector and the vtk
cameraPlane normal respectively. This works
fine, but is not so intuitive for the user.<br>
<br>
Instead I believe allowing interaction with
something like a box widget that encapsulates
the molecule view, (with disabled handles),
would be better.<br>
<br>
The challenge is how to figure out how to
capture the boxwidgets orientation in a
callback, and using this information in order
to manipulate the underlying molecular model.<br>
<br>
For example, a boxwidget callback (from
boxwidget example at <a
moz-do-not-send="true"
href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget"
rel="noreferrer" target="_blank"><a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget</a></a>):<br>
<br>
class vtkMyCallback : public vtkCommand<br>
{<br>
public:<br>
static vtkMyCallback *New() {
return new vtkMyCallback; }<br>
<br>
virtual void Execute(vtkObject *caller,
unsigned long, void*)<br>
{<br>
vtkSmartPointer<vtkTransform> t
= vtkSmartPointer<vtkTransform>::New();<br>
vtkBoxWidget *widget =
reinterpret_cast<vtkBoxWidget*>(caller);<br>
widget->GetTransform(t);<br>
<br>
double* angles?? =
t->GetOrientation();<br>
if(aMoleculeModel)<br>
{<br>
//Use some secret(!) code to
manipulate orientation of a molecule to
'rotate' it together with the boxWidget<br>
aMoleculeModel->RotateZ(??);<br>
aMoleculeModel->RotateY(??);<br>
aMoleculeModel->RotateZ(??);<br>
}<br>
}<br>
Molecule* aMoleculeModel;<br>
<br>
Anyone seeing how to do this or have some
pointers?<br>
<br>
Cheers,<br>
tk<br>
<br>
_______________________________________________<br>
Powered by <a moz-do-not-send="true"
href="http://www.kitware.com"
rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a
moz-do-not-send="true"
href="http://www.kitware.com/opensource/opensource.html"
target="_blank"><a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></a><br>
<br>
Please keep messages on-topic and check the
VTK FAQ at: <a moz-do-not-send="true"
href="http://www.vtk.org/Wiki/VTK_FAQ"
target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a
moz-do-not-send="true"
href="http://markmail.org/search/?q=vtkusers"
rel="noreferrer" target="_blank"><a class="moz-txt-link-freetext" href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a></a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a moz-do-not-send="true"
href="http://public.kitware.com/mailman/listinfo/vtkusers"
rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div>Cory Quammen<br>
R&D Engineer<br>
Kitware, Inc.</div>
</div>
</blockquote>
<br>
</div>
</div>
<span class="">
<div>-- <br>
<hr size="1">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><a moz-do-not-send="true"
href="http://www.dunescientific.com/"
target="_blank"><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/ds_logo_233x60.png"
alt="" border="0" height="40"></a></td>
<td><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="15"></td>
<td bgcolor="#cccccc"><img
moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="1"></td>
<td><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="10"></td>
<td>
<div style="font-size:10px;color:#666666">
Totte Karlsson: <a moz-do-not-send="true"
href="mailto:totte@dunescientific.com"
target="_blank">totte@dunescientific.com</a>
or <a moz-do-not-send="true"
href="tel:%20425%20%20780-9648"
value="+14257809648" target="_blank">(425)
780-9648</a><br>
<a moz-do-not-send="true"
href="http://www.dunescientific.com/"
target="_blank">http://www.dunescientific.com/</a>
<br>
© 2015 Dune Scientific, LLC. All rights
reserved. </div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</span></div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">Cory Quammen<br>
R&D Engineer<br>
Kitware, Inc.</div>
</div>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<hr size="1">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><a moz-do-not-send="true"
href="http://www.dunescientific.com/" target="_blank"><img
moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/ds_logo_233x60.png"
alt="" border="0" height="40"></a></td>
<td><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="15"></td>
<td bgcolor="#cccccc"><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="1"></td>
<td><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="10"></td>
<td>
<div style="font-size:10px;color:#666666"> Totte Karlsson:
<a moz-do-not-send="true"
href="mailto:totte@dunescientific.com" target="_blank">totte@dunescientific.com</a>
or <a moz-do-not-send="true"
href="tel:%20425%20%20780-9648" value="+14257809648"
target="_blank">(425) 780-9648</a><br>
<a moz-do-not-send="true"
href="http://www.dunescientific.com/" target="_blank">http://www.dunescientific.com/</a>
<br>
© 2015 Dune Scientific, LLC. All rights reserved. </div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</body>
</html>