<div dir="ltr">Thanks for your reply Alex.<div><br></div><div>I have tried what you have suggested but it sill doesn't work. I believe the problem is on how I apply the new style on the three views. As I have noted in my original post, when I apply the customised style on the 4th view it works. The way I did that for the 4th view is:</div>
<div><br></div><div><div><span class="" style="white-space:pre">        </span>vtkSmartPointer< vtkRenderer > ren =<span class="" style="white-space:pre">        </span>vtkSmartPointer< vtkRenderer >::New();</div><div><br></div>
<div><span class="" style="white-space:pre">        </span>this->ui->view4->GetRenderWindow()->AddRenderer(ren);</div><div><span class="" style="white-space:pre">        </span>vtkRenderWindowInteractor *iren = this->ui->view4->GetInteractor();</div>
<div><span class="" style="white-space:pre">        </span>iren->SetInteractorStyle(style);</div><div><span class="" style="white-space:pre">        </span>style->SetCurrentRenderer(ren);</div></div><div><br></div><div>Any other suggestions?</div>
<div><br></div><div>Thanks.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 9, 2013 at 9:25 PM, Alex Malyushytskyy <span dir="ltr"><<a href="mailto:alexmalvtk@gmail.com" target="_blank">alexmalvtk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><table><tbody><tr><td>Override vtkInteractorStyle::OnChar </td>
<td>(</td>
<td>)</td><td><br><br></td></tr></tbody></table>Make it do nothing. <br><br></div>Alex<br><div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Mon, Sep 9, 2013 at 9:37 AM, Panayiotis Georgiou <span dir="ltr"><<a href="mailto:ps.georgiou@gmail.com" target="_blank">ps.georgiou@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><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 style="white-space:pre-wrap">        </span>static KeyPressInteractorStyle* New();</div><div> <span style="white-space:pre-wrap">        </span>vtkTypeMacro(KeyPressInteractorStyle, vtkInteractorStyle);</div>
<div> </div><div> <span style="white-space:pre-wrap">        </span>virtual void OnKeyPress() </div><div> <span style="white-space:pre-wrap">        </span>{</div><div> <span style="white-space:pre-wrap">                </span>// Get the keypress</div>
<div> <span style="white-space:pre-wrap">                </span>vtkRenderWindowInteractor *rwi = this->Interactor;</div><div> <span style="white-space:pre-wrap">                </span>std::string key = rwi->GetKeySym();</div><div>
</div><div> <span style="white-space:pre-wrap">                </span>// Output the key that was pressed</div><div> <span style="white-space:pre-wrap">                </span>std::cout << "Pressed " << key << std::endl;</div>
<div> <span style="white-space:pre-wrap">                </span>qDebug()<< "Pressed " << rwi->GetKeySym();</div><div> </div><div> <span style="white-space:pre-wrap">                </span>// Forward events</div>
<div> <span style="white-space:pre-wrap">                </span>vtkInteractorStyle::OnKeyPress();</div><div> <span style="white-space:pre-wrap">        </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<KeyPressInteractorStyle> style = </div><div> vtkSmartPointer<KeyPressInteractorStyle>::New();</div>
<div> </div><div> this->ui->view1->GetRenderWindow()->GetInteractor()->SetInteractorStyle(style);</div><div> style->SetCurrentRenderer(riw[0]->GetRenderer());</div><div> </div>
<div> this->ui->view1->SetRenderWindow(riw[0]->GetRenderWindow());</div><div> riw[0]->SetupInteractor(this->ui->view1->GetRenderWindow()->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>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" 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">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>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>