X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_DeviceActor.cxx;h=7e2202460bbfc067f1d99d14cee68d987d2f288a;hb=c1e553583fcbe76805b21dca2d0c6db8e1f067ba;hp=4d0626902228f86a9e23f10e27d43179e588b445;hpb=2daa321efae3d0c6ce41199fa5a2482630d505d9;p=modules%2Fsmesh.git diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index 4d0626902..7e2202460 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -1,36 +1,38 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH OBJECT : interactive object for SMESH visualization // File : SMESH_DeviceActor.cxx // Author : // Module : SMESH // - #include "SMESH_DeviceActor.h" +#include "SMESH_ScalarBarActor.h" #include "SMESH_ExtractGeometry.h" #include "SMESH_ControlsDef.hxx" #include "SMESH_ActorUtils.h" #include "SMESH_FaceOrientationFilter.h" #include "VTKViewer_CellLocationsArray.h" +#include "VTKViewer_PolyDataMapper.h" #include #include @@ -47,7 +49,6 @@ #include #include -#include #include #include #include @@ -88,7 +89,7 @@ SMESH_DeviceActor myRepresentation = eSurface; myProperty = vtkProperty::New(); - myMapper = vtkPolyDataMapper::New(); + myMapper = VTKViewer_PolyDataMapper::New(); vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, myPolygonOffsetUnits); @@ -281,7 +282,7 @@ SMESH_DeviceActor void SMESH_DeviceActor ::SetControlMode(SMESH::Controls::FunctorPtr theFunctor, - vtkScalarBarActor* theScalarBarActor, + SMESH_ScalarBarActor* theScalarBarActor, vtkLookupTable* theLookupTable) { bool anIsInitialized = theFunctor; @@ -335,7 +336,7 @@ SMESH_DeviceActor void SMESH_DeviceActor ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor, - vtkScalarBarActor* theScalarBarActor, + SMESH_ScalarBarActor* theScalarBarActor, vtkLookupTable* theLookupTable) { bool anIsInitialized = theFunctor; @@ -483,21 +484,31 @@ SMESH_DeviceActor myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; - if ( dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get()) ) { - Predicate* aFreePredicate = dynamic_cast(theFunctor.get()); + if ( dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get())) + { + Predicate* aPredicate = dynamic_cast(theFunctor.get()); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid(); vtkIdType aNbCells = aGrid->GetNumberOfCells(); for( vtkIdType i = 0; i < aNbCells; i++ ){ vtkIdType anObjId = myVisualObj->GetElemObjId(i); - if(aFreePredicate->IsSatisfy(anObjId)) + if(aPredicate->IsSatisfy(anObjId)) myExtractUnstructuredGrid->RegisterCell(i); } if(!myExtractUnstructuredGrid->IsCellsRegistered()) myExtractUnstructuredGrid->RegisterCell(-1); SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); - }else if(FreeEdges* aFreeEdges = dynamic_cast(theFunctor.get())){ + } + else if(FreeEdges* aFreeEdges = dynamic_cast(theFunctor.get())) + { SMESH::Controls::FreeEdges::TBorders aBorders; aFreeEdges->GetBoreders(aBorders); vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New(); @@ -544,12 +555,16 @@ SMESH_DeviceActor SetUnstructuredGrid(aDataSet); aDataSet->Delete(); - }else if(FreeNodes* aFreeNodes = dynamic_cast(theFunctor.get())){ + } + else if(dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get())) + { + Predicate* aPredicate = dynamic_cast(theFunctor.get()); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node); for( vtkIdType i = 0; i < aNbNodes; i++ ){ vtkIdType anObjId = myVisualObj->GetNodeObjId(i); - if(aFreeNodes->IsSatisfy(anObjId)) + if(aPredicate->IsSatisfy(anObjId)) myExtractUnstructuredGrid->RegisterCell(i); } if(!myExtractUnstructuredGrid->IsCellsRegistered()) @@ -616,7 +631,7 @@ void SMESH_DeviceActor ::SetFacesOriented(bool theIsFacesOriented) { - if ( vtkDataSet* aDataSet = myPassFilter[ 1 ]->GetOutput() ) + if ( vtkDataSet* aDataSet = myTransformFilter->GetOutput() ) { myIsFacesOriented = theIsFacesOriented; if( theIsFacesOriented ) @@ -625,6 +640,48 @@ SMESH_DeviceActor } } +void +SMESH_DeviceActor +::SetFacesOrientationColor(vtkFloatingPointType theColor[3]) +{ + myFaceOrientation->GetProperty()->SetColor( theColor ); +} + +void +SMESH_DeviceActor +::GetFacesOrientationColor(vtkFloatingPointType theColor[3]) +{ + myFaceOrientation->GetProperty()->GetColor( theColor ); +} + +void +SMESH_DeviceActor +::SetFacesOrientationScale(vtkFloatingPointType theScale) +{ + myFaceOrientationFilter->SetOrientationScale( theScale ); +} + +vtkFloatingPointType +SMESH_DeviceActor +::GetFacesOrientationScale() +{ + return myFaceOrientationFilter->GetOrientationScale(); +} + +void +SMESH_DeviceActor +::SetFacesOrientation3DVectors(bool theState) +{ + myFaceOrientationFilter->Set3dVectors( theState ); +} + +bool +SMESH_DeviceActor +::GetFacesOrientation3DVectors() +{ + return myFaceOrientationFilter->Get3dVectors(); +} + void SMESH_DeviceActor ::UpdateFaceOrientation() @@ -661,6 +718,7 @@ SMESH_DeviceActor myGeomFilter->SetWireframeMode(false); GetProperty()->SetRepresentation(theMode); } + SetMarkerEnabled(theMode == ePoint); myRepresentation = theMode; UpdateFaceOrientation(); GetProperty()->Modified(); @@ -859,3 +917,58 @@ void SMESH_DeviceActor::SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle){ vtkFloatingPointType SMESH_DeviceActor::GetQuadraticArcAngle(){ return myGeomFilter->GetQuadraticArcAngle(); } + +/*! + * Set point marker enabled + * \param theMarkerEnabled flag to enable/disable point marker + */ +void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled ) +{ + myMapper->SetMarkerEnabled( theMarkerEnabled ); +} + +/*! + * Set standard point marker + * \param theMarkerType type of the marker + */ +void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale ) +{ + myMapper->SetMarkerStd( theMarkerType, theMarkerScale ); +} + +/*! + * Set custom point marker + * \param theMarkerId id of the marker texture + * \param theMarkerTexture marker texture + */ +void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture ) +{ + myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture ); +} + +/*! + * Get type of the point marker + * \return type of the point marker + */ +VTK::MarkerType SMESH_DeviceActor::GetMarkerType() +{ + return myMapper->GetMarkerType(); +} + +/*! + Get scale of the point marker + \return scale of the point marker +*/ +VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale() +{ + return myMapper->GetMarkerScale(); +} + +/*! + * Get texture identifier of the point marker + * \return texture identifier of the point marker + */ +int SMESH_DeviceActor::GetMarkerTexture() +{ + return myMapper->GetMarkerTexture(); +}