Back to index

salome-gui  6.5.0
VTKViewer_DataSetMapper.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "VTKViewer_DataSetMapper.h"
00021 #include "VTKViewer_PolyDataMapper.h"
00022 
00023 #include <vtkDataSetSurfaceFilter.h>
00024 #include <vtkObjectFactory.h>
00025 
00026 vtkCxxRevisionMacro(VTKViewer_DataSetMapper, "Revision$");
00027 vtkStandardNewMacro(VTKViewer_DataSetMapper);
00028 
00029 //----------------------------------------------------------------------------
00030 VTKViewer_DataSetMapper::VTKViewer_DataSetMapper()
00031 {
00032   this->MarkerEnabled = false;
00033   this->MarkerType    = VTK::MT_NONE;
00034   this->MarkerScale   = VTK::MS_NONE;
00035   this->MarkerId      = 0;
00036 }
00037 
00038 //----------------------------------------------------------------------------
00039 VTKViewer_DataSetMapper::~VTKViewer_DataSetMapper()
00040 {
00041 }
00042 
00043 //----------------------------------------------------------------------------
00044 void VTKViewer_DataSetMapper::Render(vtkRenderer *ren, vtkActor *act)
00045 {
00046   // just to create VTKViewer_PolyDataMapper instead of vtkPolyDataMapper
00047   if( this->PolyDataMapper == NULL )
00048   {
00049     vtkDataSetSurfaceFilter *gf = vtkDataSetSurfaceFilter::New();
00050     VTKViewer_PolyDataMapper *pm = VTKViewer_PolyDataMapper::New();
00051     pm->SetInput(gf->GetOutput());
00052 
00053     pm->SetMarkerEnabled( this->MarkerEnabled );
00054     if( this->MarkerType != VTK::MT_USER )
00055       pm->SetMarkerStd( this->MarkerType, this->MarkerScale );
00056     else
00057       pm->SetMarkerTexture( this->MarkerId, this->MarkerTexture );
00058 
00059     this->GeometryExtractor = gf;
00060     this->PolyDataMapper = pm;
00061   }
00062   vtkDataSetMapper::Render(ren, act);
00063 }
00064 
00065 //-----------------------------------------------------------------------------
00066 void VTKViewer_DataSetMapper::SetMarkerEnabled( bool theMarkerEnabled )
00067 {
00068   this->MarkerEnabled = theMarkerEnabled;
00069   if( this->PolyDataMapper )
00070     if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
00071       aMapper->SetMarkerEnabled( theMarkerEnabled );
00072 }
00073 
00074 //----------------------------------------------------------------------------
00075 void VTKViewer_DataSetMapper::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
00076 {
00077   this->MarkerType = theMarkerType;
00078   this->MarkerScale = theMarkerScale;
00079   if( this->PolyDataMapper )
00080     if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
00081       aMapper->SetMarkerStd( theMarkerType, theMarkerScale );
00082 }
00083 
00084 //----------------------------------------------------------------------------
00085 void VTKViewer_DataSetMapper::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
00086 {
00087   this->MarkerType = VTK::MT_USER;
00088   this->MarkerId = theMarkerId;
00089   this->MarkerTexture = theMarkerTexture;
00090   if( this->PolyDataMapper )
00091     if( VTKViewer_PolyDataMapper* aMapper = dynamic_cast<VTKViewer_PolyDataMapper*>( this->PolyDataMapper ) )
00092       aMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
00093 }
00094 
00095 //-----------------------------------------------------------------------------
00096 VTK::MarkerType VTKViewer_DataSetMapper::GetMarkerType()
00097 {
00098   return this->MarkerType;
00099 }
00100 
00101 //-----------------------------------------------------------------------------
00102 VTK::MarkerScale VTKViewer_DataSetMapper::GetMarkerScale()
00103 {
00104   return this->MarkerScale;
00105 }
00106 
00107 //-----------------------------------------------------------------------------
00108 int VTKViewer_DataSetMapper::GetMarkerTexture()
00109 {
00110   return this->MarkerId;
00111 }