1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #include <QColorDialog>
27 #include <vtkCamera.h>
28 #include <vtkRenderer.h>
29 #include <vtkActorCollection.h>
31 //#include "SUIT_Session.h"
32 #include "SVTK_ViewModel.h"
33 #include "SVTK_ViewWindow.h"
34 #include "SVTK_View.h"
35 #include "SVTK_Renderer.h"
36 //#include "SVTK_MainWindow.h"
39 #include "VTKViewer_Algorithm.h"
40 #include "VTKViewer_ViewModel.h"
42 #include "SUIT_ViewModel.h"
43 #include "SUIT_ViewManager.h"
45 #include "SALOME_Actor.h"
47 #include "QtxActionToolMgr.h"
48 #include "QtxBackgroundTool.h"
50 // VSR: Uncomment below line to allow texture background support in VTK viewer
51 #define VTK_ENABLE_TEXTURED_BACKGROUND
56 SVTK_Viewer::SVTK_Viewer()
58 myTrihedronSize = 105;
59 myTrihedronRelative = true;
60 myIsStaticTrihedronVisible = true;
61 myIncrementSpeed = 10;
68 mySelectionEnabled = true;
69 myPreSelectionMode = Standard_Preselection;
73 myDefaultBackground = Qtx::BackgroundData( Qt::black );
74 myQuadBufferSupport = false;
80 SVTK_Viewer::~SVTK_Viewer()
84 /*! Get data for supported background modes: gradient types, identifiers and supported image formats */
85 QString SVTK_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList )
87 gradList << tr( "GT_HORIZONTALGRADIENT" )
88 << tr( "GT_VERTICALGRADIENT" )
89 << tr( "GT_FIRSTDIAGONALGRADIENT" )
90 << tr( "GT_SECONDDIAGONALGRADIENT" )
91 << tr( "GT_FIRSTCORNERGRADIENT" )
92 << tr( "GT_SECONDCORNERGRADIENT" )
93 << tr( "GT_THIRDCORNERGRADIENT" )
94 << tr( "GT_FOURTHCORNERGRADIENT" );
95 idList << HorizontalGradient
97 << FirstDiagonalGradient
98 << SecondDiagonalGradient
99 << FirstCornerGradient
100 << SecondCornerGradient
101 << ThirdCornerGradient
102 << FourthCornerGradient;
103 #ifdef VTK_ENABLE_TEXTURED_BACKGROUND
104 txtList << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
106 return tr("BG_IMAGE_FILES");
109 /*! Get data for supported background modes: gradient types, identifiers and supported image formats */
110 void SVTK_Viewer::stereoData( QStringList& typeList, QIntList& idList )
112 typeList << tr("ST_CRYSTALEYES") << tr("ST_REDBLUE") <<
113 tr("ST_INTERLACED") << tr("ST_LEFT") <<
114 tr("ST_RIGHT") << tr("ST_DRESDEN") <<
115 tr("ST_ANAGLYPH") << tr("ST_CHECKERBOARD") <<
116 tr("ST_SPLITVIEWPORTHORIZONTAL");
117 idList << CrystalEyesType << RedBlueType <<
118 InterlacedType << LeftType <<
119 RightType << DresdenType <<
120 AnaglyphType << CheckerboardType <<
121 SplitViewPortHorizontalType;
124 //! Get background color of the viewer [obsolete]
125 QColor SVTK_Viewer::backgroundColor() const
127 return background().color();
130 //! Set background color to the viewer [obsolete]
131 void SVTK_Viewer::setBackgroundColor( const QColor& c )
133 Qtx::BackgroundData bg = background();
139 \return background data
141 Qtx::BackgroundData SVTK_Viewer::background() const
143 return myDefaultBackground;
148 \param theBackground - new background data
150 void SVTK_Viewer::setBackground( const Qtx::BackgroundData& theBackground )
152 myDefaultBackground = theBackground.isValid() ? theBackground : Qtx::BackgroundData( Qt::black );
153 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
154 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
155 if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
156 if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViewWindow)){
157 aView->setBackground(myDefaultBackground);
163 /*!Create new instance of view window on desktop \a theDesktop.
164 *\retval SUIT_ViewWindow* - created view window pointer.
166 SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop )
168 TViewWindow* aViewWindow = new TViewWindow(theDesktop);
169 aViewWindow->Initialize(this);
171 aViewWindow->setBackground( background() );
172 aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() );
173 aViewWindow->SetStaticTrihedronVisible( isStaticTrihedronVisible() );
174 aViewWindow->SetProjectionMode( projectionMode() );
175 aViewWindow->SetStereoType( stereoType() );
176 aViewWindow->SetAnaglyphFilter( anaglyphFilter() );
177 aViewWindow->SetQuadBufferSupport( isQuadBufferSupport() );
178 aViewWindow->SetInteractionStyle( interactionStyle() );
179 aViewWindow->SetZoomingStyle( zoomingStyle() );
180 aViewWindow->SetPreSelectionMode( preSelectionMode() );
181 aViewWindow->SetSelectionEnabled( isSelectionEnabled() );
182 aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() );
183 aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) );
185 connect(aViewWindow, SIGNAL( actorAdded(VTKViewer_Actor*) ),
186 this, SLOT(onActorAdded(VTKViewer_Actor*)));
187 connect(aViewWindow, SIGNAL( actorRemoved(VTKViewer_Actor*) ),
188 this, SLOT(onActorRemoved(VTKViewer_Actor*)));
194 \return trihedron size
196 double SVTK_Viewer::trihedronSize() const
198 return myTrihedronSize;
202 \return true if thihedron changes size in accordance with bounding box
204 bool SVTK_Viewer::trihedronRelative() const
206 return myTrihedronRelative;
210 Sets trihedron size and relativeness( whether thihedron changes size in accordance with bounding box)
211 \param theSize - new size
212 \param theRelative - new relativeness
214 void SVTK_Viewer::setTrihedronSize( const double theSize, const bool theRelative )
216 myTrihedronSize = theSize;
217 myTrihedronRelative = theRelative;
219 if (SUIT_ViewManager* aViewManager = getViewManager()) {
220 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
221 for ( uint i = 0; i < aViews.count(); i++ )
223 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
224 aView->SetTrihedronSize( theSize, theRelative );
230 \return visibility status of the static trihedron
232 bool SVTK_Viewer::isStaticTrihedronVisible() const
234 return myIsStaticTrihedronVisible;
238 Sets visibility status of the static trihedron
239 \param theIsVisible - new visibility status
241 void SVTK_Viewer::setStaticTrihedronVisible( const bool theIsVisible )
243 myIsStaticTrihedronVisible = theIsVisible;
245 if (SUIT_ViewManager* aViewManager = getViewManager()) {
246 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
247 for ( uint i = 0; i < aViews.count(); i++ )
249 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
250 aView->SetStaticTrihedronVisible( theIsVisible );
256 \return projection mode
258 int SVTK_Viewer::projectionMode() const
265 Sets projection mode: 0 - orthogonal, 1 - perspective projection
266 \param theMode - new projection mode
268 void SVTK_Viewer::setProjectionMode( const int theMode )
270 if ( myProjMode != theMode ) {
271 if ( theMode != SVTK_ViewWindow::Stereo )
272 myProjMode = theMode;
273 if (SUIT_ViewManager* aViewManager = getViewManager()) {
274 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
275 for ( uint i = 0; i < aViews.count(); i++ )
277 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
278 aView->SetProjectionMode( theMode );
287 int SVTK_Viewer::stereoType() const
294 \param theType - new stereo type
296 void SVTK_Viewer::setStereoType( const int theType )
298 if ( myStereoType != theType ) {
299 myStereoType = theType;
301 if (SUIT_ViewManager* aViewManager = getViewManager()) {
302 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
303 for ( uint i = 0; i < aViews.count(); i++ )
305 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
306 aView->SetStereoType( theType );
313 \return anaglyph filter
315 int SVTK_Viewer::anaglyphFilter() const
317 return myAnaglyphFilter;
322 \param theFilter - new anaglyph filter
324 void SVTK_Viewer::setAnaglyphFilter( const int theFilter )
326 if ( myAnaglyphFilter != theFilter ) {
327 myAnaglyphFilter = theFilter;
329 if (SUIT_ViewManager* aViewManager = getViewManager()) {
330 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
331 for ( uint i = 0; i < aViews.count(); i++ )
333 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
334 aView->SetAnaglyphFilter( theFilter );
341 \return support quad-buffered stereo
343 bool SVTK_Viewer::isQuadBufferSupport() const
345 return myQuadBufferSupport;
349 Set support quad-buffered stereo
350 \param theEnable - enable/disable support quad-buffered stereo
352 void SVTK_Viewer::setQuadBufferSupport( const bool theEnable )
354 if ( myQuadBufferSupport != theEnable ) {
355 myQuadBufferSupport = theEnable;
357 if (SUIT_ViewManager* aViewManager = getViewManager()) {
358 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
359 for ( uint i = 0; i < aViews.count(); i++ )
361 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
362 aView->SetQuadBufferSupport( theEnable );
368 \return interaction style
370 int SVTK_Viewer::interactionStyle() const
376 Sets interaction style: 0 - standard, 1 - keyboard free interaction
377 \param theStyle - new interaction style
379 void SVTK_Viewer::setInteractionStyle( const int theStyle )
383 if (SUIT_ViewManager* aViewManager = getViewManager()) {
384 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
385 for ( uint i = 0; i < aViews.count(); i++ )
387 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
388 aView->SetInteractionStyle( theStyle );
394 \return zooming style
396 int SVTK_Viewer::zoomingStyle() const
398 return myZoomingStyle;
402 Sets zooming style: 0 - standard, 1 - advanced (at cursor)
403 \param theStyle - new zooming style
405 void SVTK_Viewer::setZoomingStyle( const int theStyle )
407 myZoomingStyle = theStyle;
409 if (SUIT_ViewManager* aViewManager = getViewManager()) {
410 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
411 for ( uint i = 0; i < aViews.count(); i++ )
413 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
414 aView->SetZoomingStyle( theStyle );
420 \return current preselection mode
422 Preselection_Mode SVTK_Viewer::preSelectionMode() const
424 return myPreSelectionMode;
428 Sets preselection mode
429 \param theMode - new preselection mode
431 void SVTK_Viewer::setPreSelectionMode( Preselection_Mode theMode )
433 myPreSelectionMode = theMode;
435 if (SUIT_ViewManager* aViewManager = getViewManager()) {
436 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
437 for ( uint i = 0; i < aViews.count(); i++ )
439 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
440 aView->SetPreSelectionMode( theMode );
446 \return incremental speed value
448 int SVTK_Viewer::incrementalSpeed() const
450 return myIncrementSpeed;
454 \return modification mode of the incremental speed
456 int SVTK_Viewer::incrementalSpeedMode() const
458 return myIncrementMode;
462 Set the incremental speed value and modification mode
463 \param theValue - new value
464 \param theMode - new mode: 0 - arithmetic, 1 - geometrical progression
466 void SVTK_Viewer::setIncrementalSpeed( const int theValue, const int theMode )
468 myIncrementSpeed = theValue;
469 myIncrementMode = theMode;
471 if (SUIT_ViewManager* aViewManager = getViewManager()) {
472 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
473 for ( uint i = 0; i < aViews.count(); i++ )
475 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
476 aView->SetIncrementalSpeed( theValue, theMode );
482 \return spacemouse button assigned to the specified function
483 \param theIndex - function by number (from 1 to 3)
485 int SVTK_Viewer::spacemouseBtn( const int theIndex ) const
487 if ( theIndex < 1 || theIndex > 3 )
489 return mySpaceBtn[theIndex-1];
493 Set the spacemouse buttons
494 \param theBtn1, theBtn2, theBtn3 - new buttons
496 void SVTK_Viewer::setSpacemouseButtons( const int theBtn1, const int theBtn2, const int theBtn3 )
498 mySpaceBtn[0] = theBtn1;
499 mySpaceBtn[1] = theBtn2;
500 mySpaceBtn[2] = theBtn3;
502 if (SUIT_ViewManager* aViewManager = getViewManager()) {
503 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
504 for ( uint i = 0; i < aViews.count(); i++ )
506 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
507 aView->SetSpacemouseButtons( theBtn1, theBtn2, theBtn3 );
513 Sets new view manager
514 \param theViewManager - new view manager
516 void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
518 SUIT_ViewModel::setViewManager(theViewManager);
520 if ( !theViewManager )
523 connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
524 this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
526 connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
527 this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
529 connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
530 this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
534 Builds popup for vtk viewer
536 void SVTK_Viewer::contextMenuPopup( QMenu* thePopup )
538 thePopup->addAction( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
539 thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) );
541 thePopup->addSeparator();
543 if(TViewWindow* aView = dynamic_cast<TViewWindow*>(myViewManager->getActiveView())){
544 //Support of several toolbars in the popup menu
545 QList<QToolBar*> lst = aView->findChildren<QToolBar*>();
546 QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
547 for( ; it!=last; it++ )
548 thePopup->addAction( (*it)->toggleViewAction() );
549 aView->RefreshDumpImage();
554 SLOT: called on mouse button press, empty implementation
556 void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
560 SLOT: called on mouse move, empty implementation
562 void SVTK_Viewer::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)
566 SLOT: called on mouse button release, empty implementation
568 void SVTK_Viewer::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)
572 Enables/disables selection
573 \param isEnabled - new state
575 void SVTK_Viewer::enableSelection(bool isEnabled)
577 mySelectionEnabled = isEnabled;
578 //!! To be done for view windows
580 if (SUIT_ViewManager* aViewManager = getViewManager()) {
581 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
582 for ( uint i = 0; i < aViews.count(); i++ )
584 if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
585 aView->SetSelectionEnabled( isEnabled );
590 //clear current selection in the viewer
591 bool blocked = blockSignals( true );
592 if ( SUIT_ViewManager* aViewMgr = getViewManager() ) {
593 if( SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewMgr->getActiveView() ) ){
594 if( SVTK_Selector* aSelector = aViewWindow->GetSelector() ) {
595 if(SVTK_View* aView = aViewWindow->getView()){
596 aSelector->ClearIObjects();
597 aView->onSelectionChanged();
602 blockSignals( blocked );
608 Enables/disables selection of many object
609 \param isEnabled - new state
611 void SVTK_Viewer::enableMultiselection(bool isEnable)
613 myMultiSelectionEnabled = isEnable;
614 //!! To be done for view windows
618 SLOT: called on dump view operation is activated, stores scene to raster file
620 void SVTK_Viewer::onDumpView()
622 if(SUIT_ViewWindow* aView = myViewManager->getActiveView())
627 SLOT: called if background color is to be changed changed, passes new color to view port
629 void SVTK_Viewer::onChangeBackground()
631 SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(myViewManager->getActiveView());
635 // get supported gradient types
636 QStringList gradList;
637 QIntList idList, txtList;
638 QString formats = backgroundData( gradList, idList, txtList );
641 Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(), // initial background
642 aView, // parent for dialog box
643 txtList, // allowed texture modes
644 true, // enable solid color mode
645 true, // enable gradient mode
646 false, // disable custom gradient mode
647 !txtList.isEmpty(), // enable texture mode
648 gradList, // gradient names
649 idList, // gradient identifiers
650 formats ); // image formats
652 // set chosen background data to the viewer
653 if ( bgData.isValid() )
654 aView->setBackground( bgData );
659 \param prs - presentation
661 void SVTK_Viewer::Display( const SALOME_VTKPrs* prs )
663 // try do downcast object
664 if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){
667 if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
668 anActorCollection->InitTraversal();
669 while(vtkActor* anActor = anActorCollection->GetNextActor()){
670 if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
671 if(!anAct->ShouldBeDisplayed())
673 // Set visibility flag
674 // Temporarily commented to avoid awful dependecy on SALOMEDS
675 // TODO: better mechanism of storing display/erse status in a study
676 // should be provided...
677 //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
678 //if(!anObj.IsNull() && anObj->hasEntry()){
679 // ToolsGUI::SetVisibility(anObj->getEntry(),true,this);
681 // just display the object
682 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
683 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
684 if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
685 if(SVTK_View* aView = aViewWindow->getView()){
686 aView->Display(anAct,false);
687 if(anAct->IsSetCamera()){
688 vtkRenderer* aRenderer = aView->getRenderer();
689 anAct->SetCamera( aRenderer->GetActiveCamera() );
702 \param prs - presentation
703 \param forced - removes object from view
705 void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced )
707 // try do downcast object
708 if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){
711 if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
712 anActorCollection->InitTraversal();
713 while(vtkActor* anActor = anActorCollection->GetNextActor())
714 if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
715 // Set visibility flag
716 // Temporarily commented to avoid awful dependecy on SALOMEDS
717 // TODO: better mechanism of storing display/erase status in a study
718 // should be provided...
719 //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
720 //if(!anObj.IsNull() && anObj->hasEntry()){
721 // ToolsGUI::SetVisibility(anObj->getEntry(),false,this);
723 // just display the object
724 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
725 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
726 if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
727 if(SVTK_View* aView = aViewWindow->getView())
730 aView->Remove(anAct,false);
732 aView->Erase(anAct,forced);
741 Erase all presentations
742 \param forced - removes all objects from view
744 void SVTK_Viewer::EraseAll( SALOME_Displayer* d, const bool forced )
746 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
747 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
748 if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
749 if(SVTK_View* aView = aViewWindow->getView()){
750 vtkRenderer* aRenderer = aView->getRenderer();
751 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
752 vtkActorCollection* anActorCollection = aCopy.GetActors();
753 anActorCollection->InitTraversal();
754 while(vtkActor* anActor = anActorCollection->GetNextActor()){
755 if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
756 // Set visibility flag
757 // Temporarily commented to avoid awful dependecy on SALOMEDS
758 // TODO: better mechanism of storing display/erse status in a study
759 // should be provided...
760 //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
761 //if(!anObj.IsNull() && anObj->hasEntry())
762 // ToolsGUI::SetVisibility(anObj->getEntry(),false,this);
764 if(SVTK_Renderer* aRnd = aView->GetRenderer())
765 aRnd->RemoveActor(anAct);
768 anAct->SetVisibility( false );
769 // erase dependent actors
770 vtkActorCollection* aCollection = vtkActorCollection::New();
771 anAct->GetChildActors( aCollection );
772 aCollection->InitTraversal();
773 while(vtkActor* aSubAct = aCollection->GetNextActor())
774 aSubAct->SetVisibility( false );
775 aCollection->Delete();
782 SALOME_View::EraseAll( d, forced );
788 Create presentation corresponding to the entry
791 SALOME_Prs* SVTK_Viewer::CreatePrs( const char* entry )
793 SVTK_Prs* prs = new SVTK_Prs( entry );
795 if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(getViewManager()->getActiveView()))
796 if(SVTK_View* aView = aViewWindow->getView()){
797 vtkRenderer* aRenderer = aView->getRenderer();
798 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
799 vtkActorCollection* theActors = aCopy.GetActors();
800 theActors->InitTraversal();
802 while( ( ac = theActors->GetNextActor() ) ) {
803 SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
804 if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {
805 prs->AddObject( ac );
814 \return true if object is displayed in viewer
815 \param obj - object to be checked
817 bool SVTK_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& io )
819 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
820 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
821 if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
822 if(TViewWindow* aViewWnd = dynamic_cast<TViewWindow*>(aViewWindow))
823 if(SVTK_View* aView = aViewWnd->getView())
824 if(!aView->isVisible( io ))
831 \Collect objects visible in viewer
832 \param theList - visible objects collection
834 void SVTK_Viewer::GetVisible( SALOME_ListIO& theList )
836 // here we collect object if it is disaplaed even one view
837 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
838 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
839 if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
840 if(TViewWindow* aViewWnd = dynamic_cast<TViewWindow*>(aViewWindow))
841 if(SVTK_View* aView = aViewWnd->getView())
842 aView->GetVisible( theList );
846 Updates current viewer
848 void SVTK_Viewer::Repaint()
850 // if (theUpdateTrihedron) onAdjustTrihedron();
851 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
852 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
853 if(TViewWindow* aViewWindow = dynamic_cast<TViewWindow*>(aViews.at(i)))
854 if(SVTK_View* aView = aViewWindow->getView())
859 void SVTK_Viewer::onActorAdded(VTKViewer_Actor* theActor)
861 emit actorAdded((SVTK_ViewWindow*)sender(), theActor);
864 void SVTK_Viewer::onActorRemoved(VTKViewer_Actor* theActor)
866 emit actorRemoved((SVTK_ViewWindow*)sender(), theActor);