From 2ffe4e63a878965af69ac04a01c57243e45e6e86 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 15 Feb 2018 16:04:32 +0300 Subject: [PATCH] GPUSPHGUI: show a custom control by setting a functor --- src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx | 6 +++--- src/OBJECT/SMESH_Actor.cxx | 23 ++++++++++++++++++++++- src/OBJECT/SMESH_Actor.h | 4 +++- src/OBJECT/SMESH_ActorDef.h | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx index 344542ebc..d97a232a1 100644 --- a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx +++ b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx @@ -162,7 +162,7 @@ namespace MED if (myMinor < 0) myMinor = MED_MINOR_NUM; myFile->Open(theMode,theErr); } - + ~TFileWrapper() { myFile->Close(); @@ -172,8 +172,8 @@ namespace MED //--------------------------------------------------------------- TVWrapper::TVWrapper(const std::string& theFileName, TInt theMinor): - myMinor(theMinor), - myFile(new TFile(theFileName, theMinor)) + myFile(new TFile(theFileName, theMinor)), + myMinor(theMinor) { TErr aRet; myFile->Open( eLECTURE_ECRITURE, &aRet ); diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 6bd4e2c62..dac3d4a0d 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -804,12 +804,20 @@ bool SMESH_ActorDef::GetFacesOrientation3DVectors() } +void SMESH_ActorDef::SetControl(SMESH::Controls::FunctorPtr theFunctor) +{ + myFunctor = theFunctor; + if ( !theFunctor ) + SetControlMode( eNone, true ); + else + SetControlMode( eCustomControl, true ); +} + void SMESH_ActorDef::SetControlMode(eControl theMode) { SetControlMode(theMode,true); } - void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode ) { vtkLookupTable* lookupTable = static_cast(myScalarBarActor->GetLookupTable()); @@ -1006,6 +1014,19 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode ) myControlActor = myNodeActor; break; } + case eCustomControl: + { + if ( !myFunctor ) + return; + switch ( myFunctor->GetType() ) { + case SMDSAbs_Node : myControlActor = myNodeActor; break; + case SMDSAbs_Edge : myControlActor = my1DActor; break; + case SMDSAbs_Face : myControlActor = my2DActor; break; + case SMDSAbs_Volume : myControlActor = my3DActor; break; + default : return; + } + break; + } default: return; } diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index e8818e4d5..7ad9d2f88 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -146,8 +146,10 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor eMinimumAngle, eWarping, eSkew, eAspectRatio3D, eMultiConnection2D, eVolume3D, eMaxElementLength2D, eMaxElementLength3D, eBareBorderFace, eBareBorderVolume, eOverConstrainedFace, eOverConstrainedVolume, eCoincidentNodes, - eCoincidentElems1D, eCoincidentElems2D, eCoincidentElems3D, eNodeConnectivityNb }; + eCoincidentElems1D, eCoincidentElems2D, eCoincidentElems3D, eNodeConnectivityNb, + eCustomControl }; virtual void SetControlMode(eControl theMode) = 0; + virtual void SetControl(SMESH::Controls::FunctorPtr) = 0; virtual eControl GetControlMode() = 0; virtual SMESH::Controls::FunctorPtr GetFunctor() = 0; virtual int GetNumberControlEntities() = 0; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index 3b9d9c68f..833e8253f 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -209,6 +209,7 @@ class SMESH_ActorDef : public SMESH_Actor virtual bool GetFacesOrientation3DVectors(); virtual void SetControlMode(eControl theMode); + virtual void SetControl(SMESH::Controls::FunctorPtr theFunctor); virtual int GetNumberControlEntities(); virtual eControl GetControlMode(){ return myControlMode;} virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; } -- 2.39.2