1 // Copyright (C) 2007-2016 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;
34 this->MarkerType = VTK::MT_NONE;
35 this->MarkerScale = VTK::MS_NONE;
39 //----------------------------------------------------------------------------
40 VTKViewer_DataSetMapper::~VTKViewer_DataSetMapper()
44 //----------------------------------------------------------------------------
45 void VTKViewer_DataSetMapper::Render(vtkRenderer *ren, vtkActor *act)
47 // just to create VTKViewer_PolyDataMapper instead of vtkPolyDataMapper
48 if( this->PolyDataMapper == NULL )
50 vtkDataSetSurfaceFilter *gf = vtkDataSetSurfaceFilter::New();
51 VTKViewer_PolyDataMapper *pm = VTKViewer_PolyDataMapper::New();
52 pm->SetInputConnection(gf->GetOutputPort());
54 pm->SetMarkerEnabled( this->MarkerEnabled );
55 if( this->MarkerType != VTK::MT_USER )
56 pm->SetMarkerStd( this->MarkerType, this->MarkerScale );
58 pm->SetMarkerTexture( this->MarkerId, this->MarkerTexture );
59 pm->SetBallEnabled( this->BallEnabled );
60 pm->SetBallScale( this->BallScale );
62 this->GeometryExtractor = gf;
63 this->PolyDataMapper = pm;
65 vtkDataSetMapper::Render(ren, act);
68 //-----------------------------------------------------------------------------
69 void VTKViewer_DataSetMapper::SetMarkerEnabled( bool theMarkerEnabled )
71 this->MarkerEnabled = theMarkerEnabled;
72 if( this->PolyDataMapper )
73 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
74 aMapper->SetMarkerEnabled( theMarkerEnabled );
78 //-----------------------------------------------------------------------------
79 void VTKViewer_DataSetMapper::SetBallEnabled( bool theBallEnabled )
81 this->BallEnabled = theBallEnabled;
82 if( this->PolyDataMapper )
83 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
84 aMapper->SetBallEnabled( theBallEnabled );
87 //-----------------------------------------------------------------------------
88 void VTKViewer_DataSetMapper::SetBallScale( double theBallScale )
90 this->BallScale = theBallScale;
91 if( this->PolyDataMapper )
92 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
93 aMapper->SetBallScale( theBallScale );
96 //----------------------------------------------------------------------------
97 void VTKViewer_DataSetMapper::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
99 this->MarkerType = theMarkerType;
100 this->MarkerScale = theMarkerScale;
101 if( this->PolyDataMapper )
102 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
103 aMapper->SetMarkerStd( theMarkerType, theMarkerScale );
106 //----------------------------------------------------------------------------
107 void VTKViewer_DataSetMapper::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
109 this->MarkerType = VTK::MT_USER;
110 this->MarkerId = theMarkerId;
111 this->MarkerTexture = theMarkerTexture;
112 if( this->PolyDataMapper )
113 if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
114 aMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
117 //-----------------------------------------------------------------------------
118 VTK::MarkerType VTKViewer_DataSetMapper::GetMarkerType()
120 return this->MarkerType;
123 //-----------------------------------------------------------------------------
124 VTK::MarkerScale VTKViewer_DataSetMapper::GetMarkerScale()
126 return this->MarkerScale;
129 //-----------------------------------------------------------------------------
130 int VTKViewer_DataSetMapper::GetMarkerTexture()
132 return this->MarkerId;