1 // Copyright (C) 2007-2013 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 #include "VTKViewer_DataSetMapper.h"
21 #include "VTKViewer_PolyDataMapper.h"
23 #include <vtkDataSetSurfaceFilter.h>
24 #include <vtkObjectFactory.h>
26 vtkStandardNewMacro(VTKViewer_DataSetMapper);
28 //----------------------------------------------------------------------------
29 VTKViewer_DataSetMapper::VTKViewer_DataSetMapper()
31 this->MarkerEnabled = false;
32 this->MarkerType = VTK::MT_NONE;
33 this->MarkerScale = VTK::MS_NONE;
37 //----------------------------------------------------------------------------
38 VTKViewer_DataSetMapper::~VTKViewer_DataSetMapper()
42 //----------------------------------------------------------------------------
43 void VTKViewer_DataSetMapper::Render(vtkRenderer *ren, vtkActor *act)
45 // just to create VTKViewer_PolyDataMapper instead of vtkPolyDataMapper
46 if( this->PolyDataMapper == NULL )
48 vtkDataSetSurfaceFilter *gf = vtkDataSetSurfaceFilter::New();
49 VTKViewer_PolyDataMapper *pm = VTKViewer_PolyDataMapper::New();
50 pm->SetInputConnection(gf->GetOutputPort());
52 pm->SetMarkerEnabled( this->MarkerEnabled );
53 if( this->MarkerType != VTK::MT_USER )
54 pm->SetMarkerStd( this->MarkerType, this->MarkerScale );
56 pm->SetMarkerTexture( this->MarkerId, this->MarkerTexture );
58 this->GeometryExtractor = gf;
59 this->PolyDataMapper = pm;
61 vtkDataSetMapper::Render(ren, act);
64 //-----------------------------------------------------------------------------
65 void VTKViewer_DataSetMapper::SetMarkerEnabled( bool theMarkerEnabled )
67 this->MarkerEnabled = theMarkerEnabled;
68 if( this->PolyDataMapper )
69 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
70 aMapper->SetMarkerEnabled( theMarkerEnabled );
73 //----------------------------------------------------------------------------
74 void VTKViewer_DataSetMapper::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
76 this->MarkerType = theMarkerType;
77 this->MarkerScale = theMarkerScale;
78 if( this->PolyDataMapper )
79 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
80 aMapper->SetMarkerStd( theMarkerType, theMarkerScale );
83 //----------------------------------------------------------------------------
84 void VTKViewer_DataSetMapper::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
86 this->MarkerType = VTK::MT_USER;
87 this->MarkerId = theMarkerId;
88 this->MarkerTexture = theMarkerTexture;
89 if( this->PolyDataMapper )
90 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
91 aMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
94 //-----------------------------------------------------------------------------
95 VTK::MarkerType VTKViewer_DataSetMapper::GetMarkerType()
97 return this->MarkerType;
100 //-----------------------------------------------------------------------------
101 VTK::MarkerScale VTKViewer_DataSetMapper::GetMarkerScale()
103 return this->MarkerScale;
106 //-----------------------------------------------------------------------------
107 int VTKViewer_DataSetMapper::GetMarkerTexture()
109 return this->MarkerId;