<div dir="ltr">Dear vtk users,<div><br></div><div><div>I am trying to customize the FourPaneViewer example from the provided VTK examples. The full code of the example can be found in VTK_DIR/Examples/GUI/Qt/FourPaneViewer. </div>
<div><br></div><div>The example embeds in Qt 4 QVTKWidget views and performs reslicing. One of the views renders (3) vtkImagePlaneWidgets and each of the other 3 views renders a vtkResliceImageViewer.</div><div><br></div>
<div>What I am trying to achieve is disable in the 3 vtkResliceImageViewers any events triggered by pressing keys on the keyboard, i.e. I want to restrict the user and allow him to interact with these widgets using only the mouse. </div>
<div><br></div><div>The way I have tried to do this is by subclassing the vtkInteractorStyle class as follows:</div><div><br></div><div>    // Define interaction style</div><div>    class KeyPressInteractorStyle : public vtkInteractorStyle</div>
<div>    {</div><div>    public:</div><div>    <span class="" style="white-space:pre">        </span>static KeyPressInteractorStyle* New();</div><div>    <span class="" style="white-space:pre">        </span>vtkTypeMacro(KeyPressInteractorStyle, vtkInteractorStyle);</div>
<div>    </div><div>    <span class="" style="white-space:pre">        </span>virtual void OnKeyPress() </div><div>    <span class="" style="white-space:pre">        </span>{</div><div>    <span class="" style="white-space:pre">                </span>// Get the keypress</div>
<div>    <span class="" style="white-space:pre">                </span>vtkRenderWindowInteractor *rwi = this-&gt;Interactor;</div><div>    <span class="" style="white-space:pre">                </span>std::string key = rwi-&gt;GetKeySym();</div><div>
    </div><div>    <span class="" style="white-space:pre">                </span>// Output the key that was pressed</div><div>    <span class="" style="white-space:pre">                </span>std::cout &lt;&lt; &quot;Pressed &quot; &lt;&lt; key &lt;&lt; std::endl;</div>
<div>    <span class="" style="white-space:pre">                </span>qDebug()&lt;&lt; &quot;Pressed &quot; &lt;&lt; rwi-&gt;GetKeySym();</div><div>    </div><div>    <span class="" style="white-space:pre">                </span>// Forward events</div>
<div>    <span class="" style="white-space:pre">                </span>vtkInteractorStyle::OnKeyPress();</div><div>    <span class="" style="white-space:pre">        </span>}</div><div>    </div><div>    };</div><div>    vtkStandardNewMacro(KeyPressInteractorStyle);</div>
<div><br></div><div>and then for each of the 3 views, the customised interaction style is applied as follows:</div><div><br></div><div>        vtkSmartPointer&lt;KeyPressInteractorStyle&gt; style = </div><div>    vtkSmartPointer&lt;KeyPressInteractorStyle&gt;::New();</div>
<div>        </div><div>        this-&gt;ui-&gt;view1-&gt;GetRenderWindow()-&gt;GetInteractor()-&gt;SetInteractorStyle(style);</div><div>        style-&gt;SetCurrentRenderer(riw[0]-&gt;GetRenderer());</div><div>        </div>
<div>        this-&gt;ui-&gt;view1-&gt;SetRenderWindow(riw[0]-&gt;GetRenderWindow());</div><div>        riw[0]-&gt;SetupInteractor(this-&gt;ui-&gt;view1-&gt;GetRenderWindow()-&gt;GetInteractor());</div><div><br></div><div>
where view1 is of type QVTKWidget  and riw[i] of type vtkResliceImageViewer.</div><div><br></div><div>Unfortunately the approach I am using has no effect. The keyboard events are not captured at all by the interaction style. Nothing is printed in the console. It should be noted that if I apply the customised style on the 4th view for vtkImagePlaneWidgets, then it works.</div>
<div><br></div><div>Can someone help me to fix this? I am new to VTK and any help will be much appreciated. </div><div><br></div><div>Thanks for your help,</div></div></div>