1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "VVTK_ViewModel.h"
22 #include "VVTK_ViewWindow.h"
24 #include "VTKViewer_Algorithm.h"
25 #include "SVTK_Functor.h"
26 #include "VISU_Actor.h"
27 #include "SVTK_View.h"
30 #include <vtkActorCollection.h>
31 #include <vtkRenderer.h>
33 //---------------------------------------------------------------
39 //---------------------------------------------------------------
45 //---------------------------------------------------------------
48 ::createView( SUIT_Desktop* theDesktop )
50 TViewWindow* aViewWindow = new TViewWindow (theDesktop);
51 aViewWindow->Initialize(this);
53 aViewWindow->setBackgroundColor( backgroundColor() );
54 aViewWindow->SetTrihedronSize( trihedronSize() );
59 //---------------------------------------------------------------
62 ::Display(const SALOME_VTKPrs* thePrs)
64 // try do downcast object
65 if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>(thePrs)){
68 if(vtkActorCollection* aCollection = aPrs->GetObjects()){
69 aCollection->InitTraversal();
70 while(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(aCollection->GetNextActor())){
71 if(!anActor->GetFactory()->GetActiveState())
73 QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
74 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
75 if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
76 if(SVTK_View* aView = aViewWindow->getView()){
77 aView->Display(anActor, false);
86 //---------------------------------------------------------------
89 struct TIsOneActorVisibleAction
92 TIsOneActorVisibleAction(bool& theResult):
98 operator()(SALOME_Actor* theActor)
101 myResult = theActor->GetVisibility();
106 //---------------------------------------------------------------
109 ::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
111 QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
112 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
113 if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
115 VVTK::TIsOneActorVisibleAction anAction(aResult);
116 SVTK::ForEachIf<SALOME_Actor>(aViewWindow->getRenderer()->GetActors(),
117 SVTK::TIsSameIObject<SALOME_Actor>(theIO),
119 return anAction.myResult;