#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
+
//----------------------------------------------------------------------------
-SVTK_RendererHolder
-::SVTK_RendererHolder(QWidget* theParent,
- const char* theName):
- QMainWindow(theParent,theName,0),
- myRenderer(SVTK_Renderer::New())
+SVTK_MainWindow
+::SVTK_MainWindow(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr) :
+ QMainWindow(theParent,theName,0)
{
- myRenderer->Delete();
+ myToolBar = new QToolBar(this);
+ myToolBar->setCloseMode(QDockWindow::Undocked);
+ myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
+
+ createActions(theResourceMgr);
+ createToolBar();
}
-SVTK_RendererHolder
-::~SVTK_RendererHolder()
+//----------------------------------------------------------------------------
+SVTK_MainWindow
+::~SVTK_MainWindow()
{}
+
//----------------------------------------------------------------------------
-vtkRenderer*
-SVTK_RendererHolder
-::GetRenderer()
+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 myInteractor;
+}
+
+vtkRenderWindowInteractor*
+SVTK_MainWindow
+::getInteractor()
+{
+ return GetInteractor()->GetDevice();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::Repaint()
+{
+ Repaint( true );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::Repaint(bool theUpdateTrihedron)
+{
+ if(theUpdateTrihedron)
+ GetRenderer()->onAdjustTrihedron();
+
+ GetInteractor()->update();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::InvokeEvent(unsigned long theEvent, void* theCallData)
+{
+ myInteractor->InvokeEvent(theEvent,theCallData);
+}
+
+//----------------------------------------------------------------------------
+SVTK_InteractorStyle*
+SVTK_MainWindow
+::GetInteractorStyle()
+{
+ return myInteractor->GetInteractorStyle();
+}
+
+void
+SVTK_MainWindow
+::PushInteractorStyle(SVTK_InteractorStyle* theStyle)
+{
+ myInteractor->PushInteractorStyle(theStyle);
+}
+
+void
+SVTK_MainWindow
+::PopInteractorStyle()
+{
+ myInteractor->PopInteractorStyle();
+}
+
+//----------------------------------------------------------------------------
+SVTK_Selector*
+SVTK_MainWindow
+::GetSelector()
+{
+ return myInteractor->GetSelector();
+}
+
+void
+SVTK_MainWindow
+::SetSelector(SVTK_Selector* theSelector)
+{
+ myInteractor->SetSelector(theSelector);
+}
+
+Selection_Mode
+SVTK_MainWindow
+::SelectionMode()
+{
+ return GetSelector()->SelectionMode();
+}
+
+void
+SVTK_MainWindow
+::SetSelectionMode(Selection_Mode theMode)
{
- return myRenderer.GetPointer();
+ GetSelector()->SetSelectionMode(theMode);
}
+
//----------------------------------------------------------------------------
void
-SVTK_RendererHolder
-::setBackgroundColor(const QColor& theColor)
+SVTK_MainWindow
+::SetRenderWindow(SVTK_RenderWindow *theRenderWindow)
+{
+ myRenderWindow = theRenderWindow;
+}
+
+SVTK_RenderWindow*
+SVTK_MainWindow
+::GetRenderWindow()
+{
+ return myRenderWindow.GetPointer();
+}
+
+vtkRenderWindow*
+SVTK_MainWindow
+::getRenderWindow()
{
- myRenderer->SetBackground(theColor.red()/255.0,
- theColor.green()/255.0,
- theColor.blue()/255.0);
+ return myRenderWindow.GetPointer();
}
+
//----------------------------------------------------------------------------
+SVTK_Renderer*
+SVTK_MainWindow
+::GetRenderer()
+{
+ return GetRenderWindow()->GetRenderer();
+}
+
+vtkRenderer*
+SVTK_MainWindow
+::getRenderer()
+{
+ return GetRenderWindow()->GetRenderer();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::SetBackgroundColor(const QColor& theColor)
+{
+ GetRenderer()->SetBackground(theColor.red()/255.0,
+ theColor.green()/255.0,
+ theColor.blue()/255.0);
+}
+
QColor
-SVTK_RendererHolder
-::backgroundColor() const
+SVTK_MainWindow
+::BackgroundColor()
{
float aBackgroundColor[3];
- myRenderer->GetBackground(aBackgroundColor);
+ GetRenderer()->GetBackground(aBackgroundColor);
return QColor(int(aBackgroundColor[0]*255),
int(aBackgroundColor[1]*255),
int(aBackgroundColor[2]*255));
//----------------------------------------------------------------------------
void
-SVTK_RendererHolder
+SVTK_MainWindow
::GetScale( double theScale[3] )
{
- myRenderer->GetScale( theScale );
+ GetRenderer()->GetScale( theScale );
}
void
-SVTK_RendererHolder
+SVTK_MainWindow
::SetScale( double theScale[3] )
{
- myRenderer->SetScale( theScale );
+ GetRenderer()->SetScale( theScale );
Repaint();
}
//----------------------------------------------------------------------------
void
-SVTK_RendererHolder
-::AddActor(VTKViewer_Actor* theActor, bool theIsUpdate)
+SVTK_MainWindow
+::AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
{
- myRenderer->AddActor(theActor);
+ GetRenderer()->AddActor(theActor);
if(theIsUpdate)
Repaint();
}
//----------------------------------------------------------------------------
void
-SVTK_RendererHolder
-::RemoveActor(VTKViewer_Actor* theActor, bool theIsUpdate)
+SVTK_MainWindow
+::RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
{
- myRenderer->RemoveActor(theActor);
+ GetRenderer()->RemoveActor(theActor);
if(theIsUpdate)
Repaint();
}
//----------------------------------------------------------------------------
int
-SVTK_RendererHolder
-::GetTrihedronSize() const
+SVTK_MainWindow
+::GetTrihedronSize()
{
- return myRenderer->GetTrihedronSize();
+ return GetRenderer()->GetTrihedronSize();
}
//----------------------------------------------------------------------------
void
-SVTK_RendererHolder
+SVTK_MainWindow
::SetTrihedronSize( const int theSize )
{
- myRenderer->SetTrihedronSize(theSize);
+ GetRenderer()->SetTrihedronSize(theSize);
Repaint();
}
* trihedron and cube axes, even if trihedron and cube axes is invisible.
*/
void
-SVTK_RendererHolder
+SVTK_MainWindow
::AdjustTrihedrons(const bool theIsForced)
{
- myRenderer->AdjustTrihedrons(theIsForced);
+ GetRenderer()->AdjustTrihedrons(theIsForced);
Repaint();
}
//----------------------------------------------------------------------------
bool
-SVTK_RendererHolder
-::isTrihedronDisplayed()
+SVTK_MainWindow
+::IsTrihedronDisplayed()
{
- return myRenderer->isTrihedronDisplayed();
+ return GetRenderer()->isTrihedronDisplayed();
}
//----------------------------------------------------------------------------
bool
-SVTK_RendererHolder
-::isCubeAxesDisplayed()
+SVTK_MainWindow
+::IsCubeAxesDisplayed()
{
- return myRenderer->isCubeAxesDisplayed();
+ return GetRenderer()->isCubeAxesDisplayed();
}
//----------------------------------------------------------------------------
VTKViewer_Trihedron*
-SVTK_RendererHolder
+SVTK_MainWindow
::GetTrihedron()
{
- return myRenderer->GetTrihedron();
+ return GetRenderer()->GetTrihedron();
}
//----------------------------------------------------------------------------
SVTK_CubeAxesActor2D*
-SVTK_RendererHolder
+SVTK_MainWindow
::GetCubeAxes()
{
- return myRenderer->GetCubeAxes();
+ return GetRenderer()->GetCubeAxes();
}
//----------------------------------------------------------------------------
-SVTK_ActionHolder
-::SVTK_ActionHolder(QWidget* theParent,
- const char* theName,
- SUIT_ResourceMgr* theResourceMgr) :
- SVTK_RendererHolder(theParent,theName)
+QToolBar*
+SVTK_MainWindow
+::getToolBar()
{
- myToolBar = new QToolBar(this);
- myToolBar->setCloseMode(QDockWindow::Undocked);
- myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
-
- createActions(theResourceMgr);
- createToolBar();
+ return myToolBar;
}
-//----------------------------------------------------------------------------
-SVTK_ActionHolder
-::~SVTK_ActionHolder()
-{}
-
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::SetEventDispatcher(vtkObject* theDispatcher)
{
myEventDispatcher = theDispatcher;
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::createActions(SUIT_ResourceMgr* theResourceMgr)
{
if(!myActionsMap.isEmpty())
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::createToolBar()
{
myActionsMap[DumpId]->addTo(myToolBar);
myActionsMap[ResetId]->addTo(myToolBar);
}
-//----------------------------------------------------------------------------
-QToolBar*
-SVTK_ActionHolder
-::getToolBar()
-{
- return myToolBar;
-}
-
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::activateZoom()
{
myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::activatePanning()
{
myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::activateRotation()
{
myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::activateGlobalPanning()
{
myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::activateWindowFit()
{
myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onFrontView()
{
- myRenderer->onFrontView();
+ GetRenderer()->onFrontView();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onBackView()
{
- myRenderer->onBackView();
+ GetRenderer()->onBackView();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onTopView()
{
- myRenderer->onTopView();
+ GetRenderer()->onTopView();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onBottomView()
{
- myRenderer->onBottomView();
+ GetRenderer()->onBottomView();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onLeftView()
{
- myRenderer->onLeftView();
+ GetRenderer()->onLeftView();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onRightView()
{
- myRenderer->onRightView();
+ GetRenderer()->onRightView();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onResetView()
{
- myRenderer->onResetView();
+ GetRenderer()->onResetView();
Repaint();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onFitAll()
{
- myRenderer->onFitAll();
+ GetRenderer()->onFitAll();
Repaint();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onViewTrihedron()
{
- myRenderer->onViewTrihedron();
+ GetRenderer()->onViewTrihedron();
Repaint();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onViewCubeAxes()
{
- myRenderer->onViewCubeAxes();
+ GetRenderer()->onViewCubeAxes();
Repaint();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onAdjustTrihedron()
{
- myRenderer->onAdjustTrihedron();
+ GetRenderer()->onAdjustTrihedron();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onAdjustCubeAxes()
{
- myRenderer->onAdjustCubeAxes();
+ GetRenderer()->onAdjustCubeAxes();
}
//----------------------------------------------------------------------------
void
-SVTK_ActionHolder
+SVTK_MainWindow
::onDumpView()
{}
//----------------------------------------------------------------------------
QImage
-SVTK_ActionHolder
+SVTK_MainWindow
::dumpView()
{
QPixmap px = QPixmap::grabWindow( winId() );
//----------------------------------------------------------------------------
-SVTK_InteractorHolder
-::SVTK_InteractorHolder(QWidget* theParent,
- const char* theName,
- SUIT_ResourceMgr* theResourceMgr) :
- SVTK_ActionHolder(theParent,theName,theResourceMgr),
- myRenderWindow(SVTK_RenderWindow::New())
-{
- myRenderWindow->Delete();
-
- myRenderWindow->AddRenderer(GetRenderer());
-
- myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
-
- SetInteractor(myInteractor);
-
- myInteractor->PushInteractorStyle(SVTK_InteractorStyle::New());
-}
-
-//----------------------------------------------------------------------------
-SVTK_InteractorHolder
-::~SVTK_InteractorHolder()
-{}
-
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorHolder
-::SetInteractor(SVTK_RenderWindowInteractor* theInteractor)
+SVTK_SignalHandler
+::SVTK_SignalHandler(SVTK_MainWindow* theMainWindow):
+ QObject(theMainWindow),
+ myMainWindow(theMainWindow)
{
- myInteractor = theInteractor;
+ SVTK_RenderWindow* aRenderWindow = SVTK_RenderWindow::New();
+ theMainWindow->SetRenderWindow(aRenderWindow);
+ aRenderWindow->Delete();
- if(myInteractor){
- connect(myInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
- this,SIGNAL(KeyPressed(QKeyEvent*)) );
- connect(myInteractor,SIGNAL(KeyReleased(QKeyEvent*)),
- this,SIGNAL(KeyReleased(QKeyEvent*)));
- connect(myInteractor,SIGNAL(MouseButtonPressed(QMouseEvent*)),
- this,SIGNAL(MouseButtonPressed(QMouseEvent*)));
- connect(myInteractor,SIGNAL(MouseButtonReleased(QMouseEvent*)),
- this,SIGNAL(MouseButtonReleased(QMouseEvent*)));
- connect(myInteractor,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
- this,SIGNAL(MouseDoubleClicked(QMouseEvent*)));
- connect(myInteractor,SIGNAL(MouseMove(QMouseEvent*)),
- this,SIGNAL(MouseMove(QMouseEvent*)));
- connect(myInteractor,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
- this,SIGNAL(contextMenuRequested(QContextMenuEvent*)));
- connect(myInteractor,SIGNAL(selectionChanged()),
- this,SIGNAL(selectionChanged()));
-
- SetEventDispatcher(myInteractor->GetDevice());
-
- setCentralWidget(myInteractor);
-
- myInteractor->setFocusPolicy(StrongFocus);
- myInteractor->setFocus();
- setFocusProxy(myInteractor);
-
- myInteractor->SetRenderWindow(myRenderWindow.GetPointer());
- }
-}
+ aRenderWindow->SetRenderer(SVTK_Renderer::New());
-//----------------------------------------------------------------------------
-SVTK_RenderWindowInteractor*
-SVTK_InteractorHolder
-::GetInteractor()
-{
- return myInteractor;
-}
+ SVTK_RenderWindowInteractor* anInteractor =
+ new SVTK_RenderWindowInteractor(theMainWindow,"SVTK_RenderWindowInteractor");
+ anInteractor->SetRenderWindow(aRenderWindow);
-//----------------------------------------------------------------------------
-vtkRenderWindowInteractor*
-SVTK_InteractorHolder
-::GetRenderWindowInteractor()
-{
- return myInteractor->GetDevice();
-}
+ theMainWindow->SetInteractor(anInteractor);
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorHolder
-::Repaint( bool theUpdateTrihedron )
-{
- if(theUpdateTrihedron)
- myRenderer->onAdjustTrihedron();
-
- myInteractor->update();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorHolder
-::Repaint()
-{
- Repaint( true );
-}
+ anInteractor->PushInteractorStyle(SVTK_InteractorStyle::New());
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorHolder
-::InvokeEvent(unsigned long theEvent, void* theCallData)
-{
- myInteractor->InvokeEvent(theEvent,theCallData);
+ connect(anInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
+ this,SIGNAL(KeyPressed(QKeyEvent*)) );
+ connect(anInteractor,SIGNAL(KeyReleased(QKeyEvent*)),
+ this,SIGNAL(KeyReleased(QKeyEvent*)));
+ connect(anInteractor,SIGNAL(MouseButtonPressed(QMouseEvent*)),
+ this,SIGNAL(MouseButtonPressed(QMouseEvent*)));
+ connect(anInteractor,SIGNAL(MouseButtonReleased(QMouseEvent*)),
+ this,SIGNAL(MouseButtonReleased(QMouseEvent*)));
+ connect(anInteractor,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
+ this,SIGNAL(MouseDoubleClicked(QMouseEvent*)));
+ connect(anInteractor,SIGNAL(MouseMove(QMouseEvent*)),
+ this,SIGNAL(MouseMove(QMouseEvent*)));
+ connect(anInteractor,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
+ this,SIGNAL(contextMenuRequested(QContextMenuEvent*)));
+ connect(anInteractor,SIGNAL(selectionChanged()),
+ this,SIGNAL(selectionChanged()));
}
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorHolder
-::SetRenderWindow(vtkRenderWindow *theRenderWindow)
-{
- myRenderWindow = theRenderWindow;
-
- if(myInteractor)
- myInteractor->SetRenderWindow(myRenderWindow.GetPointer());
-}
+SVTK_SignalHandler
+::~SVTK_SignalHandler()
+{}
-//----------------------------------------------------------------------------
-vtkRenderWindow*
-SVTK_InteractorHolder
-::GetRenderWindow()
+SVTK_MainWindow*
+SVTK_SignalHandler
+::GetMainWindow()
{
- return myRenderWindow.GetPointer();
+ return myMainWindow;
}
-//----------------------------------------------------------------------------
-SVTK_Selector*
-SVTK_InteractorHolder
-::GetSelector()
-{
- return myInteractor->GetSelector();
-}
-
-void
-SVTK_InteractorHolder
-::SetSelector(SVTK_Selector* theSelector)
-{
- myInteractor->SetSelector(theSelector);
-}
-//----------------------------------------------------------------------------
+//----------------------------------------------------------------
void
-SVTK_InteractorHolder
-::PushInteractorStyle(SVTK_InteractorStyle* theStyle)
+SVTK_SignalHandler
+::Repaint()
{
- myInteractor->PushInteractorStyle(theStyle);
+ myMainWindow->Repaint();
}
-//----------------------------------------------------------------------------
void
-SVTK_InteractorHolder
-::PopInteractorStyle()
+SVTK_SignalHandler
+::Repaint(bool theUpdateTrihedron)
{
- myInteractor->PopInteractorStyle();
+ myMainWindow->Repaint(theUpdateTrihedron);
}
-
//----------------------------------------------------------------------------
-SVTK_InteractorStyle*
-SVTK_InteractorHolder
-::GetInteractorStyle()
-{
- return myInteractor->GetInteractorStyle();
-}
-
-
-//----------------------------------------------------------------
-void
-SVTK_InteractorHolder
-::SetSelectionMode(int theMode)
+SVTK_Renderer*
+SVTK_SignalHandler
+::GetRenderer()
{
- myInteractor->SetSelectionMode(theMode);
+ return myMainWindow->GetRenderer();
}
-
-//----------------------------------------------------------------
-int
-SVTK_InteractorHolder
-::SelectionMode() const
+vtkRenderer*
+SVTK_SignalHandler
+::getRenderer()
{
- return myInteractor->SelectionMode();
+ return myMainWindow->GetRenderer();
}
-
//----------------------------------------------------------------
struct THighlightAction
{
bool myIsHighlight;
- int mySelectionMode;
- THighlightAction( bool theIsHighlight, int theSelectionMode = ActorSelection ):
+ Selection_Mode mySelectionMode;
+ THighlightAction( bool theIsHighlight,
+ Selection_Mode theSelectionMode = ActorSelection ):
myIsHighlight( theIsHighlight ),
mySelectionMode( theSelectionMode )
{}
}
};
-//----------------------------------------------------------------
void
-SVTK_InteractorHolder
+SVTK_SignalHandler
::onSelectionChanged()
{
- vtkActorCollection* anActors = GetRenderer()->GetActors();
+ vtkActorCollection* anActors = myMainWindow->GetRenderer()->GetActors();
using namespace VTK;
ForEach<SALOME_Actor>(anActors,
THighlightAction( false ));
-
- const SALOME_ListIO& aListIO = GetSelector()->StoredIObjects();
+ SVTK_Selector* aSelector = myMainWindow->GetSelector();
+ const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
SALOME_ListIteratorOfListIO anIter(aListIO);
- int aSelectionMode = SelectionMode();
+ Selection_Mode aSelectionMode = aSelector->SelectionMode();
for(; anIter.More(); anIter.Next()){
ForEachIf<SALOME_Actor>(anActors,
TIsSameIObject<SALOME_Actor>(anIter.Value()),
THighlightAction(true,aSelectionMode));
}
- Repaint();
+ myMainWindow->Repaint();
}
//----------------------------------------------------------------------------
SVTK_View
-::SVTK_View(QWidget* theParent,
- const char* theName,
- SUIT_ResourceMgr* theResourceMgr) :
- SVTK_InteractorHolder(theParent,theName,theResourceMgr)
+::SVTK_View(SVTK_MainWindow* theMainWindow) :
+ SVTK_SignalHandler(theMainWindow)
{}
//----------------------------------------------------------------------------
bool theIsUpdate )
{
using namespace VTK;
+ SVTK_Selector* aSelector = myMainWindow->GetSelector();
ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>( theIO ),
- THighlightAction( theIsHighlight, GetSelector()->SelectionMode() ));
+ THighlightAction( theIsHighlight, aSelector->SelectionMode() ));
Repaint();
}
#endif
#include "SVTK.h"
-
+#include "SVTK_Selection.h"
#include "SALOME_InteractiveObject.hxx"
#include <vtkSmartPointer.h>
class SALOME_Actor;
//----------------------------------------------------------------------------
-class SVTK_EXPORT SVTK_RendererHolder: public QMainWindow
+class SVTK_EXPORT SVTK_MainWindow: public QMainWindow
{
Q_OBJECT;
public:
- SVTK_RendererHolder(QWidget* theParent,
- const char* theName);
+ SVTK_MainWindow(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr);
virtual
- ~SVTK_RendererHolder();
+ ~SVTK_MainWindow();
- vtkRenderer* GetRenderer();
+ //----------------------------------------------------------------------------
+ void
+ SetInteractor(SVTK_RenderWindowInteractor* theInteractor);
- virtual void Repaint() = 0;
+ SVTK_RenderWindowInteractor*
+ GetInteractor();
- void setBackgroundColor( const QColor& );
- QColor backgroundColor() const;
+ vtkRenderWindowInteractor*
+ getInteractor();
- //apply existing transformation on adding SALOME_Actor
- void SetScale( double theScale[3] );
- void GetScale( double theScale[3] );
+ void
+ Repaint();
- void AddActor(VTKViewer_Actor* theActor, bool theIsUpdate = false);
- void RemoveActor(VTKViewer_Actor* theActor, bool theIsUpdate = false);
+ void
+ Repaint(bool theUpdateTrihedron);
- int GetTrihedronSize() const;
- void SetTrihedronSize( const int );
- void AdjustTrihedrons( const bool forced );
+ void
+ InvokeEvent(unsigned long theEvent, void* theCallData);
- bool isTrihedronDisplayed();
- bool isCubeAxesDisplayed();
+ //----------------------------------------------------------------------------
+ SVTK_InteractorStyle*
+ GetInteractorStyle();
- VTKViewer_Trihedron* GetTrihedron();
- SVTK_CubeAxesActor2D* GetCubeAxes();
+ void
+ PushInteractorStyle(SVTK_InteractorStyle* theStyle);
- protected:
- vtkSmartPointer<SVTK_Renderer> myRenderer;
-};
+ void
+ PopInteractorStyle();
+ //----------------------------------------------------------------------------
+ SVTK_Selector*
+ GetSelector();
-//----------------------------------------------------------------------------
-class SVTK_EXPORT SVTK_ActionHolder: public SVTK_RendererHolder
-{
- Q_OBJECT;
+ void
+ SetSelector(SVTK_Selector* theSelector);
-public:
- SVTK_ActionHolder(QWidget* theParent,
- const char* theName,
- SUIT_ResourceMgr* theResourceMgr);
+ Selection_Mode
+ SelectionMode();
- virtual
- ~SVTK_ActionHolder();
+ void
+ SetSelectionMode(Selection_Mode theMode);
+ //----------------------------------------------------------------------------
void
- SetEventDispatcher(vtkObject* theDispatcher);
+ SetRenderWindow(SVTK_RenderWindow *theRenderWindow);
+
+ SVTK_RenderWindow*
+ GetRenderWindow();
+
+ vtkRenderWindow*
+ getRenderWindow();
+
+ //----------------------------------------------------------------------------
+ SVTK_Renderer*
+ GetRenderer();
+
+ vtkRenderer*
+ getRenderer();
+ void
+ SetBackgroundColor(const QColor& theColor);
+
+ QColor
+ BackgroundColor();
+
+ void
+ SetScale(double theScale[3]);
+
+ void
+ GetScale(double theScale[3]);
+
+ void
+ AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+ void
+ RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ int
+ GetTrihedronSize();
+
+ void
+ SetTrihedronSize(const int theSize);
+
+ void
+ AdjustTrihedrons(const bool theIsForced);
+
+ bool
+ IsTrihedronDisplayed();
+
+ bool
+ IsCubeAxesDisplayed();
+
+ VTKViewer_Trihedron*
+ GetTrihedron();
+
+ SVTK_CubeAxesActor2D*
+ GetCubeAxes();
+
+ //----------------------------------------------------------------------------
QToolBar* getToolBar();
public slots:
- virtual void activateZoom();
- virtual void activateWindowFit();
- virtual void activateRotation();
- virtual void activatePanning();
- virtual void activateGlobalPanning();
+ void activateZoom();
+ void activateWindowFit();
+ void activateRotation();
+ void activatePanning();
+ void activateGlobalPanning();
void onFrontView();
void onBackView();
void
createToolBar();
+ void
+ SetEventDispatcher(vtkObject* theDispatcher);
+
enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId };
typedef QMap<int, QtxAction*> TActionsMap;
vtkSmartPointer<vtkObject> myEventDispatcher;
TActionsMap myActionsMap;
QToolBar* myToolBar;
+
+ SVTK_RenderWindowInteractor* myInteractor;
+ vtkSmartPointer<SVTK_RenderWindow> myRenderWindow;
};
//----------------------------------------------------------------------------
-class SVTK_EXPORT SVTK_InteractorHolder : public SVTK_ActionHolder
+class SVTK_EXPORT SVTK_SignalHandler : public QObject
{
Q_OBJECT;
public:
- SVTK_InteractorHolder(QWidget* theParent,
- const char* theName,
- SUIT_ResourceMgr* theResourceMgr);
+ SVTK_SignalHandler(SVTK_MainWindow* theMainWindow);
virtual
- ~SVTK_InteractorHolder();
-
- void
- SetInteractor(SVTK_RenderWindowInteractor* theInteractor);
+ ~SVTK_SignalHandler();
- SVTK_RenderWindowInteractor*
- GetInteractor();
-
- vtkRenderWindowInteractor*
- GetRenderWindowInteractor();
-
- virtual void Repaint();
- void Repaint( bool theUpdateTrihedron );
+ SVTK_MainWindow*
+ GetMainWindow();
+ //----------------------------------------------------------------------------
void
- InvokeEvent(unsigned long theEvent, void* theCallData);
+ Repaint();
void
- SetRenderWindow(vtkRenderWindow *theRenderWindow);
-
- vtkRenderWindow*
- GetRenderWindow();
-
- vtkRenderWindow*
- getRenderWindow()
- {
- return GetRenderWindow();
- }
-
- SVTK_Selector* GetSelector();
- void SetSelector(SVTK_Selector* theSelector);
+ Repaint(bool theUpdateTrihedron);
- SVTK_InteractorStyle* GetInteractorStyle();
- void PushInteractorStyle(SVTK_InteractorStyle* theStyle);
- void PopInteractorStyle();
+ //----------------------------------------------------------------------------
+ SVTK_Renderer*
+ GetRenderer();
- int SelectionMode() const;
- void SetSelectionMode(int theMode);
+ vtkRenderer*
+ getRenderer();
+ //----------------------------------------------------------------------------
public slots:
void onSelectionChanged();
void KeyPressed( QKeyEvent* );
void KeyReleased( QKeyEvent* );
void contextMenuRequested( QContextMenuEvent *e );
-
void selectionChanged();
- protected:
- SVTK_RenderWindowInteractor* myInteractor;
- vtkSmartPointer<SVTK_RenderWindow> myRenderWindow;
+ protected:
+ SVTK_MainWindow* myMainWindow;
};
//----------------------------------------------------------------------------
-class SVTK_EXPORT SVTK_View : public SVTK_InteractorHolder
+class SVTK_EXPORT SVTK_View : public SVTK_SignalHandler
{
Q_OBJECT;
public:
- SVTK_View(QWidget* theParent,
- const char* theName,
- SUIT_ResourceMgr* theResourceMgr);
+ SVTK_View(SVTK_MainWindow* theMainWindow);
virtual
~SVTK_View();
#include "SVTK_Event.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModelBase.h"
-#include "SVTK_RenderWindowInteractor.h"
-#include "SVTK_InteractorStyle.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SVTK_Selector.h"
+#include "SVTK_View.h"
#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
::Initialize(SVTK_ViewModelBase* theModel)
{
if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
- myView = new SVTK_View(this,"SVTK_View",aResourceMgr);
- setCentralWidget(myView);
+ myMainWindow = new SVTK_MainWindow(this,"SVTK_MainWindow",aResourceMgr);
+ setCentralWidget(myMainWindow);
+ myView = new SVTK_View(myMainWindow);
Initialize(myView,theModel);
}
}
::Initialize(SVTK_View* theView,
SVTK_ViewModelBase* theModel)
{
- onResetView();
-
connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
this,SLOT(onKeyPressed(QKeyEvent*)) );
connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+SVTK_View*
+SVTK_ViewWindow
+::getView()
+{
+ return myView;
+}
+
+SVTK_MainWindow*
+SVTK_ViewWindow
+::getMainWindow()
+{
+ return myMainWindow;
+}
+
+vtkRenderWindow*
+SVTK_ViewWindow
+::getRenderWindow()
+{
+ return getMainWindow()->getRenderWindow();
+}
+
+vtkRenderWindowInteractor*
+SVTK_ViewWindow
+::getInteractor()
+{
+ return getMainWindow()->getInteractor();
+}
+
vtkRenderer*
SVTK_ViewWindow
::getRenderer()
{
- return myView->GetRenderer();
+ return myMainWindow->getRenderer();
}
-//----------------------------------------------------------------------------
SVTK_Selector*
SVTK_ViewWindow
::GetSelector()
{
- return myView->GetSelector();
+ return myMainWindow->GetSelector();
}
-//----------------------------------------------------------------------------
-SVTK_View*
-SVTK_ViewWindow
-::getView() {
- return myView;
-}
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
::onFrontView()
{
- myView->onFrontView();
+ myMainWindow->onFrontView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onBackView()
{
- myView->onBackView();
+ myMainWindow->onBackView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onTopView()
{
- myView->onTopView();
+ myMainWindow->onTopView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onBottomView()
{
- myView->onBottomView();
+ myMainWindow->onBottomView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onLeftView()
{
- myView->onLeftView();
+ myMainWindow->onLeftView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onRightView()
{
- myView->onRightView();
+ myMainWindow->onRightView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onResetView()
{
- myView->onResetView();
+ myMainWindow->onResetView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onFitAll()
{
- myView->onFitAll();
+ myMainWindow->onFitAll();
}
//----------------------------------------------------------------
SVTK_ViewWindow
::SetSelectionMode(Selection_Mode theMode)
{
- myView->SetSelectionMode( theMode );
+ myMainWindow->SetSelectionMode( theMode );
}
//----------------------------------------------------------------
SVTK_ViewWindow
::SelectionMode() const
{
- return Selection_Mode(myView->SelectionMode());
+ return myMainWindow->SelectionMode();
}
//----------------------------------------------------------------
SVTK_ViewWindow
::setBackgroundColor( const QColor& color )
{
- myView->setBackgroundColor( color );
+ myMainWindow->SetBackgroundColor( color );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::backgroundColor() const
{
- return myView->backgroundColor();
+ return myMainWindow->BackgroundColor();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::Repaint(bool theUpdateTrihedron)
{
- myView->Repaint( theUpdateTrihedron );
+ myMainWindow->Repaint( theUpdateTrihedron );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::GetScale( double theScale[3] )
{
- myView->GetScale( theScale );
+ myMainWindow->GetScale( theScale );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::SetScale( double theScale[3] )
{
- myView->SetScale( theScale );
+ myMainWindow->SetScale( theScale );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::isTrihedronDisplayed()
{
- return myView->isTrihedronDisplayed();
+ return myMainWindow->IsTrihedronDisplayed();
}
bool
SVTK_ViewWindow
::isCubeAxesDisplayed()
{
- return myView->isCubeAxesDisplayed();
+ return myMainWindow->IsCubeAxesDisplayed();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onViewTrihedron()
{
- myView->onViewTrihedron();
+ myMainWindow->onViewTrihedron();
}
void
SVTK_ViewWindow
::onViewCubeAxes()
{
- myView->onViewCubeAxes();
+ myMainWindow->onViewCubeAxes();
}
//----------------------------------------------------------------------------
-VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
+VTKViewer_Trihedron*
+SVTK_ViewWindow::
+GetTrihedron()
{
- return myView->GetTrihedron();
+ return myMainWindow->GetTrihedron();
}
-SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
+SVTK_CubeAxesActor2D*
+SVTK_ViewWindow
+::GetCubeAxes()
{
- return myView->GetCubeAxes();
+ return myMainWindow->GetCubeAxes();
}
-int SVTK_ViewWindow::GetTrihedronSize() const
+int
+SVTK_ViewWindow
+::GetTrihedronSize() const
{
- return myView->GetTrihedronSize();
+ return myMainWindow->GetTrihedronSize();
}
-void SVTK_ViewWindow::SetTrihedronSize( const int sz )
+void
+SVTK_ViewWindow
+::SetTrihedronSize(const int theSize)
{
- myView->SetTrihedronSize( sz );
+ myMainWindow->SetTrihedronSize(theSize);
}
/*! If parameter theIsForcedUpdate is true, recalculate parameters for
SVTK_ViewWindow
::AdjustTrihedrons(const bool theIsForcedUpdate)
{
- myView->AdjustTrihedrons( theIsForcedUpdate );
+ myMainWindow->AdjustTrihedrons( theIsForcedUpdate );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onAdjustTrihedron()
{
- myView->onAdjustTrihedron();
+ myMainWindow->onAdjustTrihedron();
}
void
SVTK_ViewWindow
::onAdjustCubeAxes()
{
- myView->onAdjustCubeAxes();
+ myMainWindow->onAdjustCubeAxes();
}
//=======================================================================
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::AddActor( VTKViewer_Actor* theActor, bool theUpdate )
+::AddActor( VTKViewer_Actor* theActor,
+ bool theUpdate )
{
- myView->AddActor( theActor, theUpdate );
+ myMainWindow->AddActor( theActor, theUpdate );
}
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate )
+::RemoveActor( VTKViewer_Actor* theActor,
+ bool theUpdate )
{
- myView->RemoveActor( theActor, theUpdate );
+ myMainWindow->RemoveActor( theActor, theUpdate );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::dumpView()
{
- return myView->dumpView();
+ return myMainWindow->dumpView();
}
//----------------------------------------------------------------------------
if ( accelAction == SUIT_Accel::ZoomFit )
onFitAll();
else {
- int svtkEvent = convertAction( accelAction );
- myView->InvokeEvent( svtkEvent, 0 );
+ int anEvent = convertAction( accelAction );
+ myMainWindow->InvokeEvent( anEvent, 0 );
}
}