+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
#include <qpopupmenu.h>
#include <qcolordialog.h>
#include "SVTK_Selection.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
+#include "SVTK_View.h"
+#include "SVTK_MainWindow.h"
#include "SVTK_Prs.h"
-#include "SVTK_RenderWindowInteractor.h"
-#include "SVTK_RenderWindow.h"
+#include "VTKViewer_ViewModel.h"
-#include "ToolsGUI.h"
-
-#include "SALOME_Actor.h"
-#include "SALOME_InteractiveObject.hxx"
-
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
-#include "SALOME_ModuleCatalog_impl.hxx"
-#include "SALOME_NamingService.hxx"
-
-#include "SALOMEDSClient.hxx"
-#include "SALOMEDS_StudyManager.hxx"
+#include <SALOME_Actor.h>
+#include <SALOME_InteractiveObject.hxx>
// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from
// SALOMEDS::StudyManager - no linkage with SalomeApp.
-static _PTR(Study) getStudyDS()
-{
- SALOMEDSClient_Study* aStudy = NULL;
- _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
-
+// Temporarily commented to avoid awful dependecy on SALOMEDS
+// TODO: better mechanism of storing display/erse status in a study
+// should be provided...
+//static _PTR(Study) getStudyDS()
+//{
+// SALOMEDSClient_Study* aStudy = NULL;
+// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
// get id of SUIT_Study, if it's a SalomeApp_Study, it will return
// id of its underlying SALOMEDS::Study
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( !app ) return _PTR(Study)(aStudy);
- SUIT_Study* stud = app->activeStudy();
- if ( !stud ) return _PTR(Study)(aStudy);
- const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
+// SUIT_Application* app = SUIT_Session::session()->activeApplication();
+// if ( !app ) return _PTR(Study)(aStudy);
+// SUIT_Study* stud = app->activeStudy();
+// if ( !stud ) return _PTR(Study)(aStudy);
+// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
// get SALOMEDS_Study with this id from StudyMgr
- return aMgr->GetStudyByID( id );
-}
+// return aMgr->GetStudyByID( id );
+//}
//==========================================================
SVTK_Viewer::SVTK_Viewer()
{
- myTrihedronSize = 100;
+ myTrihedronSize = 105;
+ myTrihedronRelative = true;
}
//==========================================================
{
}
-QColor SVTK_Viewer::backgroundColor() const
+QColor
+SVTK_Viewer
+::backgroundColor() const
{
return myBgColor;
}
-void SVTK_Viewer::setBackgroundColor( const QColor& c )
+void
+SVTK_Viewer
+::setBackgroundColor( const QColor& theColor )
{
- if ( c.isValid() )
- myBgColor = c;
+ if ( !theColor.isValid() )
+ return;
+
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
+ if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViewWindow)){
+ aView->setBackgroundColor(theColor);
+ }
+ }
+ }
+
+ myBgColor = theColor;
}
//==========================================================
-SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop )
+SUIT_ViewWindow*
+SVTK_Viewer::
+createView( SUIT_Desktop* theDesktop )
{
- SVTK_ViewWindow* vw = new SVTK_ViewWindow( theDesktop, this );
- vw->setBackgroundColor( backgroundColor() );
- vw->SetTrihedronSize( trihedronSize() );
- return vw;
+ TViewWindow* aViewWindow = new TViewWindow(theDesktop);
+ aViewWindow->Initialize(this);
+
+ aViewWindow->setBackgroundColor( backgroundColor() );
+ aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() );
+
+ return aViewWindow;
}
int SVTK_Viewer::trihedronSize() const
return myTrihedronSize;
}
-void SVTK_Viewer::setTrihedronSize( const int sz )
+bool SVTK_Viewer::trihedronRelative() const
{
- myTrihedronSize = sz;
-
- SUIT_ViewManager* vm = getViewManager();
- if ( !vm )
- return;
-
- QPtrVector<SUIT_ViewWindow> vec = vm->getViews();
- for ( int i = 0; i < vec.count(); i++ )
- {
- SUIT_ViewWindow* win = vec.at( i );
- if ( !win || !win->inherits( "SVTK_ViewWindow" ) )
- continue;
+ return myTrihedronRelative;
+}
- SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win;
- vw->SetTrihedronSize( sz );
+void SVTK_Viewer::setTrihedronSize( const int theSize, const bool theRelative )
+{
+ myTrihedronSize = theSize;
+ myTrihedronRelative = theRelative;
+
+ if (SUIT_ViewManager* aViewManager = getViewManager()) {
+ QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+ for (int i = 0; i < aViews.count(); i++) {
+ if (TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at(i))) {
+ aView->SetTrihedronSize(theSize, theRelative);
+ }
+ }
}
}
}
//==========================================================
-void SVTK_Viewer::contextMenuPopup( QPopupMenu* thePopup )
+void
+SVTK_Viewer
+::contextMenuPopup( QPopupMenu* thePopup )
{
- thePopup->insertItem( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
- thePopup->insertItem( tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );
+ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
+ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );
thePopup->insertSeparator();
- SVTK_ViewWindow* aView = (SVTK_ViewWindow*)(myViewManager->getActiveView());
- if ( aView && !aView->getToolBar()->isVisible() )
- thePopup->insertItem( tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
-}
-
-//==========================================================
-void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
-{
- if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){
- switch(event->button()) {
- case LeftButton:
- aRWI->LeftButtonPressed(event) ;
- break ;
- case MidButton:
- aRWI->MiddleButtonPressed(event) ;
- break ;
- case RightButton:
- aRWI->RightButtonPressed(event) ;
- break;
- default:
- break ;
- }
+ if(TViewWindow* aView = dynamic_cast<TViewWindow*>(myViewManager->getActiveView())){
+ if ( !aView->getMainWindow()->getToolBar()->isVisible() ){
+ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
}
}
}
+//==========================================================
+void
+SVTK_Viewer
+::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
+{}
+
//==========================================================
void
SVTK_Viewer
::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)
-{
- if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){
- aRWI->MouseMove( event );
- }
- }
-}
+{}
//==========================================================
void
SVTK_Viewer
::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)
-{
- if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){
- switch(event->button()) {
- case LeftButton:
- aRWI->LeftButtonReleased(event) ;
- break ;
- case MidButton:
- aRWI->MiddleButtonReleased(event) ;
- break ;
- case RightButton:
- aRWI->RightButtonReleased(event) ;
- break;
- default:
- break ;
- }
- }
- }
-}
+{}
//==========================================================
void
//!! To be done for view windows
}
-void SVTK_Viewer::onDumpView()
+void
+SVTK_Viewer
+::onDumpView()
{
- SVTK_ViewWindow* aView = (SVTK_ViewWindow*)(myViewManager->getActiveView());
- if ( aView )
+ if(SUIT_ViewWindow* aView = myViewManager->getActiveView())
aView->onDumpView();
}
//==========================================================
-void SVTK_Viewer::onChangeBgColor()
+void
+SVTK_Viewer
+::onChangeBgColor()
{
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)){
- QColor aColor = QColorDialog::getColor( aView->backgroundColor(), aView);
- if ( aColor.isValid() )
- aView->setBackgroundColor(aColor);
- }
+ if(SUIT_ViewWindow* aView = myViewManager->getActiveView()){
+ QColor aColor = QColorDialog::getColor( backgroundColor(), aView);
+ setBackgroundColor(aColor);
+ }
}
//==========================================================
::onShowToolbar()
{
QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- aView->getToolBar()->show();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at(i))){
+ aView->getMainWindow()->getToolBar()->show();
+ }
+ }
}
//==========================================================
return;
if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
// get SALOMEDS Study
- _PTR(Study) aStudy(getStudyDS());
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ // _PTR(Study) aStudy(getStudyDS());
anActorCollection->InitTraversal();
while(vtkActor* anActor = anActorCollection->GetNextActor()){
if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
// Set visibility flag
- Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
- if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
- ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this);
- }
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+ //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
+ // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this);
+ //}
// just display the object
QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)){
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()){
- aRWI->Display(anAct,false);
- if(anAct->IsSetCamera()){
- vtkRenderer* aRenderer = aView->getRenderer();
- anAct->SetCamera( aRenderer->GetActiveCamera() );
- }
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
+ if(SVTK_View* aView = aViewWindow->getView()){
+ aView->Display(anAct,false);
+ if(anAct->IsSetCamera()){
+ vtkRenderer* aRenderer = aView->getRenderer();
+ anAct->SetCamera( aRenderer->GetActiveCamera() );
}
}
}
return;
if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
// get SALOMEDS Study
- _PTR(Study) aStudy(getStudyDS());
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //_PTR(Study) aStudy(getStudyDS());
anActorCollection->InitTraversal();
while(vtkActor* anActor = anActorCollection->GetNextActor())
if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
// Set visibility flag
- Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
- if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
- ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
- }
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+ //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
+ // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
+ //}
// just display the object
QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor())
- if ( forced )
- aRWI->Remove(anAct,false);
- else
- aRWI->Erase(anAct,forced);
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
+ if(SVTK_View* aView = aViewWindow->getView())
+ if ( forced )
+ aView->Remove(anAct,false);
+ else
+ aView->Erase(anAct,forced);
}
}
}
SVTK_Viewer
::EraseAll( const bool forced )
{
- _PTR(Study) aStudy(getStudyDS());
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //_PTR(Study) aStudy(getStudyDS());
QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)){
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
+ if(SVTK_View* aView = aViewWindow->getView()){
vtkRenderer* aRenderer = aView->getRenderer();
vtkActorCollection* anActorCollection = aRenderer->GetActors();
anActorCollection->InitTraversal();
while(vtkActor* anActor = anActorCollection->GetNextActor()){
if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
// Set visibility flag
- Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
- if(!anObj.IsNull() && anObj->hasEntry() && aStudy)
- ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+ //if(!anObj.IsNull() && anObj->hasEntry() && aStudy)
+ // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
if(forced)
aRenderer->RemoveActor(anAct);
else{
}
}
}
- }
}
Repaint();
}
{
SVTK_Prs* prs = new SVTK_Prs();
if ( entry ) {
- vtkRenderer* rnr = ( (SVTK_ViewWindow*) getViewManager()->getActiveView() )->getRenderer();
- vtkActorCollection* theActors = rnr->GetActors();
- theActors->InitTraversal();
- vtkActor* ac;
- while( ( ac = theActors->GetNextActor() ) ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {
- prs->AddObject( ac );
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(getViewManager()->getActiveView()))
+ if(SVTK_View* aView = aViewWindow->getView()){
+ vtkRenderer* aRenderer = aView->getRenderer();
+ vtkActorCollection* theActors = aRenderer->GetActors();
+ theActors->InitTraversal();
+ vtkActor* ac;
+ while( ( ac = theActors->GetNextActor() ) ) {
+ SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
+ if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {
+ prs->AddObject( ac );
+ }
+ }
}
- }
}
return prs;
}
QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor())
- if(!aRWI->isVisible( io ))
- return false;
+ if(TViewWindow* aViewWnd = dynamic_cast<TViewWindow*>(aViewWindow))
+ if(SVTK_View* aView = aViewWnd->getView())
+ if(!aView->isVisible( io ))
+ return false;
+
return true;
}
// if (theUpdateTrihedron) onAdjustTrihedron();
QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- if(SVTK_RenderWindow* aRW = aView->getRenderWindow())
- {
- aView->getRenderer()->Render();
- aView->getRWInteractor()->unHighlightAll();
- aRW->update();
- }
+ if(TViewWindow* aViewWindow = dynamic_cast<TViewWindow*>(aViews.at(i)))
+ if(SVTK_View* aView = aViewWindow->getView())
+ aView->Repaint();
}
-
-void
-SVTK_Viewer
-::onSelectionChanged()
-{
- emit selectionChanged();
-}
-