Back to index

salome-gui  6.5.0
SVTK_ViewModel.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include <QMenu>
00024 #include <QColorDialog>
00025 #include <QToolBar>
00026 
00027 #include <vtkCamera.h>
00028 #include <vtkRenderer.h>
00029 #include <vtkActorCollection.h>
00030 
00031 //#include "SUIT_Session.h"
00032 #include "SVTK_Selection.h"
00033 #include "SVTK_ViewModel.h"
00034 #include "SVTK_ViewWindow.h"
00035 #include "SVTK_View.h"
00036 //#include "SVTK_MainWindow.h"
00037 #include "SVTK_Prs.h"
00038 
00039 #include "VTKViewer_Algorithm.h"
00040 #include "VTKViewer_ViewModel.h"
00041 
00042 #include "SUIT_ViewModel.h"
00043 #include "SUIT_ViewManager.h"
00044 
00045 #include "SALOME_Actor.h"
00046 
00047 #include "QtxActionToolMgr.h"
00048 #include "QtxBackgroundTool.h"
00049 
00050 // VSR: Uncomment below line to allow texture background support in VTK viewer
00051 #define VTK_ENABLE_TEXTURED_BACKGROUND
00052 
00053 
00054 // in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
00055 // SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from 
00056 // SALOMEDS::StudyManager - no linkage with SalomeApp. 
00057 
00058 // Temporarily commented to avoid awful dependecy on SALOMEDS
00059 // TODO: better mechanism of storing display/erse status in a study
00060 // should be provided...
00061 //static _PTR(Study) getStudyDS() 
00062 //{
00063 //  SALOMEDSClient_Study* aStudy = NULL;
00064 //  _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
00065   // get id of SUIT_Study, if it's a SalomeApp_Study, it will return
00066   //    id of its underlying SALOMEDS::Study
00067 //  SUIT_Application* app = SUIT_Session::session()->activeApplication();
00068 //  if ( !app )  return _PTR(Study)(aStudy); 
00069 //  SUIT_Study* stud = app->activeStudy();
00070 //  if ( !stud ) return _PTR(Study)(aStudy);  
00071 //  const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
00072   // get SALOMEDS_Study with this id from StudyMgr
00073 //  return aMgr->GetStudyByID( id );
00074 //}
00075 
00079 SVTK_Viewer::SVTK_Viewer()
00080 {
00081   myTrihedronSize = 105;
00082   myTrihedronRelative = true;
00083   myIsStaticTrihedronVisible = true;
00084   myIncrementSpeed = 10;
00085   myIncrementMode = 0;
00086   myProjMode = 0;
00087   myStyle = 0;
00088   myZoomingStyle = 0;
00089   myDynamicPreSelection = false;
00090   mySpaceBtn[0] = 1;
00091   mySpaceBtn[1] = 2;
00092   mySpaceBtn[2] = 9;
00093   myDefaultBackground = Qtx::BackgroundData( Qt::black );
00094 }
00095 
00099 SVTK_Viewer::~SVTK_Viewer() 
00100 {
00101 }
00102 
00104 QString SVTK_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList )
00105 {
00106   gradList << tr( "GT_HORIZONTALGRADIENT" )
00107            << tr( "GT_VERTICALGRADIENT" )
00108            << tr( "GT_FIRSTDIAGONALGRADIENT" )
00109            << tr( "GT_SECONDDIAGONALGRADIENT" )
00110            << tr( "GT_FIRSTCORNERGRADIENT" )
00111            << tr( "GT_SECONDCORNERGRADIENT" )
00112            << tr( "GT_THIRDCORNERGRADIENT" )
00113            << tr( "GT_FOURTHCORNERGRADIENT" );
00114   idList   << HorizontalGradient
00115            << VerticalGradient
00116            << FirstDiagonalGradient
00117            << SecondDiagonalGradient
00118            << FirstCornerGradient
00119            << SecondCornerGradient
00120            << ThirdCornerGradient
00121            << FourthCornerGradient;
00122 #ifdef VTK_ENABLE_TEXTURED_BACKGROUND
00123   txtList  << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
00124 #endif
00125   return tr("BG_IMAGE_FILES");
00126 }
00127 
00129 QColor SVTK_Viewer::backgroundColor() const
00130 {
00131   return background().color();
00132 }
00133 
00135 void SVTK_Viewer::setBackgroundColor( const QColor& c )
00136 {
00137   Qtx::BackgroundData bg = background();
00138   bg.setColor( c );
00139   setBackground( bg );
00140 }
00141 
00145 Qtx::BackgroundData SVTK_Viewer::background() const
00146 {
00147   return myDefaultBackground;
00148 }
00149 
00154 void SVTK_Viewer::setBackground( const Qtx::BackgroundData& theBackground )
00155 {
00156   myDefaultBackground = theBackground.isValid() ? theBackground : Qtx::BackgroundData( Qt::black );
00157   QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
00158   for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
00159     if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
00160       if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViewWindow)){
00161         aView->setBackground(myDefaultBackground);
00162       }
00163     }
00164   }  
00165 }
00166 
00170 SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop )
00171 {
00172   TViewWindow* aViewWindow = new TViewWindow(theDesktop);
00173   aViewWindow->Initialize(this);
00174 
00175   aViewWindow->setBackground( background() );
00176   aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() );
00177   aViewWindow->SetStaticTrihedronVisible( isStaticTrihedronVisible() );
00178   aViewWindow->SetProjectionMode( projectionMode() );
00179   aViewWindow->SetInteractionStyle( interactionStyle() );
00180   aViewWindow->SetZoomingStyle( zoomingStyle() );
00181   aViewWindow->SetDynamicPreSelection( dynamicPreSelection() );
00182   aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() );
00183   aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) );
00184 
00185   connect(aViewWindow, SIGNAL( actorAdded(VTKViewer_Actor*) ), 
00186           this,  SLOT(onActorAdded(VTKViewer_Actor*)));
00187   connect(aViewWindow, SIGNAL( actorRemoved(VTKViewer_Actor*) ), 
00188           this,  SLOT(onActorRemoved(VTKViewer_Actor*)));
00189 
00190   return aViewWindow;
00191 }
00192 
00196 vtkFloatingPointType SVTK_Viewer::trihedronSize() const
00197 {
00198   return myTrihedronSize;
00199 }
00200 
00204 bool SVTK_Viewer::trihedronRelative() const
00205 {
00206   return myTrihedronRelative;
00207 }
00208 
00214 void SVTK_Viewer::setTrihedronSize( const vtkFloatingPointType theSize, const bool theRelative )
00215 {
00216   myTrihedronSize = theSize;
00217   myTrihedronRelative = theRelative;
00218 
00219   if (SUIT_ViewManager* aViewManager = getViewManager()) {
00220     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
00221     for ( uint i = 0; i < aViews.count(); i++ )
00222     {
00223       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
00224               aView->SetTrihedronSize( theSize, theRelative );
00225     }
00226   }
00227 }
00228 
00232 bool SVTK_Viewer::isStaticTrihedronVisible() const
00233 {
00234   return myIsStaticTrihedronVisible;
00235 }
00236 
00241 void SVTK_Viewer::setStaticTrihedronVisible( const bool theIsVisible )
00242 {
00243   myIsStaticTrihedronVisible = theIsVisible;
00244 
00245   if (SUIT_ViewManager* aViewManager = getViewManager()) {
00246     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
00247     for ( uint i = 0; i < aViews.count(); i++ )
00248     {
00249       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
00250         aView->SetStaticTrihedronVisible( theIsVisible );
00251     }
00252   }
00253 }
00254 
00258 int SVTK_Viewer::projectionMode() const
00259 {
00260   return myProjMode;
00261 }
00262 
00263 
00268 void SVTK_Viewer::setProjectionMode( const int theMode )
00269 {
00270   if ( myProjMode != theMode ) {
00271     myProjMode = theMode;
00272 
00273     if (SUIT_ViewManager* aViewManager = getViewManager()) {
00274       QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
00275       for ( uint i = 0; i < aViews.count(); i++ )
00276       {
00277         if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
00278           aView->SetProjectionMode( theMode );
00279       }
00280     }
00281   }
00282 }
00283 
00287 int SVTK_Viewer::interactionStyle() const
00288 {
00289   return myStyle;
00290 }
00291 
00296 void SVTK_Viewer::setInteractionStyle( const int theStyle )
00297 {
00298   myStyle = theStyle;
00299   
00300   if (SUIT_ViewManager* aViewManager = getViewManager()) {
00301     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
00302     for ( uint i = 0; i < aViews.count(); i++ )
00303     {
00304       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
00305         aView->SetInteractionStyle( theStyle );
00306     }
00307   }
00308 }
00309 
00313 int SVTK_Viewer::zoomingStyle() const
00314 {
00315   return myZoomingStyle;
00316 }
00317 
00322 void SVTK_Viewer::setZoomingStyle( const int theStyle )
00323 {
00324   myZoomingStyle = theStyle;
00325   
00326   if (SUIT_ViewManager* aViewManager = getViewManager()) {
00327     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
00328     for ( uint i = 0; i < aViews.count(); i++ )
00329     {
00330       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
00331         aView->SetZoomingStyle( theStyle );
00332     }
00333   }
00334 }
00335 
00339 bool SVTK_Viewer::dynamicPreSelection() const
00340 {
00341   return myDynamicPreSelection;
00342 }
00343 
00348 void SVTK_Viewer::setDynamicPreSelection( const bool theMode )
00349 {
00350   myDynamicPreSelection = theMode;
00351   
00352   if (SUIT_ViewManager* aViewManager = getViewManager()) {
00353     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
00354     for ( uint i = 0; i < aViews.count(); i++ )
00355     {
00356       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
00357         aView->SetDynamicPreSelection( theMode );
00358     }
00359   }
00360 }
00361 
00365 int SVTK_Viewer::incrementalSpeed() const
00366 {
00367   return myIncrementSpeed;
00368 }
00369 
00373 int SVTK_Viewer::incrementalSpeedMode() const
00374 {
00375   return myIncrementMode;
00376 }
00377 
00383 void SVTK_Viewer::setIncrementalSpeed( const int theValue, const int theMode )
00384 {
00385   myIncrementSpeed = theValue;
00386   myIncrementMode = theMode;
00387 
00388   if (SUIT_ViewManager* aViewManager = getViewManager()) {
00389     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
00390     for ( uint i = 0; i < aViews.count(); i++ )
00391     {
00392       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
00393         aView->SetIncrementalSpeed( theValue, theMode );
00394     }
00395   }
00396 }
00397 
00402 int SVTK_Viewer::spacemouseBtn( const int theIndex ) const
00403 {
00404   if ( theIndex < 1 || theIndex > 3 ) 
00405     return -1;
00406   return mySpaceBtn[theIndex-1];
00407 }
00408 
00413 void SVTK_Viewer::setSpacemouseButtons( const int theBtn1, const int theBtn2, const int theBtn3 )
00414 {
00415   mySpaceBtn[0] = theBtn1;
00416   mySpaceBtn[1] = theBtn2;
00417   mySpaceBtn[2] = theBtn3;
00418 
00419   if (SUIT_ViewManager* aViewManager = getViewManager()) {
00420     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
00421     for ( uint i = 0; i < aViews.count(); i++ )
00422     {
00423       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
00424         aView->SetSpacemouseButtons( theBtn1, theBtn2, theBtn3 );
00425     }
00426   }
00427 }
00428 
00433 void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
00434 {
00435   SUIT_ViewModel::setViewManager(theViewManager);
00436 
00437   if ( !theViewManager )
00438     return;
00439 
00440   connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), 
00441           this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
00442   
00443   connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), 
00444           this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
00445   
00446   connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), 
00447           this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
00448 }
00449 
00453 void SVTK_Viewer::contextMenuPopup( QMenu* thePopup )
00454 {
00455   thePopup->addAction( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
00456   thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) );
00457 
00458   thePopup->addSeparator();
00459 
00460   if(TViewWindow* aView = dynamic_cast<TViewWindow*>(myViewManager->getActiveView())){
00461     //Support of several toolbars in the popup menu
00462     QList<QToolBar*> lst = qFindChildren<QToolBar*>( aView );
00463     QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
00464     for( ; it!=last; it++ )
00465       thePopup->addAction( (*it)->toggleViewAction() );
00466     aView->RefreshDumpImage();
00467   }
00468 }
00469 
00473 void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
00474 {}
00475 
00479 void SVTK_Viewer::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)
00480 {}
00481 
00485 void SVTK_Viewer::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)
00486 {}
00487 
00492 void SVTK_Viewer::enableSelection(bool isEnabled)
00493 {
00494   mySelectionEnabled = isEnabled;
00496 }
00497 
00502 void SVTK_Viewer::enableMultiselection(bool isEnable)
00503 {
00504   myMultiSelectionEnabled = isEnable;
00506 }
00507 
00511 void SVTK_Viewer::onDumpView()
00512 {
00513   if(SUIT_ViewWindow* aView = myViewManager->getActiveView())
00514     aView->onDumpView();
00515 }
00516 
00520 void SVTK_Viewer::onChangeBackground()
00521 {
00522   SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(myViewManager->getActiveView());
00523   if ( !aView )
00524     return;
00525 
00526   // get supported gradient types
00527   QStringList gradList;
00528   QIntList    idList, txtList;
00529   QString     formats = backgroundData( gradList, idList, txtList );
00530 
00531   // invoke dialog box
00532   Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(),  // initial background
00533                                                            aView,                // parent for dialog box
00534                                                            txtList,              // allowed texture modes
00535                                                            true,                 // enable solid color mode
00536                                                            true,                 // enable gradient mode
00537                                                            false,                // disable custom gradient mode
00538                                                            !txtList.isEmpty(),   // enable texture mode
00539                                                            gradList,             // gradient names
00540                                                            idList,               // gradient identifiers
00541                                                            formats );            // image formats
00542 
00543   // set chosen background data to the viewer
00544   if ( bgData.isValid() )
00545     aView->setBackground( bgData );
00546 }
00547 
00552 void SVTK_Viewer::Display( const SALOME_VTKPrs* prs )
00553 {
00554   // try do downcast object
00555   if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){
00556     if(aPrs->IsNull())
00557       return;
00558     if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
00559       // get SALOMEDS Study
00560       // Temporarily commented to avoid awful dependecy on SALOMEDS
00561       // TODO: better mechanism of storing display/erse status in a study
00562       // should be provided...
00563       // _PTR(Study) aStudy(getStudyDS());
00564       anActorCollection->InitTraversal();
00565       while(vtkActor* anActor = anActorCollection->GetNextActor()){
00566         if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
00567           if(!anAct->ShouldBeDisplayed())
00568             continue;
00569           // Set visibility flag
00570           // Temporarily commented to avoid awful dependecy on SALOMEDS
00571           // TODO: better mechanism of storing display/erse status in a study
00572           // should be provided...
00573           //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
00574           //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
00575           //  ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this);
00576           //}
00577           // just display the object
00578           QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
00579           for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
00580             if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
00581               if(SVTK_View* aView = aViewWindow->getView()){
00582                 aView->Display(anAct,false);
00583                 if(anAct->IsSetCamera()){
00584                   vtkRenderer* aRenderer = aView->getRenderer();
00585                   anAct->SetCamera( aRenderer->GetActiveCamera() );
00586                 }
00587               }
00588             }
00589           }
00590         }
00591       }
00592     }
00593   }
00594 }
00595 
00601 void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced )
00602 {
00603   // try do downcast object
00604   if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){
00605     if(aPrs->IsNull())
00606       return;
00607     if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
00608       // get SALOMEDS Study
00609       // Temporarily commented to avoid awful dependecy on SALOMEDS
00610       // TODO: better mechanism of storing display/erase status in a study
00611       // should be provided...
00612       //_PTR(Study) aStudy(getStudyDS());
00613       anActorCollection->InitTraversal();
00614       while(vtkActor* anActor = anActorCollection->GetNextActor())
00615         if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
00616           // Set visibility flag
00617           // Temporarily commented to avoid awful dependecy on SALOMEDS
00618           // TODO: better mechanism of storing display/erase status in a study
00619           // should be provided...
00620           //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
00621           //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
00622           //  ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
00623           //}
00624           // just display the object
00625           QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
00626           for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
00627             if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
00628               if(SVTK_View* aView = aViewWindow->getView())
00629               {
00630                 if ( forced )
00631                   aView->Remove(anAct,false);
00632                 else
00633                   aView->Erase(anAct,forced);
00634               }
00635           }
00636         }
00637     }
00638   }
00639 }
00640 
00645 void SVTK_Viewer::EraseAll( const bool forced )
00646 {
00647   // Temporarily commented to avoid awful dependecy on SALOMEDS
00648   // TODO: better mechanism of storing display/erse status in a study
00649   // should be provided...
00650   //_PTR(Study) aStudy(getStudyDS());
00651   QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
00652   for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
00653     if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
00654       if(SVTK_View* aView = aViewWindow->getView()){
00655         vtkRenderer* aRenderer =  aView->getRenderer();
00656         VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
00657         vtkActorCollection* anActorCollection = aCopy.GetActors();
00658         anActorCollection->InitTraversal();
00659         while(vtkActor* anActor = anActorCollection->GetNextActor()){
00660           if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
00661             // Set visibility flag
00662             // Temporarily commented to avoid awful dependecy on SALOMEDS
00663             // TODO: better mechanism of storing display/erse status in a study
00664             // should be provided...
00665             //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
00666             //if(!anObj.IsNull() && anObj->hasEntry() && aStudy)
00667             //  ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
00668             if(forced)
00669               aRenderer->RemoveActor(anAct);
00670             else{
00671               // just erase actor
00672               anAct->SetVisibility( false );
00673               // erase dependent actors
00674               vtkActorCollection* aCollection = vtkActorCollection::New();
00675               anAct->GetChildActors( aCollection );
00676               aCollection->InitTraversal();
00677               while(vtkActor* aSubAct = aCollection->GetNextActor())
00678                 aSubAct->SetVisibility( false );
00679               aCollection->Delete();
00680             }
00681           }
00682         }
00683       }
00684   }
00685   Repaint();
00686 }
00687 
00692 SALOME_Prs* SVTK_Viewer::CreatePrs( const char* entry )
00693 {
00694   SVTK_Prs* prs = new SVTK_Prs();
00695   if ( entry ) {
00696     if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(getViewManager()->getActiveView()))
00697       if(SVTK_View* aView = aViewWindow->getView()){
00698         vtkRenderer* aRenderer =  aView->getRenderer();
00699         VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
00700         vtkActorCollection* theActors = aCopy.GetActors();
00701         theActors->InitTraversal();
00702         vtkActor* ac;
00703         while( ( ac = theActors->GetNextActor() ) ) {
00704           SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
00705           if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {
00706             prs->AddObject( ac );
00707           }
00708         }
00709       }
00710   }
00711   return prs;
00712 }
00713 
00718 bool SVTK_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& io )
00719 {
00720   QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
00721   for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
00722     if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
00723       if(TViewWindow* aViewWnd = dynamic_cast<TViewWindow*>(aViewWindow))
00724         if(SVTK_View* aView = aViewWnd->getView())
00725           if(!aView->isVisible( io ))
00726             return false;
00727 
00728   return true;
00729 }
00730 
00735 void SVTK_Viewer::GetVisible( SALOME_ListIO& theList )
00736 {
00737   // here we collect object if it is disaplaed even one view
00738   QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
00739   for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
00740     if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
00741       if(TViewWindow* aViewWnd = dynamic_cast<TViewWindow*>(aViewWindow))
00742         if(SVTK_View* aView = aViewWnd->getView())
00743           aView->GetVisible( theList );
00744 }
00745 
00749 void SVTK_Viewer::Repaint()
00750 {
00751 //  if (theUpdateTrihedron) onAdjustTrihedron();
00752   QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
00753   for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
00754     if(TViewWindow* aViewWindow = dynamic_cast<TViewWindow*>(aViews.at(i)))
00755       if(SVTK_View* aView = aViewWindow->getView())
00756         aView->Repaint();
00757 }
00758  
00759 
00760 void SVTK_Viewer::onActorAdded(VTKViewer_Actor* theActor)
00761 {
00762   emit actorAdded((SVTK_ViewWindow*)sender(), theActor);
00763 }
00764 
00765 void SVTK_Viewer::onActorRemoved(VTKViewer_Actor* theActor)
00766 {
00767   emit actorRemoved((SVTK_ViewWindow*)sender(), theActor);
00768 }