X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_Actor.cxx;h=ada5f91b8ae2f1294fc7c0ce9475546573656549;hb=1c1bbf6798782cb24bcab45d519817cff125ae5c;hp=34c956b5ce12c4c9b589955d30cf82d49cf1e2d3;hpb=5c5e1f2368ca2b3388f657ae028b2a6b5ce8ae36;p=modules%2Fsmesh.git diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 34c956b5c..ada5f91b8 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -26,23 +26,23 @@ // Module : SMESH #include "SMESH_ActorDef.h" + +#include "SMDS_UnstructuredGrid.hxx" #include "SMESH_ActorUtils.h" +#include "SMESH_CellLabelActor.h" +#include "SMESH_ControlsDef.hxx" #include "SMESH_DeviceActor.h" #include "SMESH_NodeLabelActor.h" -#include "SMESH_CellLabelActor.h" #include "SMESH_ObjectDef.h" -#include "SMESH_ControlsDef.hxx" -#include "SMDS_UnstructuredGrid.hxx" -#include "SMESH_ScalarBarActor.h" -#include "VTKViewer_ExtractUnstructuredGrid.h" -#include "VTKViewer_FramedTextActor.h" -#include "SALOME_InteractiveObject.hxx" #include "SMESH_SVTKActor.h" - -#include "SUIT_Session.h" -#include "SUIT_ResourceMgr.h" +#include "SMESH_ScalarBarActor.h" #include +#include +#include +#include +#include +#include #ifndef DISABLE_PLOT2DVIEWER #include @@ -117,6 +117,9 @@ SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, SMESH_ActorDef::SMESH_ActorDef() { if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. ); my2DActor = SMESH_CellLabelActor::New(); - my2DActor->SetStoreGemetryMapping(true); + my2DActor->SetStoreClippingMapping(true); my2DActor->SetUserMatrix(aMatrix); my2DActor->PickableOff(); my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); @@ -255,7 +258,7 @@ SMESH_ActorDef::SMESH_ActorDef() aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); my3DActor = SMESH_CellLabelActor::New(); - my3DActor->SetStoreGemetryMapping(true); + my3DActor->SetStoreClippingMapping(true); my3DActor->SetUserMatrix(aMatrix); my3DActor->PickableOff(); my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); @@ -321,7 +324,7 @@ SMESH_ActorDef::SMESH_ActorDef() myEdgeProp->SetLineWidth(aLineWidth); my1DActor = SMESH_CellLabelActor::New(); - my1DActor->SetStoreGemetryMapping(true); + my1DActor->SetStoreClippingMapping(true); my1DActor->SetUserMatrix(aMatrix); my1DActor->PickableOff(); my1DActor->SetHighlited(true); @@ -369,7 +372,7 @@ SMESH_ActorDef::SMESH_ActorDef() my0DActor = SMESH_CellLabelActor::New(); my0DActor->SetUserMatrix(aMatrix); - my0DActor->SetStoreGemetryMapping(true); + my0DActor->SetStoreClippingMapping(true); my0DActor->PickableOff(); my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); my0DActor->SetVisibility(false); @@ -388,7 +391,7 @@ SMESH_ActorDef::SMESH_ActorDef() myBallActor = SMESH_CellLabelActor::New(); myBallActor->SetUserMatrix(aMatrix); - myBallActor->SetStoreGemetryMapping(true); + myBallActor->SetStoreClippingMapping(true); myBallActor->PickableOff(); myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); myBallActor->SetVisibility(false); @@ -461,6 +464,8 @@ SMESH_ActorDef::SMESH_ActorDef() //---------------------------------------------- myBaseActor->SetUserMatrix(aMatrix); + myBaseActor->SetStoreIDMapping(true); + myBaseActor->SetStoreClippingMapping(true); myBaseActor->SetStoreGemetryMapping(true); myBaseActor->GetProperty()->SetOpacity(0.0); myPickableActor = myBaseActor; @@ -1134,6 +1139,11 @@ int SMESH_ActorDef::GetNumberControlEntities() void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer) { + if ( !mySelector || !mySelector->IsSelectionEnabled() ) + { + myBaseActor->SetUnstructuredGrid( NULL ); + myHighlitableActor->SetUnstructuredGrid( NULL ); + } theRenderer->AddActor(myBaseActor); theRenderer->AddActor(myNodeExtActor); theRenderer->AddActor(my1DExtActor); @@ -1274,7 +1284,9 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, double* SMESH_ActorDef::GetBounds() { - return myNodeActor->GetBounds(); + if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 ) + return myNodeActor->GetBounds(); + return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds(); } @@ -1603,97 +1615,108 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode) myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState); myEntityMode = theMode; - VTKViewer_ExtractUnstructuredGrid* aFilter = NULL; - aFilter = myBaseActor->GetExtractUnstructuredGrid(); - aFilter->ClearRegisteredCellsWithType(); - aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); + VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid(); + aFilter->ClearRegisteredCellsWithType(); VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid(); aHightFilter->ClearRegisteredCellsWithType(); - aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); - if (myEntityMode & e0DElements) { - if (MYDEBUG) MESSAGE("0D ELEMENTS"); - aFilter->RegisterCellsWithType(VTK_VERTEX); - aHightFilter->RegisterCellsWithType(VTK_VERTEX); + bool isPassAll = + (( myEntityMode & e0DElements || myVisualObj->GetNbEntities(SMDSAbs_0DElement) == 0 ) && + ( myEntityMode & eBallElem || myVisualObj->GetNbEntities(SMDSAbs_Ball) == 0 ) && + ( myEntityMode & eEdges || myVisualObj->GetNbEntities(SMDSAbs_Edge) == 0 ) && + ( myEntityMode & eFaces || myVisualObj->GetNbEntities(SMDSAbs_Face) == 0 ) && + ( myEntityMode & eVolumes || myVisualObj->GetNbEntities(SMDSAbs_Volume) == 0 )); + if ( isPassAll && myEntityMode ) + { + aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); + aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); } + else + { + aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); + aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); - if (myEntityMode & eBallElem) { - aFilter->RegisterCellsWithType(VTK_POLY_VERTEX); - } + if (myEntityMode & e0DElements) { + aFilter->RegisterCellsWithType(VTK_VERTEX); + aHightFilter->RegisterCellsWithType(VTK_VERTEX); + } - if (myEntityMode & eEdges) { - if (MYDEBUG) MESSAGE("EDGES"); - aFilter->RegisterCellsWithType(VTK_LINE); - aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); + if (myEntityMode & eBallElem) { + aFilter->RegisterCellsWithType(VTK_POLY_VERTEX); + } - aHightFilter->RegisterCellsWithType(VTK_LINE); - aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); - } + if (myEntityMode & eEdges) { + aFilter->RegisterCellsWithType(VTK_LINE); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); - if (myEntityMode & eFaces) { - if (MYDEBUG) MESSAGE("FACES"); - aFilter->RegisterCellsWithType(VTK_TRIANGLE); - aFilter->RegisterCellsWithType(VTK_QUAD); - aFilter->RegisterCellsWithType(VTK_POLYGON); - aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); - aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); - aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); - aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); - aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); - - aHightFilter->RegisterCellsWithType(VTK_TRIANGLE); - aHightFilter->RegisterCellsWithType(VTK_QUAD); - aHightFilter->RegisterCellsWithType(VTK_POLYGON); - aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); - aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); - aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); - aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); - aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); - } + aHightFilter->RegisterCellsWithType(VTK_LINE); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); + } - if (myEntityMode & eVolumes) { - if (MYDEBUG) MESSAGE("VOLUMES"); - aFilter->RegisterCellsWithType(VTK_TETRA); - aFilter->RegisterCellsWithType(VTK_VOXEL); - aFilter->RegisterCellsWithType(VTK_HEXAHEDRON); - aFilter->RegisterCellsWithType(VTK_WEDGE); - aFilter->RegisterCellsWithType(VTK_PYRAMID); - aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM); - aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA); - aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON); - aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON); - aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID); - aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); - aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); - aFilter->RegisterCellsWithType(VTK_POLYHEDRON); - - aHightFilter->RegisterCellsWithType(VTK_TETRA); - aHightFilter->RegisterCellsWithType(VTK_VOXEL); - aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON); - aHightFilter->RegisterCellsWithType(VTK_WEDGE); - aHightFilter->RegisterCellsWithType(VTK_PYRAMID); - aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM); - aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA); - aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON); - aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON); - aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); - aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID); - aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); - aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON); + if (myEntityMode & eFaces) { + aFilter->RegisterCellsWithType(VTK_TRIANGLE); + aFilter->RegisterCellsWithType(VTK_QUAD); + aFilter->RegisterCellsWithType(VTK_POLYGON); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); + aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); + aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); + + aHightFilter->RegisterCellsWithType(VTK_TRIANGLE); + aHightFilter->RegisterCellsWithType(VTK_QUAD); + aHightFilter->RegisterCellsWithType(VTK_POLYGON); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); + aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); + aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); + } + + if (myEntityMode & eVolumes) { + aFilter->RegisterCellsWithType(VTK_TETRA); + aFilter->RegisterCellsWithType(VTK_VOXEL); + aFilter->RegisterCellsWithType(VTK_HEXAHEDRON); + aFilter->RegisterCellsWithType(VTK_WEDGE); + aFilter->RegisterCellsWithType(VTK_PYRAMID); + aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON); + aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID); + aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); + aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); + aFilter->RegisterCellsWithType(VTK_POLYHEDRON); + + aHightFilter->RegisterCellsWithType(VTK_TETRA); + aHightFilter->RegisterCellsWithType(VTK_VOXEL); + aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON); + aHightFilter->RegisterCellsWithType(VTK_WEDGE); + aHightFilter->RegisterCellsWithType(VTK_PYRAMID); + aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON); + aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); + aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID); + aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); + aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON); + } } - aFilter->Update(); + if ( GetVisibility() ) + aFilter->Update(); if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells()); SetVisibility(GetVisibility(),false); } void SMESH_ActorDef::SetRepresentation (int theMode) { - int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge); - int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face); + int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge); + int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face); int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume); - int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement); - int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball); + int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement); + int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball); if (theMode < 0) { myRepresentation = eSurface; @@ -1835,6 +1858,11 @@ void SMESH_ActorDef::UpdateHighlight() case SMESH_DeviceActor::eSurface: case SMESH_DeviceActor::eWireframe: { + // if ( !mySelector || !mySelector->IsSelectionEnabled() ) + // myHighlitableActor->SetUnstructuredGrid( NULL ); + // else if ( !myHighlitableActor->myExtractUnstructuredGrid->GetInput() ) + // myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + if(myIsHighlighted) { myHighlitableActor->SetProperty(myHighlightProp); }else if(myIsPreselected){ @@ -1868,6 +1896,24 @@ void SMESH_ActorDef::UpdateHighlight() } } +void SMESH_ActorDef::EnableSelection( bool enable ) +{ + // selection in the Viewer enabled/disabled + if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() ) + { + myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + myBaseActor->myExtractUnstructuredGrid->Update(); + myHighlitableActor->myExtractUnstructuredGrid->Update(); + } + if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() ) + { + myBaseActor->SetUnstructuredGrid( NULL ); + myHighlitableActor->SetUnstructuredGrid( NULL ); + myBaseActor->myExtractUnstructuredGrid->Update(); + myHighlitableActor->myExtractUnstructuredGrid->Update(); + } +} void SMESH_ActorDef::highlight(bool theHighlight) { @@ -1926,6 +1972,8 @@ void SMESH_ActorDef::Update() { if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update"); + myVisualObj->Update(); + if(GetControlMode() != eNone) { unsigned long aTime = myTimeStamp->GetMTime(); unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime(); @@ -2297,6 +2345,11 @@ void SMESH_ActorDef::SetOpenGLClippingPlane() myHighlitableActor->SetPlaneCollection( myPlaneCollection ); myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + if ( !mySelector || !mySelector->IsSelectionEnabled() ) + { + myBaseActor->SetUnstructuredGrid( NULL ); + myHighlitableActor->SetUnstructuredGrid( NULL ); + } my1DActor->SetPlaneCollection( myPlaneCollection ); my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());