<div dir="ltr">Hello,<div><br></div><div>I am essentially trying to build on the FourPaneViewer example which you can find from here:</div><div><a href="https://github.com/Kitware/VTK/tree/master/Examples/GUI/Qt/FourPaneViewer">https://github.com/Kitware/VTK/tree/master/Examples/GUI/Qt/FourPaneViewer</a></div>
<div><br></div><div>The major changes compared to the original code is the inclusion in <span style="font-family:arial,sans-serif">QtVTKRenderWindows.cxx</span> of the subclass <span style="font-size:13px;font-family:arial,sans-serif">KeyPressInteractorStyle and the 3 lines of code where I apply the new style to view1. Both of these changes were included in my first post.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Below I have including the code I am using which consists of 3 files: </span><font face="arial, sans-serif">QtVTKRenderWindows.cxx, QtVTKRenderWindows.h and QtVTKRenderWindowsApp.cxx</font></div>
<div><font face="arial, sans-serif"><br></font></div><div>You can download the .ui file from the above link. <font face="arial, sans-serif"><br></font></div><div><br></div><div><font face="arial, sans-serif">Note: you may want to change the path to the Dicom files at </font><span style="font-family:arial,sans-serif">reader->SetDirectoryName(...)</span></div>
<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">Thanks for your help.</span></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">==================</font></div>
<div><span style="font-family:arial,sans-serif">QtVTKRenderWindows.h</span><font face="arial, sans-serif"><br></font></div><div><span style="font-family:arial,sans-serif">==================</span></div><div><span style="font-family:arial,sans-serif"><br>
</span></div><div><div><font face="arial, sans-serif">#ifndef QtVTKRenderWindows_H</font></div><div><font face="arial, sans-serif">#define QtVTKRenderWindows_H</font></div><div><font face="arial, sans-serif"><br></font></div>
<div><font face="arial, sans-serif">#include "vtkSmartPointer.h"</font></div><div><font face="arial, sans-serif">#include "vtkResliceImageViewer.h"</font></div><div><font face="arial, sans-serif">#include "vtkImagePlaneWidget.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkDistanceWidget.h"</font></div><div><font face="arial, sans-serif">#include "vtkResliceImageViewerMeasurements.h"</font></div><div><font face="arial, sans-serif">#include <QMainWindow></font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">// Forward Qt class declarations</font></div><div><font face="arial, sans-serif">class Ui_QtVTKRenderWindows;</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif">class QtVTKRenderWindows : public QMainWindow</font></div><div><font face="arial, sans-serif">{</font></div><div><font face="arial, sans-serif"> Q_OBJECT</font></div><div>
<font face="arial, sans-serif">public:</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"> // Constructor/Destructor</font></div><div><font face="arial, sans-serif"> QtVTKRenderWindows(int argc, char *argv[]);</font></div>
<div><font face="arial, sans-serif"> ~QtVTKRenderWindows() {};</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">public slots:</font></div><div><font face="arial, sans-serif"> virtual void resliceMode(int);</font></div>
<div><font face="arial, sans-serif"> virtual void Render();</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">protected:</font></div><div><font face="arial, sans-serif"> vtkSmartPointer< vtkResliceImageViewer > riw[3];</font></div>
<div><font face="arial, sans-serif"> vtkSmartPointer< vtkImagePlaneWidget > planeWidget[3];</font></div><div><font face="arial, sans-serif"> vtkSmartPointer< vtkDistanceWidget > DistanceWidget[3];</font></div>
<div><font face="arial, sans-serif"> vtkSmartPointer< vtkResliceImageViewerMeasurements > ResliceMeasurements;</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">private:</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"> // Designer form</font></div><div><font face="arial, sans-serif"> Ui_QtVTKRenderWindows *ui;</font></div><div><font face="arial, sans-serif">};</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">#endif // QtVTKRenderWindows_H</font></div><div style="font-family:arial,sans-serif"><br></div></div><div style="font-family:arial,sans-serif">
====================</div><div style="font-family:arial,sans-serif">QtVTKRenderWindows.cxx<br></div><div style="font-family:arial,sans-serif">====================</div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><div><font face="arial, sans-serif">#include "ui_QtVTKRenderWindows.h"</font></div><div><font face="arial, sans-serif">#include "QtVTKRenderWindows.h"</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif">#include <vtkRenderer.h></font></div><div><font face="arial, sans-serif">#include <vtkRenderWindow.h></font></div><div><font face="arial, sans-serif">#include "vtkResliceImageViewer.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkResliceCursorLineRepresentation.h"</font></div><div><font face="arial, sans-serif">#include "vtkResliceCursorThickLineRepresentation.h"</font></div><div>
<font face="arial, sans-serif">#include "vtkResliceCursorWidget.h"</font></div><div><font face="arial, sans-serif">#include "vtkResliceCursorActor.h"</font></div><div><font face="arial, sans-serif">#include "vtkResliceCursorPolyDataAlgorithm.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkResliceCursor.h"</font></div><div><font face="arial, sans-serif">#include "vtkDICOMImageReader.h"</font></div><div><font face="arial, sans-serif">#include "vtkCellPicker.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkProperty.h"</font></div><div><font face="arial, sans-serif">#include "vtkPlane.h"</font></div><div><font face="arial, sans-serif">#include "vtkImageData.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkCommand.h"</font></div><div><font face="arial, sans-serif">#include "vtkPlaneSource.h"</font></div><div><font face="arial, sans-serif">#include "vtkLookupTable.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkImageMapToWindowLevelColors.h"</font></div><div><font face="arial, sans-serif">#include "vtkInteractorStyleImage.h"</font></div><div><font face="arial, sans-serif">#include "vtkImageSlabReslice.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkBoundedPlanePointPlacer.h"</font></div><div><font face="arial, sans-serif">#include "vtkDistanceWidget.h"</font></div><div><font face="arial, sans-serif">#include "vtkDistanceRepresentation.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkHandleRepresentation.h"</font></div><div><font face="arial, sans-serif">#include "vtkResliceImageViewerMeasurements.h"</font></div><div><font face="arial, sans-serif">#include "vtkDistanceRepresentation2D.h"</font></div>
<div><font face="arial, sans-serif">#include "vtkPointHandleRepresentation3D.h"</font></div><div><font face="arial, sans-serif">#include "vtkPointHandleRepresentation2D.h"</font></div><div><font face="arial, sans-serif">#include <qdebug.h></font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">#include <vtkPolyDataMapper.h></font></div><div><font face="arial, sans-serif">#include <vtkObjectFactory.h></font></div>
<div><font face="arial, sans-serif">#include <vtkActor.h></font></div><div><font face="arial, sans-serif">#include <vtkSmartPointer.h></font></div><div><font face="arial, sans-serif">#include <vtkRenderWindow.h></font></div>
<div><font face="arial, sans-serif">#include <vtkRenderer.h></font></div><div><font face="arial, sans-serif">#include <vtkRenderWindowInteractor.h></font></div><div><font face="arial, sans-serif">#include <vtkPolyData.h></font></div>
<div><font face="arial, sans-serif">#include <vtkSphereSource.h></font></div><div><font face="arial, sans-serif">#include <vtkInteractorStyleTrackballCamera.h></font></div><div><font face="arial, sans-serif">#include "QVTKWidget.h"</font></div>
<div><font face="arial, sans-serif">#include <QKeyEvent></font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">// Define interaction style</font></div><div><font face="arial, sans-serif">class KeyPressInteractorStyle : public vtkInteractorStyle</font></div>
<div><font face="arial, sans-serif">{</font></div><div><font face="arial, sans-serif">public:</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>static KeyPressInteractorStyle* New();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkTypeMacro(KeyPressInteractorStyle, vtkInteractorStyle);</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>virtual void OnKeyPress() </font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>// Get the keypress</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkRenderWindowInteractor *rwi = this->Interactor;</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>std::string key = rwi->GetKeySym();</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>// Output the key that was pressed</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>std::cout << "Pressed " << key << std::endl;</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>qDebug()<< "Pressed " << rwi->GetKeySym();</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>// Forward events</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkInteractorStyle::OnKeyPress();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>virtual void OnChar()</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>qDebug()<<"keeeey";</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">};</font></div><div><font face="arial, sans-serif">vtkStandardNewMacro(KeyPressInteractorStyle);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">//----------------------------------------------------------------------------</font></div>
<div><font face="arial, sans-serif">class vtkResliceCursorCallback : public vtkCommand</font></div><div><font face="arial, sans-serif">{</font></div><div><font face="arial, sans-serif">public:</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>static vtkResliceCursorCallback *New()</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{ </font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>return new vtkResliceCursorCallback; }</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>void Execute( vtkObject *caller, unsigned long ev,</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>void *callData )</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>if (ev == vtkCommand::KeyPressEvent)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>QKeyEvent* keyPressed = static_cast<QKeyEvent*>(callData);</font></div><div><span class="" style="white-space:pre"><font face="arial, sans-serif">                        </font></span></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>qDebug()<<"key pressed: "<<keyPressed->text();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>}</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>if (ev == vtkResliceCursorWidget::WindowLevelEvent ||</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>ev == vtkCommand::WindowLevelEvent ||</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>ev == vtkResliceCursorWidget::ResliceThicknessChangedEvent||</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>ev == vtkResliceCursorWidget::ResliceAxesChangedEvent||</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>ev == vtkResliceCursorWidget::ResetCursorEvent)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>//do nothing</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>}</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkImagePlaneWidget* ipw =</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>dynamic_cast< vtkImagePlaneWidget* >( caller );</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>if (ipw)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>double* wl = static_cast<double*>( callData );</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>if ( ipw == this->IPW[0] )</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>{</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>this->IPW[1]->SetWindowLevel(wl[0],wl[1],1);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>this->IPW[2]->SetWindowLevel(wl[0],wl[1],1);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>}</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>else if( ipw == this->IPW[1] )</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>this->IPW[0]->SetWindowLevel(wl[0],wl[1],1);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>this->IPW[2]->SetWindowLevel(wl[0],wl[1],1);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>}</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>else if (ipw == this->IPW[2])</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>this->IPW[0]->SetWindowLevel(wl[0],wl[1],1);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>this->IPW[1]->SetWindowLevel(wl[0],wl[1],1);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>}</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>}</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkResliceCursorWidget *rcw = dynamic_cast<</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>vtkResliceCursorWidget * >(caller);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>if (rcw)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>vtkResliceCursorLineRepresentation *rep = dynamic_cast<</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>vtkResliceCursorLineRepresentation * >(rcw->GetRepresentation());</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>// Although the return value is not used, we keep the get calls</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>// in case they had side-effects</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>rep->GetResliceCursorActor()->GetCursorAlgorithm()->GetResliceCursor();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>for (int i = 0; i < 3; i++)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>vtkPlaneSource *ps = static_cast< vtkPlaneSource * >(</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                        </span>this->IPW[i]->GetPolyDataAlgorithm());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>ps->SetOrigin(this->RCW[i]->GetResliceCursorRepresentation()-></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                        </span>GetPlaneSource()->GetOrigin());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>ps->SetPoint1(this->RCW[i]->GetResliceCursorRepresentation()-></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                        </span>GetPlaneSource()->GetPoint1());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>ps->SetPoint2(this->RCW[i]->GetResliceCursorRepresentation()-></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                        </span>GetPlaneSource()->GetPoint2());</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>// If the reslice plane has modified, update it on the 3D widget</font></div><div>
<font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>this->IPW[i]->UpdatePlacement();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>}</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>if(ev == vtkResliceImageViewer::SliceChangedEvent)</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>for (int i = 0; i < 3; i++)</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>vtkPlaneSource *ps = static_cast< vtkPlaneSource * >(</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                        </span>this->IPW[i]->GetPolyDataAlgorithm());</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>ps->SetOrigin(this->RCW[i]->GetResliceCursorRepresentation()-></font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                        </span>GetPlaneSource()->GetOrigin());</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>ps->SetPoint1(this->RCW[i]->GetResliceCursorRepresentation()-></font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                        </span>GetPlaneSource()->GetPoint1());</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>ps->SetPoint2(this->RCW[i]->GetResliceCursorRepresentation()-></font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                        </span>GetPlaneSource()->GetPoint2());</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>// If the reslice plane has modified, update it on the 3D widget</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                                </span>this->IPW[i]->UpdatePlacement();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>}</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>// Render everything</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>for (int i = 0; i < 3; i++)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>this->RCW[i]->Render();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>}</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>this->IPW[0]->GetInteractor()->GetRenderWindow()->Render();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkResliceCursorCallback() {}</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkImagePlaneWidget* IPW[3];</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkResliceCursorWidget *RCW[3];</font></div><div><font face="arial, sans-serif">};</font></div><div><font face="arial, sans-serif"><br></font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">QtVTKRenderWindows::QtVTKRenderWindows( int vtkNotUsed(argc), char *argv[])</font></div><div><font face="arial, sans-serif">{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui = new Ui_QtVTKRenderWindows;</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->setupUi(this);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkSmartPointer< vtkDICOMImageReader > reader =</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkSmartPointer< vtkDICOMImageReader >::New();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>//reader->SetDirectoryName(argv[1]);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>reader->SetDirectoryName("C:/Users/Panayiotis/DentalCEsse/qt_interface/build/Release/temp_dental/2/dicom");</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>reader->Update();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>int imageDims[3];</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>reader->GetOutput()->GetDimensions(imageDims);</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>for (int i = 0; i < 3; i++)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i] = vtkSmartPointer< vtkResliceImageViewer >::New();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkSmartPointer<KeyPressInteractorStyle> style = vtkSmartPointer<KeyPressInteractorStyle>::New();</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view1->GetInteractor()->SetInteractorStyle(style);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>//this->ui->view1->GetRenderWindow()->GetInteractor()->SetInteractorStyle(style);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>//this->ui->view1->GetRenderWindow()->AddRenderer(riw[0]->GetRenderer());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>style->SetCurrentRenderer(riw[0]->GetRenderer());</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view1->SetRenderWindow(riw[0]->GetRenderWindow());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>riw[0]->SetupInteractor(</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>this->ui->view1->GetRenderWindow()->GetInteractor());</font></div>
<div><span class="" style="white-space:pre"><font face="arial, sans-serif">        </font></span></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view2->SetRenderWindow(riw[1]->GetRenderWindow());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>riw[1]->SetupInteractor(</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>this->ui->view2->GetRenderWindow()->GetInteractor());</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view3->SetRenderWindow(riw[2]->GetRenderWindow());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>riw[2]->SetupInteractor(</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>this->ui->view3->GetRenderWindow()->GetInteractor());</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>for (int i = 0; i < 3; i++)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>// make them all share the same reslice cursor object.</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkResliceCursorLineRepresentation *rep =</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>vtkResliceCursorLineRepresentation::SafeDownCast(</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>riw[i]->GetResliceCursorWidget()->GetRepresentation());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->SetResliceCursor(riw[0]->GetResliceCursor());</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>rep->GetResliceCursorActor()-></font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>GetCursorAlgorithm()->SetReslicePlaneNormal(i);</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->SetInput(reader->GetOutput());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->SetSliceOrientation(i);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->SetResliceModeToAxisAligned();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkSmartPointer<vtkCellPicker> picker =</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkSmartPointer<vtkCellPicker>::New();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>picker->SetTolerance(0.005);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkSmartPointer<vtkProperty> ipwProp =</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkSmartPointer<vtkProperty>::New();</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkSmartPointer< vtkRenderer > ren =</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkSmartPointer< vtkRenderer >::New();</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view4->GetRenderWindow()->AddRenderer(ren);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkRenderWindowInteractor *iren = this->ui->view4->GetInteractor();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>//commenting out the following code succesfully applies the </font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>//'style' to view4</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>//iren->SetInteractorStyle(style);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>//style->SetCurrentRenderer(ren);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>for (int i = 0; i < 3; i++)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i] = vtkSmartPointer<vtkImagePlaneWidget>::New();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetInteractor( iren );</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetPicker(picker);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->RestrictPlaneToVolumeOn();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>double color[3] = {0, 0, 0};</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>color[i] = 1;</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->GetPlaneProperty()->SetColor(color);</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>color[i] = 0.25;</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->GetRenderer()->SetBackground( color );</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetTexturePlaneProperty(ipwProp);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->TextureInterpolateOff();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetResliceInterpolateToCubic();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetInput(reader->GetOutput());</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetPlaneOrientation(i);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetSliceIndex(imageDims[i]/2);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->DisplayTextOn();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetDefaultRenderer(ren);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->On();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->InteractionOn();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetTextureVisibility(0);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>vtkSmartPointer<vtkResliceCursorCallback> cbk =</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>vtkSmartPointer<vtkResliceCursorCallback>::New();</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>for (int i = 0; i < 3; i++)</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>cbk->IPW[i] = planeWidget[i];</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>cbk->RCW[i] = riw[i]->GetResliceCursorWidget();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->GetResliceCursorWidget()->AddObserver(</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>vtkResliceCursorWidget::ResliceAxesChangedEvent, cbk );</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->GetResliceCursorWidget()->AddObserver(</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>vtkResliceCursorWidget::WindowLevelEvent, cbk );</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->GetResliceCursorWidget()->AddObserver(</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>vtkResliceCursorWidget::ResliceThicknessChangedEvent, cbk );</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->GetResliceCursorWidget()->AddObserver(</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>vtkResliceCursorWidget::ResetCursorEvent, cbk );</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->GetInteractorStyle()->AddObserver(</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                        </span>vtkCommand::WindowLevelEvent, cbk );</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->AddObserver(vtkResliceImageViewer::SliceChangedEvent,cbk);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>// Make them all share the same color map.</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->SetLookupTable(riw[0]->GetLookupTable());</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->GetColorMap()->SetLookupTable(riw[0]->GetLookupTable());</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>planeWidget[i]->SetColorMap(riw[i]->GetResliceCursorWidget()->GetResliceCursorRepresentation()->GetColorMap());</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>//riw[0]->GetRenderWindow()->GetInteractor()->AddObserver(vtkCommand::KeyPressEvent,cbk);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>resliceMode(1);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->resliceModeCheckBox->setChecked(true);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view1->show();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view2->show();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view3->show();</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>// Set up action signals and slots</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->thickModeCheckBox->setEnabled(0);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->resliceModeCheckBox->setEnabled(0);</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->blendModeGroupBox->setEnabled(0);</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->resetButton->setEnabled(0);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->AddDistance1Button->setEnabled(0);</font></div><div><font face="arial, sans-serif">};</font></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif">void QtVTKRenderWindows::resliceMode(int mode)</font></div><div><font face="arial, sans-serif">{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>for (int i = 0; i < 3; i++)</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->SetResliceMode(mode ? 1 : 0);</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->GetRenderer()->ResetCamera();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->Render();</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif">}</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">void QtVTKRenderWindows::Render()</font></div>
<div><font face="arial, sans-serif">{</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>for (int i = 0; i < 3; i++)</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>{</font></div>
<div><font face="arial, sans-serif"><span class="" style="white-space:pre">                </span>riw[i]->Render();</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>}</font></div><div><font face="arial, sans-serif"><span class="" style="white-space:pre">        </span>this->ui->view3->GetRenderWindow()->Render();</font></div>
<div><font face="arial, sans-serif">}</font></div></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">=======================</font></div><div><font face="arial, sans-serif">QtVTKRenderWindowsApp.cxx<br>
</font></div><div><font face="arial, sans-serif">=======================</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><div>#include <QApplication></div><div>#include "QtVTKRenderWindows.h"</div>
<div> </div><div>int main( int argc, char** argv )</div><div>{</div><div> // QT Stuff</div><div> QApplication app( argc, argv );</div><div> </div><div> QtVTKRenderWindows myQtVTKRenderWindows(argc, argv);</div><div> myQtVTKRenderWindows.show();</div>
<div> </div><div> return app.exec();</div><div>}</div><div><br></div></font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 10, 2013 at 8:14 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>It might be time to attach compilable code.<span class="HOEnZb"><font color="#888888"><br><br></font></span></div>
<span class="HOEnZb"><font color="#888888">Alex<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 9, 2013 at 4:53 PM, Panayiotis Georgiou <span dir="ltr"><<a href="mailto:ps.georgiou@gmail.com" target="_blank">ps.georgiou@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">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 style="white-space:pre-wrap">        </span>vtkSmartPointer< vtkRenderer > ren =<span style="white-space:pre-wrap">        </span>vtkSmartPointer< vtkRenderer >::New();</div><div><br></div>
<div><span style="white-space:pre-wrap">        </span>this->ui->view4->GetRenderWindow()->AddRenderer(ren);</div><div><span style="white-space:pre-wrap">        </span>vtkRenderWindowInteractor *iren = this->ui->view4->GetInteractor();</div>
<div><span style="white-space:pre-wrap">        </span>iren->SetInteractorStyle(style);</div><div><span style="white-space:pre-wrap">        </span>style->SetCurrentRenderer(ren);</div></div><div><br></div><div>Any other suggestions?</div>
<div><br></div><div>Thanks.</div></div><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>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><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>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>