<div dir="ltr"><div><br></div><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 6, 2015 at 4:43 PM, Totte Karlsson <span dir="ltr"><<a 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"><span class="">
    <br>
    <br>
    <div>On 8/6/2015 1:35 PM, Cory Quammen
      wrote:<br>
    </div>
    <blockquote 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 style="font-size:12.8000001907349px"><br>
            anActor->RotateWXYZ(wxyz[0], wxyz[1], wxyz[2], wxyz[3]);</span><br>
        </div>
        <div><span 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></span>
    The anActor is just a regular vtkActor (a cone) for now. <br>
    <br>
    The 'reset' is effectively the line of code:<span class=""><br>
     anActor->RotateWXYZ(-lastAngle, lastWXYZ[1], lastWXYZ[2],
    lastWXYZ[3]);</span><span><br>
      <br>
      One would need to store this input somewhere in order to do this,
      as it would be different each time.<br></span></div></blockquote><div><br></div><div>I guess I don't see the problem here. You have a reference to the actor here, and the actor has the orientation. Did you try this approach out and it didn't work? vtkActor::SetOrientation(0, 0, 0) will reset the rotation for you.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span>
      <br>
      What I'm looking for is instead to perform incremental rotations,
      avoiding the "transforming back", i.e. (reset) part.</span></div></blockquote><div><br></div><div>I don't know of a quick and easy way to get the incremental rotation you are looking for, hence my suggestion.<br></div><div><br></div><div>Cory</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span><span class="HOEnZb"><font color="#888888"><br>
      <br>
      tk<br>
    </font></span></span><div><div class="h5"><br>
    <blockquote 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 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><br>
                <br>
                    virtual void Execute(vtkObject *caller, unsigned
                long, void*)<br>
                    {<br>
              </span><span>         static int callCount = 0;<br>
              </span>         static double lastAngle = 0;<br>
                      static double lastVec[3] = {0,0,0};<span><br>
                        vtkSmartPointer<vtkTransform> t =   
                vtkSmartPointer<vtkTransform>::New();<br>
              </span>         static vtkSmartPointer<vtkTransform>
              lastTransform =
              vtkSmartPointer<vtkTransform>::New();<span><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><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><font color="#888888"><br>
                  <br>
                  tk</font></span><span><br>
                <br>
                <br>
                <div>On 8/6/2015 7:40 AM, Cory Quammen wrote:<br>
                </div>
              </span>
              <div>
                <div>
                  <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 href="http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f" target="_blank"></a><a href="http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f</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 href="mailto:totte@dunescientific.com" target="_blank"></a><a 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">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 href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget" rel="noreferrer" target="_blank"></a><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget</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 href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
                          <br>
                          Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank"></a><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
                          <br>
                          Please keep messages on-topic and check the
                          VTK FAQ at: <a 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 href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank"></a><a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
                          <br>
                          Follow this link to subscribe/unsubscribe:<br>
                          <a 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>
                <div>-- <br>
                  <hr size="1">
                  <table border="0" cellpadding="0" cellspacing="0">
                    <tbody>
                      <tr>
                        <td><a href="http://www.dunescientific.com/" target="_blank"><img src="http://www.dunescientific.com/images/email/ds_logo_233x60.png" alt="" border="0" height="40"></a></td>
                        <td><img src="http://www.dunescientific.com/images/email/spacer.gif" alt="" border="0" height="1" width="15"></td>
                        <td bgcolor="#cccccc"><img src="http://www.dunescientific.com/images/email/spacer.gif" alt="" border="0" height="1" width="1"></td>
                        <td><img 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 href="mailto:totte@dunescientific.com" target="_blank">totte@dunescientific.com</a>
                            or <a href="tel:%20425%20%20780-9648" value="+14257809648" target="_blank">(425)
                              780-9648</a><br>
                            <a 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>Cory Quammen<br>
          R&D Engineer<br>
          Kitware, Inc.</div>
      </div>
    </blockquote>
    <br>
    <div>-- <br>
      
      <hr size="1">
      <table border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td><a href="http://www.dunescientific.com/" target="_blank"><img src="http://www.dunescientific.com/images/email/ds_logo_233x60.png" alt="" border="0" height="40"></a></td>
            <td><img src="http://www.dunescientific.com/images/email/spacer.gif" alt="" border="0" height="1" width="15"></td>
            <td bgcolor="#cccccc"><img src="http://www.dunescientific.com/images/email/spacer.gif" alt="" border="0" height="1" width="1"></td>
            <td><img 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 href="mailto:totte@dunescientific.com" target="_blank">totte@dunescientific.com</a>
                or <a href="tel:%20425%20%20780-9648" value="+14257809648" target="_blank">(425) 780-9648</a><br>
                <a 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>
  </div></div></div>

<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></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></div>