1 // Copyright (C) 2007-2008 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.
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
22 #include "VVTK_ViewModel.h"
23 #include "VISU_ActorFactory.h"
24 #include "VVTK_ViewWindow.h"
26 #include "VTKViewer_Algorithm.h"
27 #include "SVTK_Functor.h"
28 #include "VISU_ActorBase.h"
29 #include "SVTK_View.h"
32 #include <SUIT_ViewManager.h>
34 #include <vtkActorCollection.h>
35 #include <vtkRenderer.h>
37 //---------------------------------------------------------------
38 VVTK_Viewer::VVTK_Viewer()
42 //---------------------------------------------------------------
43 VVTK_Viewer::~VVTK_Viewer()
47 //---------------------------------------------------------------
48 SUIT_ViewWindow* VVTK_Viewer::createView( SUIT_Desktop* theDesktop )
50 TViewWindow* aViewWindow = new TViewWindow (theDesktop);
51 aViewWindow->Initialize(this);
53 aViewWindow->setBackgroundColor( backgroundColor() );
54 aViewWindow->SetTrihedronSize( trihedronSize() );
55 aViewWindow->SetProjectionMode( projectionMode() );
56 aViewWindow->SetInteractionStyle( interactionStyle() );
57 aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() );
58 aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) );
63 //---------------------------------------------------------------
64 void VVTK_Viewer::Display(const SALOME_VTKPrs* thePrs)
66 // try do downcast object
67 if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>(thePrs)){
70 if(vtkActorCollection* aCollection = aPrs->GetObjects()){
71 aCollection->InitTraversal();
72 while(VISU_ActorBase* anActor = dynamic_cast<VISU_ActorBase*>(aCollection->GetNextActor())){
73 if(!anActor->GetFactory()->GetActiveState())
75 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
76 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
77 if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
78 if(SVTK_View* aView = aViewWindow->getView()){
79 aView->Display(anActor, false);
88 //---------------------------------------------------------------
91 struct TIsOneActorVisibleAction
94 TIsOneActorVisibleAction(bool& theResult):
100 operator()(SALOME_Actor* theActor)
103 myResult = theActor->GetVisibility();
108 //---------------------------------------------------------------
109 bool VVTK_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
111 QVector<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;