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 // VISU OBJECT : interactive object for VISU entities implementation
28 #include "VISU_ActorBase.h"
29 #include "VISU_ActorFactory.h"
30 #include "VTKViewer_ShrinkFilter.h"
32 #include <vtkObjectFactory.h>
33 #include <vtkProperty.h>
34 #include <vtkPassThroughFilter.h>
35 #include <vtkShrinkFilter.h>
36 #include <vtkDataSet.h>
37 #include <vtkShrinkPolyData.h>
38 #include <vtkUnstructuredGrid.h>
40 #include "utilities.h"
42 #include <boost/bind.hpp>
47 myShrinkFilter(VTKViewer_ShrinkFilter::New()),
51 myShrinkFilter->Delete();
53 myStoreMapping = true;
55 myShrinkFilter->SetStoreMapping(true);
61 myUpdateActorsConnection.disconnect();
62 myRemoveFromRendererConnection.disconnect();
65 //----------------------------------------------------------------------------
70 return myActorFactory;
75 ::SetFactory(VISU::TActorFactory* theActorFactory)
79 if(myActorFactory == theActorFactory)
83 myDestroySignal.connect(boost::bind(&TActorFactory::RemoveActor,
87 myActorFactory = theActorFactory;
94 if(myUpdateFromFactoryTime.GetMTime() < myActorFactory->GetMTime()){
95 myUpdateFromFactoryTime.Modified();
96 myActorFactory->UpdateActor(this);
101 //--------------------------------------------------------------------------
105 ::SetLineWidth(vtkFloatingPointType theLineWidth)
107 GetProperty()->SetLineWidth(theLineWidth);
114 return GetProperty()->GetLineWidth();
117 //--------------------------------------------------------------------------
120 ::SetRepresentation(int theMode)
122 Superclass::SetRepresentation(theMode);
123 if(myRepresentation == VTK_POINTS)
127 //----------------------------------------------------------------------------
128 void VISU_ActorBase::SetShrink()
132 if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
133 myShrinkFilter->SetInput(aDataSet);
134 myPassFilter[1]->SetInput(myShrinkFilter->GetOutput());
139 void VISU_ActorBase::UnShrink()
143 if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
144 myPassFilter[1]->SetInput(aDataSet);
145 myPassFilter[1]->Modified();
151 bool VISU_ActorBase::IsShrunk()
156 void VISU_ActorBase::SetShrinkable(bool theIsShrinkable)
158 myIsShrinkable = theIsShrinkable;
161 bool VISU_ActorBase::IsShrunkable()
163 return myIsShrinkable;
166 //--------------------------------------------------------------------------------------
168 void VISU_ActorBase::RemoveFromRender(vtkRenderer* theRenderer)
170 Superclass::RemoveFromRender(theRenderer);
173 void VISU_ActorBase::RemoveFromRender()
175 RemoveFromRender(GetRenderer());
178 void VISU_ActorBase::ConnectToFactory(boost::signal0<void>& theUpdateActorSignal, boost::signal0<void>& theRemoveFromRendererSignal)
180 myUpdateActorsConnection = theUpdateActorSignal.connect(boost::bind(&VISU_ActorBase::UpdateFromFactory,this));
181 myRemoveFromRendererConnection = theRemoveFromRendererSignal.connect(boost::bind(&VISU_ActorBase::RemoveFromRender,this));