QVTK_RenderWindowInteractor
::QVTK_RenderWindowInteractor(QWidget* theParent,
const char* theName):
- QWidget(theParent,theName)
+ QWidget(theParent,theName),
+ myRenderWindow(vtkRenderWindow::New())
{
if(MYDEBUG) INFOS("QVTK_RenderWindowInteractor() - "<<this);
setMouseTracking(true);
+
+ myRenderWindow->Delete();
+ myRenderWindow->DoubleBufferOn();
}
+void
+QVTK_RenderWindowInteractor
+::Initialize(vtkGenericRenderWindowInteractor* theDevice)
+{
+ if(GetDevice())
+ myDevice->SetRenderWindow(NULL);
+
+ myDevice = theDevice;
+
+ if(theDevice)
+ theDevice->SetRenderWindow(getRenderWindow());
+}
+
+//----------------------------------------------------------------------------
QVTK_RenderWindowInteractor
::~QVTK_RenderWindowInteractor()
{
aSpaceMouse->close(x11Display());
}
+
//----------------------------------------------------------------------------
vtkGenericRenderWindowInteractor*
QVTK_RenderWindowInteractor
return myDevice.GetPointer();
}
-void
-QVTK_RenderWindowInteractor
-::SetDevice(vtkGenericRenderWindowInteractor* theDevice)
-{
- myDevice = theDevice;
-}
-
//----------------------------------------------------------------------------
-void
-QVTK_RenderWindowInteractor
-::SetRenderWindow(vtkRenderWindow *theRenderWindow)
-{
- GetDevice()->SetRenderWindow(theRenderWindow);
- theRenderWindow->DoubleBufferOn();
-}
-
vtkRenderWindow*
QVTK_RenderWindowInteractor
-::GetRenderWindow()
+::getRenderWindow()
{
- return GetDevice()->GetRenderWindow();
+ return myRenderWindow.GetPointer();
}
//----------------------------------------------------------------------------
// Final initialization just before the widget is displayed
GetDevice()->SetSize(width(),height());
#ifndef WNT
- GetRenderWindow()->SetDisplayId((void*)x11Display());
+ getRenderWindow()->SetDisplayId((void*)x11Display());
#endif
- GetRenderWindow()->SetWindowId((void*)winId());
+ getRenderWindow()->SetWindowId((void*)winId());
GetDevice()->Enable();
}
QVTK_RenderWindowInteractor
::resizeEvent( QResizeEvent* theEvent )
{
- int* aSize = GetRenderWindow()->GetSize();
+ int* aSize = getRenderWindow()->GetSize();
int aWidth = aSize[0];
int aHeight = aSize[1];
if(isVisible() && aWidth && aHeight){
if( aWidth != width() || aHeight != height() ) {
- vtkRendererCollection * aRenderers = GetRenderWindow()->GetRenderers();
+ vtkRendererCollection * aRenderers = getRenderWindow()->GetRenderers();
aRenderers->InitTraversal();
double aCoeff = 1.0;
if(vtkRenderer *aRenderer = aRenderers->GetNextItem()) {
::SVTK_RenderWindowInteractor(QWidget* theParent,
const char* theName):
QVTK_RenderWindowInteractor(theParent,theName),
- myEventCallbackCommand(vtkCallbackCommand::New()),
- myRenderWindow(vtkRenderWindow::New())
+ myEventCallbackCommand(vtkCallbackCommand::New())
{
if(MYDEBUG) INFOS("SVTK_RenderWindowInteractor() - "<<this);
myPriority = 0.0;
myEventCallbackCommand->SetCallback(SVTK_RenderWindowInteractor::ProcessEvents);
+}
- SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
- SetDevice(aDevice);
- aDevice->Delete();
-
- aDevice->SetRenderWidget(this);
-
- SetSelector(SVTK_Selector::New());
- mySelector->Delete();
-
- aDevice->SetSelector(GetSelector());
-
- GetDevice()->SetRenderWindow(getRenderWindow());
- myRenderWindow->Delete();
+void
+SVTK_RenderWindowInteractor
+::Initialize(vtkGenericRenderWindowInteractor* theDevice,
+ SVTK_Renderer* theRenderer,
+ SVTK_Selector* theSelector)
+{
+ QVTK_RenderWindowInteractor::Initialize(theDevice);
+ SetRenderer(theRenderer);
+ SetSelector(theSelector);
}
+//----------------------------------------------------------------------------
SVTK_RenderWindowInteractor
::~SVTK_RenderWindowInteractor()
{
GetDevice()->SetRenderWindow(NULL);
}
-vtkRenderWindow*
-SVTK_RenderWindowInteractor
-::getRenderWindow()
-{
- return myRenderWindow.GetPointer();
-}
-
-
//----------------------------------------------------------------------------
SVTK_Renderer*
SVTK_RenderWindowInteractor
~QVTK_RenderWindowInteractor();
- vtkGenericRenderWindowInteractor*
- GetDevice();
-
+ virtual
void
- SetDevice(vtkGenericRenderWindowInteractor* theDevice);
+ Initialize(vtkGenericRenderWindowInteractor* theDevice);
- void
- SetRenderWindow(vtkRenderWindow *theRenderWindow);
+ vtkGenericRenderWindowInteractor*
+ GetDevice();
vtkRenderWindow*
- GetRenderWindow();
+ getRenderWindow();
virtual
void
virtual bool x11Event( XEvent *e );
+ vtkSmartPointer<vtkRenderWindow> myRenderWindow;
vtkSmartPointer<vtkGenericRenderWindowInteractor> myDevice;
};
~SVTK_RenderWindowInteractor();
- vtkRenderWindow*
- getRenderWindow();
-
- //----------------------------------------------------------------------------
+ virtual
void
- SetRenderer(SVTK_Renderer *theRenderer);
+ Initialize(vtkGenericRenderWindowInteractor* theDevice,
+ SVTK_Renderer* theRenderer,
+ SVTK_Selector* theSelector);
+ //----------------------------------------------------------------------------
SVTK_Renderer*
GetRenderer();
SVTK_Selector*
GetSelector();
- void
- SetSelector(SVTK_Selector* theSelector);
-
Selection_Mode
SelectionMode() const;
virtual void keyReleaseEvent( QKeyEvent* );
virtual void contextMenuEvent( QContextMenuEvent * e );
+ void
+ SetRenderer(SVTK_Renderer *theRenderer);
+
+ void
+ SetSelector(SVTK_Selector* theSelector);
+
void
InitInteractorStyle(vtkInteractorStyle* theStyle);
vtkSmartPointer<SVTK_Selector> mySelector;
vtkSmartPointer<SVTK_Renderer> myRenderer;
- vtkSmartPointer<vtkRenderWindow> myRenderWindow;
typedef vtkSmartPointer<vtkInteractorStyle> PInteractorStyle;
typedef std::stack<PInteractorStyle> TInteractorStyles;
void
SVTK_MainWindow
-::Initialize(SVTK_Renderer *theRenderer)
+::Initialize(SVTK_RenderWindowInteractor* theInteractor)
{
- SetInteractor(new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor"));
-
- SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
- GetInteractor()->PushInteractorStyle(aStyle);
- aStyle->Delete();
+ myInteractor = theInteractor;
+ SetEventDispatcher(myInteractor->GetDevice());
- GetInteractor()->SetRenderer(theRenderer);
-}
+ setCentralWidget(myInteractor);
-void
-SVTK_MainWindow
-::Initialize()
-{
- SVTK_Renderer* aRenderer = SVTK_Renderer::New();
- Initialize(aRenderer);
- aRenderer->Delete();
+ myInteractor->setFocusPolicy(StrongFocus);
+ myInteractor->setFocus();
+ setFocusProxy(myInteractor);
}
//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::SetInteractor(SVTK_RenderWindowInteractor* theInteractor)
-{
- myInteractor = theInteractor;
- SetEventDispatcher(myInteractor->GetDevice());
-
- setCentralWidget(myInteractor);
-
- myInteractor->setFocusPolicy(StrongFocus);
- myInteractor->setFocus();
- setFocusProxy(myInteractor);
-}
-
SVTK_RenderWindowInteractor*
SVTK_MainWindow
::GetInteractor()
return GetInteractor()->GetSelector();
}
-void
-SVTK_MainWindow
-::SetSelector(SVTK_Selector* theSelector)
-{
- GetInteractor()->SetSelector(theSelector);
-}
-
Selection_Mode
SVTK_MainWindow
::SelectionMode()
//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::SetRenderer(SVTK_Renderer* theRenderer)
-{
- GetInteractor()->SetRenderer(theRenderer);
-}
-
SVTK_Renderer*
SVTK_MainWindow
::GetRenderer()
virtual
void
- Initialize(SVTK_Renderer *theRenderer);
-
- virtual
- void
- Initialize();
+ Initialize(SVTK_RenderWindowInteractor* theInteractor);
virtual
~SVTK_MainWindow();
SVTK_Selector*
GetSelector();
- void
- SetSelector(SVTK_Selector* theSelector);
-
Selection_Mode
SelectionMode();
SetSelectionMode(Selection_Mode theMode);
//----------------------------------------------------------------------------
- void
- SetRenderer(SVTK_Renderer* theRenderer);
-
SVTK_Renderer*
GetRenderer();
#include "VTKViewer_CellRectPicker.h"
#include "SVTK_Event.h"
+#include "SVTK_Renderer.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModelBase.h"
+#include "SVTK_InteractorStyle.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
#include "SALOME_ListIteratorOfListIO.hxx"
{
if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
myMainWindow = new SVTK_MainWindow(this,"SVTK_MainWindow",aResourceMgr);
- myMainWindow->Initialize();
+
+ SVTK_RenderWindowInteractor* anIteractor =
+ new SVTK_RenderWindowInteractor(myMainWindow,"SVTK_RenderWindowInteractor");
+
+ SVTK_Renderer* aRenderer = SVTK_Renderer::New();
+
+ SVTK_Selector* aSelector = SVTK_Selector::New();
+
+ SVTK_GenericRenderWindowInteractor* aDevice =
+ SVTK_GenericRenderWindowInteractor::New();
+ aDevice->SetRenderWidget(anIteractor);
+ aDevice->SetSelector(aSelector);
+
+ anIteractor->Initialize(aDevice,aRenderer,aSelector);
+
+ aDevice->Delete();
+ aRenderer->Delete();
+ aSelector->Delete();
+
+ myMainWindow->Initialize(anIteractor);
+
+ SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
+ anIteractor->PushInteractorStyle(aStyle);
+ aStyle->Delete();
setCentralWidget(myMainWindow);