<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 07/06/17 14:15, Elvis Stansvik
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAE-7VJnG15HEOQuMx-_C4VApUrn29PRM+tSdQ0oSPK3W4YzsPw@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">2017-03-13 10:37 GMT+01:00 Elvis
            Stansvik <span dir="ltr"><<a
                href="mailto:elvis.stansvik@orexplore.com"
                target="_blank" moz-do-not-send="true">elvis.stansvik@orexplore.com</a>></span>:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div class="HOEnZb">
                <div class="h5">2017-03-13 10:32 GMT+01:00 Elvis
                  Stansvik <<a
                    href="mailto:elvis.stansvik@orexplore.com"
                    moz-do-not-send="true">elvis.stansvik@orexplore.com</a>><wbr>:<br>
                  > 2017-03-07 16:10 GMT+01:00 Elvis Stansvik <<a
                    href="mailto:elvis.stansvik@orexplore.com"
                    moz-do-not-send="true">elvis.stansvik@orexplore.com</a>><wbr>:<br>
                  >> 2017-03-07 15:58 GMT+01:00 Elvis Stansvik
                  <<a href="mailto:elvis.stansvik@orexplore.com"
                    moz-do-not-send="true">elvis.stansvik@orexplore.com</a>><wbr>:<br>
                  >>> 2017-03-07 15:53 GMT+01:00 David Cole
                  <<a href="mailto:DLRdave@aol.com"
                    moz-do-not-send="true">DLRdave@aol.com</a>>:<br>
                  >>>> On Windows, we make resizing our
                  windows interactive by getting the<br>
                  >>>> vtkInteractorStyle associated with
                  the render window containing the<br>
                  >>>> volume rendering, and then calling
                  StartState at resize begin time<br>
                  >>>> (OnEnterSizeMove) and StopState at
                  resize end time (OnExitSizeMove).<br>
                  >>>><br>
                  >>>> I suppose there may be a Qt
                  equivalent which works on many platforms<br>
                  >>>> for beginning and ending a resize
                  action. If not, there are definitely<br>
                  >>>> platform-specific hooks you can
                  intercept to achieve smooth resizing<br>
                  >>>> with this technique.<br>
                  >>>><br>
                  >>>> Wrapping anything in a
                  StartState/StopState pair on the<br>
                  >>>> vtkInteractorStyle will cause
                  "interactive frame rate rendering" to be<br>
                  >>>> in effect in between the calls. The
                  volume rendering is not as nice<br>
                  >>>> looking during interactions, but it
                  is definitely speedier.<br>
                  >>><br>
                  >>> Ah, I was just about to reply to myself
                  with some further information:<br>
                  >>><br>
                  >>> I know that during interaction, the
                  quality of the rendering is<br>
                  >>> decreased, and that this can account for
                  some of the performance<br>
                  >>> discrepancy I'm seeing between camera
                  movement vs window resize.<br>
                  >>><br>
                  >>> But, I've experimented with disabling the
                  quality degradation during<br>
                  >>> interactions (so that the two should be
                  on "equal footing"), and the<br>
                  >>> resizing is still much more choppy than
                  when interacting with the<br>
                  >>> camera. So there must be something else.<br>
                  >>><br>
                  >>> In fact, in the screencast I showed, I
                  wasn't using the volume<br>
                  >>> renderer's default built-in quality
                  degradation during interaction.<br>
                  >>> I'm using my own since I've found that
                  VTKs own is a little too<br>
                  >>> aggressive in degrading the quality to
                  maintain frame rate.<br>
                  >><br>
                  >> To illustrate, look at the attached screen
                  recording. In this test<br>
                  >> case, I'm using<br>
                  >><br>
                  >>     mapper-><wbr>AutoAdjustSampleDistancesOff()<wbr>;<br>
                  >>     mapper->SetSampleDistance(0.<wbr>0002);<br>
                  >><br>
                  >> on my vtkGPUVolumeRayCastMapper, to turn off
                  the automatic adjustment<br>
                  >> of sample distance during interactions, and
                  hardcode the sample<br>
                  >> distance to 0.0002.<br>
                  >><br>
                  >> Notice how the rendering is still reasonably
                  smooth during<br>
                  >> interaction, but during resize, the rendering
                  sometimes lags with 100s<br>
                  >> of milliseconds. During the resizing I was
                  getting warnings like<br>
                  >><br>
                  >> Warning: In /buildbot/vtk7-builder/build/<wbr>Rendering/OpenGL2/<wbr>vtkXOpenGLRenderWindow.cxx,<br>
                  >> line 1207<br>
                  >> vtkXOpenGLRenderWindow (0x2a629d0): warning
                  window did not resize in<br>
                  >> the allotted time<br>
                  >><br>
                  >> printed.<br>
                  ><br>
                  > No ideas where this discrepancy in refresh rate,
                  despite automatic<br>
                  > adjustment of sample distance being turned off,
                  comes from?<br>
                  ><br>
                  > At the moment I've worked around it by simply
                  resorting to bounding<br>
                  > box rendering when my VTK windows are resized,
                  since the choppy resize<br>
                  > behavior was quite jarring. But that's a kludge
                  and I'd much rather<br>
                  > find the real problem :/<br>
                  ><br>
                  > Below is a minimal test case, and I'm attaching a
                  video where I first<br>
                  > interact with the volume rendering, giving a
                  smooth albeit a little<br>
                  > slow frame rate, and then resizing the window,
                  which gives a jerky and<br>
                  > choppy rendering.<br>
                  ><br>
                  > This was on a Thinkpad T440s laptop with Intel HD
                  4400 graphics. VTK<br>
                  > 7.1 and Qt 5.5.1 running on Kubuntu 16.04.<br>
                  ><br>
                  > Elvis<br>
                  ><br>
                  ><br>
                  > main.cpp:<br>
                  ><br>
                  > #include <random><br>
                  ><br>
                  > #include <vtkCamera.h><br>
                  > #include <vtkColorTransferFunction.h><br>
                  > #include <vtkGPUVolumeRayCastMapper.h><br>
                  > #include <vtkImageData.h><br>
                  > #include <vtkNew.h><br>
                  > #include <vtkPiecewiseFunction.h><br>
                  > #include <vtkRenderer.h><br>
                  > #include <vtkRenderWindow.h><br>
                  > #include <vtkRenderWindowInteractor.h><br>
                  > #include <vtkVolume.h><br>
                  > #include <vtkVolumeProperty.h><br>
                  ><br>
                  > int main(int argc, char *argv[])<br>
                  > {<br>
                  >     vtkNew<<wbr>vtkColorTransferFunction>
                  colorFunction;<br>
                  >     colorFunction->AddRGBPoint(0.<wbr>0, 0.0,
                  0.0, 0.0);<br>
                  >     colorFunction->AddRGBPoint(1.<wbr>0, 0.0,
                  0.0, 0.0);<br>
                  ><br>
                  >     vtkNew<vtkPiecewiseFunction>
                  opacityFunction;<br>
                  >     opacityFunction->AddPoint(0.0, 0.0);<br>
                  >     opacityFunction->AddPoint(1.0, 0.02);<br>
                  ><br>
                  >     vtkNew<vtkImageData> data;<br>
                  >     data->SetExtent(0, 250, 0, 250, 0, 500);<br>
                  >     data->AllocateScalars(VTK_<wbr>FLOAT, 1);<br>
                  >     std::random_device device;<br>
                  >     std::mt19937 engine(device());<br>
                  >     std::uniform_real_<wbr>distribution<>
                  distribution(0, 1);<br>
                  >     auto dataPointer = static_cast<float
                  *>(data->GetScalarPointer());<br>
                  >     for (int i = 0; i < 250*250*500; ++i) {<br>
                  >         *dataPointer = distribution(engine);<br>
                  >         ++dataPointer;<br>
                  >     }<br>
                  ><br>
                  >     vtkNew<<wbr>vtkGPUVolumeRayCastMapper>
                  mapper;<br>
                  >     mapper->SetInputData(data.Get(<wbr>));<br>
                  <br>
                </div>
              </div>
              Sorry, the test case should have had<br>
              <br>
                  mapper-><wbr>AutoAdjustSampleDistancesOff()<wbr>;<br>
                  mapper->SetSampleDistance(1);<br>
              <br>
              here, to show that the discrepancy is there even when
              automatic<br>
              adjustment of sample distance is turned off.<br>
              <br>
              The result is the same, the rendering is keeping up much
              better during<br>
              interaction that it is during window resize.<br>
              <br>
              I can understand if it's a little heavier to re-render
              after window<br>
              resize, but not by that much, so I think something is
              wrong<br>
            </blockquote>
            <div><br>
            </div>
            <div>Anybody have some more advise on this? I'm seeing the
              same problem in PV 5.4.<br>
              <br>
            </div>
            <div>I had hoped that maybe the new QVTKOpenGLWidget would
              change things, but it hasn't. I would really like to
              remove the workarounds I have in place that degrades the
              rendering to bounding boxes during widget resizing.<br>
              <br>
            </div>
            <div>Elvis<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    Hi Elvis,<br>
    if you are using Qt5.5 and VTK the problem may be related to this
    bug:<br>
    <br>
<a class="moz-txt-link-freetext" href="http://vtk.1045678.n5.nabble.com/Delayed-mouse-interaction-due-to-event-loop-bug-in-Qt5-td5730474.html">http://vtk.1045678.n5.nabble.com/Delayed-mouse-interaction-due-to-event-loop-bug-in-Qt5-td5730474.html</a><br>
    <br>
    <a class="moz-txt-link-freetext" href="https://bugreports.qt.io/browse/QTBUG-40889">https://bugreports.qt.io/browse/QTBUG-40889</a><br>
    <br>
    I have this problem with VTK6 and VTK7 using Ubuntu 16.04 but it was
    fixed in Ubuntu 16.10<br>
    that has Qt5.6 which fixes the bug. Have you tried your program on a
    newer version of Ubuntu?<br>
    <br>
    Manfred<br>
    <br>
    <br>
    <blockquote type="cite"
cite="mid:CAE-7VJnG15HEOQuMx-_C4VApUrn29PRM+tSdQ0oSPK3W4YzsPw@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> <br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <span class="HOEnZb"><font color="#888888"><br>
                  Elvis<br>
                </font></span>
              <div class="HOEnZb">
                <div class="h5"><br>
                  ><br>
                  >     vtkNew<vtkVolumeProperty> property;<br>
                  >     property->SetScalarOpacity(<wbr>opacityFunction.Get());<br>
                  >     property->SetColor(<wbr>colorFunction.Get());<br>
                  ><br>
                  >     vtkNew<vtkVolume> volume;<br>
                  >     volume->SetMapper(mapper.Get()<wbr>);<br>
                  >     volume->SetProperty(property.<wbr>Get());<br>
                  ><br>
                  >     vtkNew<vtkRenderer> renderer;<br>
                  >     renderer->AddVolume(volume.<wbr>Get());<br>
                  >     renderer->SetBackground(1.0, 1.0, 1.0);<br>
                  ><br>
                  >     vtkNew<vtkRenderWindow> window;<br>
                  >     window->AddRenderer(renderer.<wbr>Get());<br>
                  ><br>
                  >     renderer->ResetCamera();<br>
                  ><br>
                  >     vtkNew<<wbr>vtkRenderWindowInteractor>
                  interactor;<br>
                  >     interactor->SetRenderWindow(<wbr>window.Get());<br>
                  >     interactor->Start();<br>
                  ><br>
                  >     return 0;<br>
                  > }<br>
                  ><br>
                  ><br>
                  > CMakeLists.txt:<br>
                  ><br>
                  > cmake_minimum_required(VERSION 3.1)<br>
                  ><br>
                  > project(TestCase)<br>
                  ><br>
                  > set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}
                  /opt/VTK7)<br>
                  ><br>
                  > find_package(VTK 7.1 COMPONENTS<br>
                  >     vtkCommonCore<br>
                  >     vtkCommonDataModel<br>
                  >     vtkCommonExecutionModel<br>
                  >     vtkCommonMath<br>
                  >     vtkInteractionStyle<br>
                  >     vtkRenderingCore<br>
                  >     vtkRenderingOpenGL2<br>
                  >     vtkRenderingVolume<br>
                  >     vtkRenderingVolumeOpenGL2<br>
                  >     REQUIRED<br>
                  > )<br>
                  ><br>
                  > add_executable(TestCase WIN32 main.cpp)<br>
                  ><br>
                  > target_link_libraries(TestCase PUBLIC<br>
                  >     vtkCommonCore<br>
                  >     vtkCommonDataModel<br>
                  >     vtkCommonExecutionModel<br>
                  >     vtkCommonMath<br>
                  >     vtkInteractionStyle<br>
                  >     vtkRenderingCore<br>
                  >     vtkRenderingOpenGL2<br>
                  >     vtkRenderingVolume<br>
                  >     vtkRenderingVolumeOpenGL2<br>
                  > )<br>
                  ><br>
                  > target_include_directories(<wbr>TestCase PUBLIC<br>
                  >     ${VTK_INCLUDE_DIRS}<br>
                  > )<br>
                  ><br>
                  > target_compile_definitions(<wbr>TestCase PUBLIC<br>
                  >     ${VTK_DEFINITIONS}<br>
                  > )<br>
                  ><br>
                  > set_target_properties(TestCase PROPERTIES<br>
                  >     CXX_STANDARD 14<br>
                  >     CXX_STANDARD_REQUIRED ON<br>
                  > )<br>
                  ><br>
                  >><br>
                  >> Elvis<br>
                  >><br>
                  >>><br>
                  >>> Elvis<br>
                  >>><br>
                  >>>><br>
                  >>>><br>
                  >>>> HTH,<br>
                  >>>> David C.<br>
                  >>>><br>
                  >>>><br>
                  >>>><br>
                  >>>> On Tue, Mar 7, 2017 at 9:33 AM, Elvis
                  Stansvik<br>
                  >>>> <<a
                    href="mailto:elvis.stansvik@orexplore.com"
                    moz-do-not-send="true">elvis.stansvik@orexplore.com</a>>
                  wrote:<br>
                  >>>>> 2017-03-07 15:17 GMT+01:00 Elvis
                  Stansvik <<a
                    href="mailto:elvis.stansvik@orexplore.com"
                    moz-do-not-send="true">elvis.stansvik@orexplore.com</a>><wbr>:<br>
                  >>>>>> Hi all,<br>
                  >>>>>><br>
                  >>>>>> I'm using Qt 5.5.1 and VTK
                  7.1. The program has a couple of VTKWidget<br>
                  >>>>>> showing volume renderings, as
                  well as a window with a chart.<br>
                  >>>>><br>
                  >>>>> Actually, I'm able to reproduce
                  this behavior when not using Qt at<br>
                  >>>>> all, but just a regular render
                  window + interactor setup with a single<br>
                  >>>>> volume rendered. Camera
                  interaction is nice and fast, but resizing the<br>
                  >>>>> window, the rendering is very
                  choppy. I'm also getting<br>
                  >>>>><br>
                  >>>>> Warning: In
                  /buildbot/vtk7-builder/build/<wbr>Rendering/OpenGL2/<wbr>vtkXOpenGLRenderWindow.cxx,<br>
                  >>>>> line 1207<br>
                  >>>>> vtkXOpenGLRenderWindow
                  (0x1353a10): warning window did not resize in<br>
                  >>>>> the allotted time<br>
                  >>>>><br>
                  >>>>> printed to the console, so it
                  seems VTK detects what I'm seeing<br>
                  >>>>> visually. I did not get this
                  warning printed in the Qt + VTK app.<br>
                  >>>>><br>
                  >>>>> Elvis<br>
                  >>>>><br>
                  >>>>>><br>
                  >>>>>> Have a look at the attached
                  screen recording. Notice how camera<br>
                  >>>>>> interaction in both VTK
                  render windows is nice and smooth, but when<br>
                  >>>>>> resizing the windows, the
                  updating of the renderings is very<br>
                  >>>>>> slow/choppy.<br>
                  >>>>>><br>
                  >>>>>> I've been trying to debug
                  this, or at least finding a way of<br>
                  >>>>>> mitigating it. Could it be
                  that Qt is delivering too many resize<br>
                  >>>>>> events? Has anyone else dealt
                  with this problem?<br>
                  >>>>>><br>
                  >>>>>> Thanks in advance for any
                  advice,<br>
                  >>>>>> Elvis<br>
                  >>>>> ______________________________<wbr>_________________<br>
                  >>>>> Powered by <a
                    href="http://www.kitware.com" rel="noreferrer"
                    target="_blank" moz-do-not-send="true">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"
                    moz-do-not-send="true">http://www.kitware.com/<wbr>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"
                    moz-do-not-send="true">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
                  >>>>><br>
                  >>>>> Search the list archives at: <a
                    href="http://markmail.org/search/?q=vtkusers"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
                  >>>>><br>
                  >>>>> Follow this link to
                  subscribe/unsubscribe:<br>
                  >>>>> <a
                    href="http://public.kitware.com/mailman/listinfo/vtkusers"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>

Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>

Please keep messages on-topic and check the VTK FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>

Search the list archives at: <a class="moz-txt-link-freetext" href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a>

Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a>
</pre>
    </blockquote>
  </body>
</html>