1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // VISU OBJECT : interactive object for VISU entities implementation
26 #include "VISU_ActorBase.h"
27 #include "VISU_ActorFactory.h"
28 #include "VTKViewer_ShrinkFilter.h"
30 #include <vtkObjectFactory.h>
31 #include <vtkProperty.h>
32 #include <vtkPassThroughFilter.h>
33 #include <vtkShrinkFilter.h>
34 #include <vtkDataSet.h>
35 #include <vtkShrinkPolyData.h>
36 #include <vtkUnstructuredGrid.h>
38 #include "utilities.h"
40 #include <boost/bind.hpp>
45 myShrinkFilter(VTKViewer_ShrinkFilter::New()),
49 myShrinkFilter->Delete();
51 myStoreMapping = true;
53 myShrinkFilter->SetStoreMapping(true);
59 myUpdateActorsConnection.disconnect();
60 myRemoveFromRendererConnection.disconnect();
63 //----------------------------------------------------------------------------
68 return myActorFactory;
73 ::SetFactory(VISU::TActorFactory* theActorFactory)
77 if(myActorFactory == theActorFactory)
81 myDestroySignal.connect(boost::bind(&TActorFactory::RemoveActor,
85 myActorFactory = theActorFactory;
92 if(myUpdateFromFactoryTime.GetMTime() < myActorFactory->GetMTime()){
93 myUpdateFromFactoryTime.Modified();
94 myActorFactory->UpdateActor(this);
99 //--------------------------------------------------------------------------
103 ::SetLineWidth(vtkFloatingPointType theLineWidth)
105 GetProperty()->SetLineWidth(theLineWidth);
112 return GetProperty()->GetLineWidth();
115 //--------------------------------------------------------------------------
118 ::SetRepresentation(int theMode)
120 Superclass::SetRepresentation(theMode);
121 if(myRepresentation == VTK_POINTS)
125 //----------------------------------------------------------------------------
126 void VISU_ActorBase::SetShrink()
130 if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
131 myShrinkFilter->SetInput(aDataSet);
132 myPassFilter[1]->SetInput(myShrinkFilter->GetOutput());
137 void VISU_ActorBase::UnShrink()
141 if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
142 myPassFilter[1]->SetInput(aDataSet);
143 myPassFilter[1]->Modified();
149 bool VISU_ActorBase::IsShrunk()
154 void VISU_ActorBase::SetShrinkable(bool theIsShrinkable)
156 myIsShrinkable = theIsShrinkable;
159 bool VISU_ActorBase::IsShrunkable()
161 return myIsShrinkable;
164 //--------------------------------------------------------------------------------------
166 void VISU_ActorBase::RemoveFromRender(vtkRenderer* theRenderer)
168 Superclass::RemoveFromRender(theRenderer);
171 void VISU_ActorBase::RemoveFromRender()
173 RemoveFromRender(GetRenderer());
176 void VISU_ActorBase::ConnectToFactory(boost::signal0<void>& theUpdateActorSignal, boost::signal0<void>& theRemoveFromRendererSignal)
178 myUpdateActorsConnection = theUpdateActorSignal.connect(boost::bind(&VISU_ActorBase::UpdateFromFactory,this));
179 myRemoveFromRendererConnection = theRemoveFromRendererSignal.connect(boost::bind(&VISU_ActorBase::RemoveFromRender,this));