1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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->BallEnabled = false;
33 this->MarkerType = VTK::MT_NONE;
34 this->MarkerScale = VTK::MS_NONE;
38 //----------------------------------------------------------------------------
39 VTKViewer_DataSetMapper::~VTKViewer_DataSetMapper()
43 //----------------------------------------------------------------------------
44 void VTKViewer_DataSetMapper::Render(vtkRenderer *ren, vtkActor *act)
46 // just to create VTKViewer_PolyDataMapper instead of vtkPolyDataMapper
47 if( this->PolyDataMapper == NULL )
49 vtkDataSetSurfaceFilter *gf = vtkDataSetSurfaceFilter::New();
50 VTKViewer_PolyDataMapper *pm = VTKViewer_PolyDataMapper::New();
51 pm->SetInputConnection(gf->GetOutputPort());
53 pm->SetMarkerEnabled( this->MarkerEnabled );
54 if( this->MarkerType != VTK::MT_USER )
55 pm->SetMarkerStd( this->MarkerType, this->MarkerScale );
57 pm->SetMarkerTexture( this->MarkerId, this->MarkerTexture );
58 pm->SetBallEnabled( this->BallEnabled );
60 this->GeometryExtractor = gf;
61 this->PolyDataMapper = pm;
63 vtkDataSetMapper::Render(ren, act);
66 //-----------------------------------------------------------------------------
67 void VTKViewer_DataSetMapper::SetMarkerEnabled( bool theMarkerEnabled )
69 this->MarkerEnabled = theMarkerEnabled;
70 if( this->PolyDataMapper )
71 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
72 aMapper->SetMarkerEnabled( theMarkerEnabled );
76 //-----------------------------------------------------------------------------
77 void VTKViewer_DataSetMapper::SetBallEnabled( bool theBallEnabled )
79 this->BallEnabled = theBallEnabled;
80 if( this->PolyDataMapper )
81 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
82 aMapper->SetBallEnabled( theBallEnabled );
86 //----------------------------------------------------------------------------
87 void VTKViewer_DataSetMapper::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
89 this->MarkerType = theMarkerType;
90 this->MarkerScale = theMarkerScale;
91 if( this->PolyDataMapper )
92 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
93 aMapper->SetMarkerStd( theMarkerType, theMarkerScale );
96 //----------------------------------------------------------------------------
97 void VTKViewer_DataSetMapper::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
99 this->MarkerType = VTK::MT_USER;
100 this->MarkerId = theMarkerId;
101 this->MarkerTexture = theMarkerTexture;
102 if( this->PolyDataMapper )
103 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
104 aMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
107 //-----------------------------------------------------------------------------
108 VTK::MarkerType VTKViewer_DataSetMapper::GetMarkerType()
110 return this->MarkerType;
113 //-----------------------------------------------------------------------------
114 VTK::MarkerScale VTKViewer_DataSetMapper::GetMarkerScale()
116 return this->MarkerScale;
119 //-----------------------------------------------------------------------------
120 int VTKViewer_DataSetMapper::GetMarkerTexture()
122 return this->MarkerId;