1 // Copyright (C) 2007-2011 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"
29 #include "VTKViewer_Transform.h"
31 #include <vtkObjectFactory.h>
32 #include <vtkProperty.h>
33 #include <vtkPassThroughFilter.h>
34 #include <vtkShrinkFilter.h>
35 #include <vtkDataSet.h>
36 #include <vtkShrinkPolyData.h>
37 #include <vtkUnstructuredGrid.h>
39 #include "utilities.h"
41 #include <boost/bind.hpp>
46 myShrinkFilter(VTKViewer_ShrinkFilter::New()),
50 myShrinkFilter->Delete();
52 myStoreMapping = true;
54 myShrinkFilter->SetStoreMapping(true);
60 myUpdateActorsConnection.disconnect();
61 myRemoveFromRendererConnection.disconnect();
64 //----------------------------------------------------------------------------
69 return myActorFactory;
74 ::SetFactory(VISU::TActorFactory* theActorFactory)
78 if(myActorFactory == theActorFactory)
82 myDestroySignal.connect(boost::bind(&TActorFactory::RemoveActor,
86 myActorFactory = theActorFactory;
93 if(myUpdateFromFactoryTime.GetMTime() < myActorFactory->GetMTime()){
94 myUpdateFromFactoryTime.Modified();
95 myActorFactory->UpdateActor(this);
100 //----------------------------------------------------------------------------
103 ::SetTransform(VTKViewer_Transform* theTransform)
105 Superclass::SetTransform( theTransform );
107 // Since the output of GetHighlightedDataSet() method (which is passed
108 // through transform filter) is used for calculation of bounds of the
109 // SALOME_Actor::myOutlineActor, we should remove transformation
110 // from the outline actor applied in SALOME_Actor::SetTransform().
111 // See issues IPAL22429, IPAL21936.
112 VTKViewer_Transform* aTransform = VTKViewer_Transform::New();
113 myOutlineActor->SetTransform( aTransform );
114 aTransform->Delete();
117 //--------------------------------------------------------------------------
121 ::SetLineWidth(vtkFloatingPointType theLineWidth)
123 GetProperty()->SetLineWidth(theLineWidth);
130 return GetProperty()->GetLineWidth();
133 //--------------------------------------------------------------------------
136 ::SetRepresentation(int theMode)
138 Superclass::SetRepresentation(theMode);
139 if(myRepresentation == VTK_POINTS)
143 //----------------------------------------------------------------------------
144 void VISU_ActorBase::SetShrink()
148 if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
149 myShrinkFilter->SetInput(aDataSet);
150 myPassFilter[1]->SetInput(myShrinkFilter->GetOutput());
155 void VISU_ActorBase::UnShrink()
159 if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
160 myPassFilter[1]->SetInput(aDataSet);
161 myPassFilter[1]->Modified();
167 bool VISU_ActorBase::IsShrunk()
172 void VISU_ActorBase::SetShrinkable(bool theIsShrinkable)
174 myIsShrinkable = theIsShrinkable;
177 bool VISU_ActorBase::IsShrunkable()
179 return myIsShrinkable;
184 ::SetShrinkFactor(vtkFloatingPointType theValue)
186 myShrinkFilter->SetShrinkFactor(theValue);
194 return myShrinkFilter->GetShrinkFactor();
198 //--------------------------------------------------------------------------------------
200 void VISU_ActorBase::RemoveFromRender(vtkRenderer* theRenderer)
202 Superclass::RemoveFromRender(theRenderer);
205 void VISU_ActorBase::RemoveFromRender()
207 RemoveFromRender(GetRenderer());
210 void VISU_ActorBase::ConnectToFactory(boost::signal0<void>& theUpdateActorSignal, boost::signal0<void>& theRemoveFromRendererSignal)
212 myUpdateActorsConnection = theUpdateActorSignal.connect(boost::bind(&VISU_ActorBase::UpdateFromFactory,this));
213 myRemoveFromRendererConnection = theRemoveFromRendererSignal.connect(boost::bind(&VISU_ActorBase::RemoveFromRender,this));
216 //--------------------------------------------------------------------------------------
217 vtkDataSet* VISU_ActorBase::GetHighlightedDataSet() {
218 return myPassFilter.back()->GetOutput();