From 884e7f4ab4832ac868c04a254ec0aabdbdcf41ad Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 11 Apr 2005 04:28:09 +0000 Subject: [PATCH] Implement Clipping Planes functionality --- src/PIPELINE/VISUPipeLine.cxx | 2 + src/PIPELINE/VISU_CutLinesPL.cxx | 4 +- src/PIPELINE/VISU_CutPlanesPL.cxx | 6 +- src/PIPELINE/VISU_DeformedShapePL.cxx | 4 +- src/PIPELINE/VISU_IsoSurfacesPL.cxx | 2 +- src/PIPELINE/VISU_MeshPL.cxx | 2 +- src/PIPELINE/VISU_PipeLine.cxx | 204 ++++++- src/PIPELINE/VISU_PipeLine.hxx | 63 ++- src/PIPELINE/VISU_ScalarMapPL.cxx | 2 +- src/PIPELINE/VISU_StreamLinesPL.cxx | 14 +- src/PIPELINE/VISU_VectorsPL.cxx | 2 +- src/VISUGUI/Makefile.in | 2 + src/VISUGUI/VISU_msg_en.po | 24 + src/VISUGUI/VisuGUI.cxx | 114 ++-- src/VISUGUI/VisuGUI.h | 1 + src/VISUGUI/VisuGUI_ClippingDlg.cxx | 746 ++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_ClippingDlg.h | 101 ++++ src/VISU_I/VISU_CutLines_i.hh | 2 +- src/VISU_I/VISU_CutPlanes_i.hh | 2 +- src/VISU_I/VISU_DeformedShape_i.hh | 2 +- src/VISU_I/VISU_IsoSurfaces_i.hh | 2 +- src/VISU_I/VISU_Mesh_i.hh | 6 +- src/VISU_I/VISU_Prs3d_i.cc | 26 + src/VISU_I/VISU_Prs3d_i.hh | 21 +- src/VISU_I/VISU_ScalarMap_i.hh | 10 +- src/VISU_I/VISU_StreamLines_i.hh | 4 +- src/VISU_I/VISU_Table_i.hh | 24 +- src/VISU_I/VISU_Vectors_i.hh | 2 +- 28 files changed, 1281 insertions(+), 113 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_ClippingDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_ClippingDlg.h diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 6595ae83..9c26e3ff 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -45,6 +45,8 @@ typedef VISU_ScalarMapPL TPresent; #include #include +#include + #include "utilities.h" using namespace std; diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index 21b5004f..22a7797b 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -70,7 +70,7 @@ float VISU_CutLinesPL::GetPosition(){ float aPosition = myPosition; if(myCondition){ float aDir[3], aBounds[6], aBoundPrj[3]; - myInput->GetBounds(aBounds); + GetInput2()->GetBounds(aBounds); GetDir(aDir,myAng[0],myBasePlane[0]); GetBoundProject(aBoundPrj,aBounds,aDir); aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[0]; @@ -93,7 +93,7 @@ void VISU_CutLinesPL::Update(){ vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New(); //Build base plane float aDir[2][3], aBaseBounds[6]; - myInput->GetBounds(aBaseBounds); + GetInput2()->GetBounds(aBaseBounds); GetDir(aDir[0],myAng[0],myBasePlane[0]); vtkUnstructuredGrid* anUnstructuredGrid = myFieldTransform->GetUnstructuredGridOutput(); diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index be8925f4..0904935b 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -78,7 +78,7 @@ void VISU_CutPlanesPL::Update(){ float aDir[3]; GetDir(aDir,myAng[0],myBasePlane[0]); float aBounds[6]; - myInput->GetBounds(aBounds); + GetInput2()->GetBounds(aBounds); vtkDataSet* aDataSet = myFieldTransform->GetUnstructuredGridOutput(); CutWithPlanes(myAppendPolyData,aDataSet,myNbParts,aDir,aBounds, myPartPosition,myPartCondition,myDisplacement[0]); @@ -209,7 +209,7 @@ float VISU_CutPlanesPL::GetPartPosition(int thePartNumber, int theNum){ float aPosition = myPartPosition[thePartNumber]; if(myPartCondition[thePartNumber]){ float aDir[3], aBounds[6], aBoundPrj[3]; - myInput->GetBounds(aBounds); + GetInput2()->GetBounds(aBounds); GetDir(aDir,myAng[theNum],myBasePlane[theNum]); GetBoundProject(aBoundPrj,aBounds,aDir); if (myNbParts > 1){ @@ -296,7 +296,7 @@ void VISU_CutPlanesPL::CutWithPlanes(vtkAppendPolyData* theAppendPolyData, vtkDa float aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement; for (int i = 0; i < theNbPlanes; i++){ aPosition = aStartPosition + i*aDBoundPrj; - float aDelta = (aBoundPrj[0] - aPosition) / aBoundPrj[2]; + //float aDelta = (aBoundPrj[0] - aPosition) / aBoundPrj[2]; if(thePlaneCondition[i]){ aPosition = aStartPosition + i*aDBoundPrj; }else diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 9b200331..bccbb94f 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -93,11 +93,11 @@ void VISU_DeformedShapePL::Init(){ VISU_ScalarMapPL::Init(); float aScalarRange[2]; GetSourceRange(aScalarRange); - SetScale(GetScaleFactor(myInput)/aScalarRange[1]); + SetScale(GetScaleFactor(GetInput2())/aScalarRange[1]); } VISU_ScalarMapPL::THook* VISU_DeformedShapePL::DoHook(){ - VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,myInput,myFieldTransform); + VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,GetInput2(),myFieldTransform); return myWarpVector->GetOutput(); } diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index b6bbb643..1692adb0 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -101,7 +101,7 @@ VISU_ScalarMapPL::THook* VISU_IsoSurfacesPL::DoHook(){ void VISU_IsoSurfacesPL::Update(){ - VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,myInput,myFieldTransform); + VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform); SetMapScale(); VISU_ScalarMapPL::Update(); diff --git a/src/PIPELINE/VISU_MeshPL.cxx b/src/PIPELINE/VISU_MeshPL.cxx index 4e3e92d2..26da8b65 100644 --- a/src/PIPELINE/VISU_MeshPL.cxx +++ b/src/PIPELINE/VISU_MeshPL.cxx @@ -39,7 +39,7 @@ vtkStandardNewMacro(VISU_MeshPL); VISU_MeshPL::VISU_MeshPL(){} void VISU_MeshPL::Build() { - myMapper->SetInput(myInput); + myMapper->SetInput(GetInput2()); } void VISU_MeshPL::Init(){ diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index a99eba60..2524787c 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -29,12 +29,20 @@ #include "VISU_PipeLine.hxx" #include "VISU_PipeLineUtils.hxx" +#include "SALOME_PassThroughFilter.h" + #include #include #include #include +#include +#include +#include +#include +#include + static int MYVTKDEBUG = 0; #ifdef _DEBUG_ @@ -45,41 +53,82 @@ static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #endif -VISU_PipeLine::VISU_PipeLine(){ +VISU_PipeLine::VISU_PipeLine() +{ + // Clipping planes + myPassFilter0 = SALOME_PassThroughFilter::New(); + + myExtractGeometry = vtkExtractGeometry::New(); + myExtractGeometry->SetReleaseDataFlag(true); + myIsImplicitFunctionUsed = false; + + myImplicitBoolean = vtkImplicitBoolean::New(); + myImplicitBoolean->SetOperationTypeToIntersection(); + myExtractGeometry->SetImplicitFunction(myImplicitBoolean); + + // Mapper myMapper = TMapper::New(); + myInput = NULL; SetDebug(MYVTKDEBUG); } -VISU_PipeLine::~VISU_PipeLine(){ - if(MYDEBUG) MESSAGE("~VISU_PipeLine - myInput = "<GetReferenceCount()); +VISU_PipeLine::~VISU_PipeLine() +{ + if (MYDEBUG) MESSAGE("~VISU_PipeLine - myInput = "<GetReferenceCount()); SetInput(NULL); myMapper->RemoveAllInputs(); myMapper->Delete(); + + //myPassFilter0->UnRegisterAllOutputs(); + myPassFilter0->Delete(); + //myExtractGeometry->UnRegisterAllOutputs(); + myExtractGeometry->Delete(); + myImplicitBoolean->Delete(); } -void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){ +void VISU_PipeLine::ShallowCopy (VISU_PipeLine *thePipeLine) { + myIsImplicitFunctionUsed = thePipeLine->myIsImplicitFunctionUsed; + myCippingPlaneCont = thePipeLine->myCippingPlaneCont; + + myImplicitBoolean->GetFunction()->RemoveAllItems(); + for (int ipln = 0; ipln < myCippingPlaneCont.size(); ipln++) { + myImplicitBoolean->GetFunction()->AddItem(myCippingPlaneCont[ipln].Get()); + } + myImplicitBoolean->GetFunction()->Modified(); // VTK bug + SetInput(thePipeLine->GetInput()); + SetImplicitFunctionUsed(myIsImplicitFunctionUsed); myMapper->ShallowCopy(thePipeLine->GetMapper()); Build(); } -void VISU_PipeLine::SetInput(TInput* theInput){ - if(myInput != theInput){ +TInput* VISU_PipeLine::GetInput2() { + return myPassFilter0->GetUnstructuredGridOutput(); +} + +void VISU_PipeLine::SetInput (TInput* theInput) +{ + if (myInput != theInput) { if (myInput != NULL) myInput->UnRegister(this); myInput = theInput; - if(myInput != NULL){ + if (myInput != NULL) { myInput->Register(this); + + // Clipping planes + SetImplicitFunctionUsed(myIsImplicitFunctionUsed); + myInput->Update(); - }else + } else { myMapper->SetInput(NULL); + } Modified(); } } VISU_PipeLine::TMapper* VISU_PipeLine::GetMapper() { - if(myInput){ - if(!myMapper->GetInput()){ + if (myInput) { + if (!myMapper->GetInput()) { myInput->Update(); Build(); } @@ -121,3 +170,138 @@ float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize){ return 0; return theSize; } + +//------------------------ Clipping planes ----------------------------------- + +bool VISU_PipeLine::IsImplicitFunctionUsed() const +{ + return myIsImplicitFunctionUsed; +} + +void VISU_PipeLine::SetImplicitFunctionUsed (bool theIsImplicitFunctionUsed) +{ + if (myInput != NULL) { + if (theIsImplicitFunctionUsed) { + myExtractGeometry->SetInput(myInput); + myPassFilter0->SetInput(myExtractGeometry->GetOutput()); + } else { + myPassFilter0->SetInput(myInput); + } + } + + Modified(); + myIsImplicitFunctionUsed = theIsImplicitFunctionUsed; +// SetStoreClippingMapping(myStoreClippingMapping); +} + +vtkIdType VISU_PipeLine::AddClippingPlane (vtkPlane* thePlane) +{ + if (thePlane) { + myImplicitBoolean->GetFunction()->AddItem(thePlane); + myCippingPlaneCont.push_back(thePlane); + if (!IsImplicitFunctionUsed()) + SetImplicitFunctionUsed(true); + } + return myCippingPlaneCont.size(); +} + +void VISU_PipeLine::RemoveAllClippingPlanes() +{ + myImplicitBoolean->GetFunction()->RemoveAllItems(); + myImplicitBoolean->GetFunction()->Modified(); // VTK bug + myCippingPlaneCont.clear(); + SetImplicitFunctionUsed(false); +} + +vtkIdType VISU_PipeLine::GetNumberOfClippingPlanes() +{ + return myCippingPlaneCont.size(); +} + +vtkPlane* VISU_PipeLine::GetClippingPlane (vtkIdType theID) +{ + if (theID >= myCippingPlaneCont.size()) + return NULL; + return myCippingPlaneCont[theID].Get(); +} + +static void ComputeBoundsParam (vtkDataSet* theDataSet, + float theDirection[3], float theMinPnt[3], + float& theMaxBoundPrj, float& theMinBoundPrj) +{ + float aBounds[6]; + theDataSet->GetBounds(aBounds); + + //Enlarge bounds in order to avoid conflicts of precision + for(int i = 0; i < 6; i += 2){ + static double EPS = 1.0E-3; + float aDelta = (aBounds[i+1] - aBounds[i])*EPS; + aBounds[i] -= aDelta; + aBounds[i+1] += aDelta; + } + + float aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]}, + {aBounds[1],aBounds[2],aBounds[4]}, + {aBounds[0],aBounds[3],aBounds[4]}, + {aBounds[1],aBounds[3],aBounds[4]}, + {aBounds[0],aBounds[2],aBounds[5]}, + {aBounds[1],aBounds[2],aBounds[5]}, + {aBounds[0],aBounds[3],aBounds[5]}, + {aBounds[1],aBounds[3],aBounds[5]}}; + + int aMaxId = 0, aMinId = aMaxId; + theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]); + theMinBoundPrj = theMaxBoundPrj; + for(int i = 1; i < 8; i++){ + float aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]); + if(theMaxBoundPrj < aTmp){ + theMaxBoundPrj = aTmp; + aMaxId = i; + } + if(theMinBoundPrj > aTmp){ + theMinBoundPrj = aTmp; + aMinId = i; + } + } + float *aMinPnt = aBoundPoints[aMaxId]; + theMinPnt[0] = aMinPnt[0]; + theMinPnt[1] = aMinPnt[1]; + theMinPnt[2] = aMinPnt[2]; +} + +static void DistanceToPosition (vtkDataSet* theDataSet, + float theDirection[3], float theDist, float thePos[3]) +{ + float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; + ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj); + float aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist; + thePos[0] = aMinPnt[0]-theDirection[0]*aLength; + thePos[1] = aMinPnt[1]-theDirection[1]*aLength; + thePos[2] = aMinPnt[2]-theDirection[2]*aLength; +} + +static void PositionToDistance (vtkDataSet* theDataSet, + float theDirection[3], float thePos[3], float& theDist) +{ + float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; + ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj); + float aPrj = vtkMath::Dot(theDirection,thePos); + theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj); +} + +void VISU_PipeLine::SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane) +{ + thePlane->SetNormal(theDir); + float anOrigin[3]; + ::DistanceToPosition(myInput,theDir,theDist,anOrigin); + thePlane->SetOrigin(anOrigin); +} + +void VISU_PipeLine::GetPlaneParam (float theDir[3], float& theDist, vtkPlane* thePlane) +{ + thePlane->GetNormal(theDir); + + float anOrigin[3]; + thePlane->GetOrigin(anOrigin); + ::PositionToDistance(myInput,theDir,anOrigin,theDist); +} diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index 1a55be8e..ebbe5d54 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -27,13 +27,38 @@ #ifndef VISU_PipeLine_HeaderFile #define VISU_PipeLine_HeaderFile -#include -#include #include -#include +#include + +#include + +template +class TVTKSmartPtr: public vtkSmartPointer +{ +public: + TVTKSmartPtr() {} + TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer(r) { + if(r && theIsOwner) + r->Delete(); + } + TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){ + vtkSmartPointer::operator=(r); + if(r && theIsOwner) + r->Delete(); + return *this; + } + TVTKSmartPtr& operator=(T* r){ vtkSmartPointer::operator=(r); return *this;} + T* Get() const { return GetPointer();} +}; class vtkDataSetMapper; class vtkUnstructuredGrid; +class vtkExtractGeometry; +class vtkImplicitBoolean; +class vtkPlane; +class SALOME_PassThroughFilter; + +typedef vtkUnstructuredGrid TInput; class VISU_PipeLine : public vtkObject{ protected: @@ -45,9 +70,8 @@ public: virtual void ShallowCopy(VISU_PipeLine *thePipeLine); public: - typedef vtkUnstructuredGrid TInput; virtual void SetInput(TInput* theInput); - virtual TInput* GetInput() { return myInput;} + virtual TInput* GetInput() { return myInput; } typedef vtkDataSetMapper TMapper; virtual TMapper* GetMapper(); @@ -58,11 +82,38 @@ public: static int CheckAvailableMemory(const float& theSize); static float GetAvailableMemory(float theSize = 16*1024*1024.0, float theMinSize = 1024*1024.0); + + // Clipping planes + virtual void SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane); + virtual void GetPlaneParam (float theDir[3], float& theDist, vtkPlane* thePlane); + + virtual void RemoveAllClippingPlanes(); + virtual vtkIdType GetNumberOfClippingPlanes(); + virtual vtkPlane* GetClippingPlane (vtkIdType theID); + virtual vtkIdType AddClippingPlane (vtkPlane* thePlane); + + void SetImplicitFunctionUsed (bool theIsImplicitFunctionUsed); + bool IsImplicitFunctionUsed() const; + protected: virtual void Build() = 0; + virtual TInput* GetInput2(); - TInput *myInput; TMapper *myMapper; + + // Clipping planes + bool myIsImplicitFunctionUsed; + + vtkImplicitBoolean* myImplicitBoolean; + typedef TVTKSmartPtr TPlanePtr; + typedef std::vector TCippingPlaneCont; + TCippingPlaneCont myCippingPlaneCont; + + SALOME_PassThroughFilter* myPassFilter0; + vtkExtractGeometry* myExtractGeometry; + +private: + TInput *myInput; }; #endif diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index d7b7b4a6..5838ee0f 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -140,7 +140,7 @@ void VISU_ScalarMapPL::Init(){ void VISU_ScalarMapPL::Build() { - myExtractor->SetInput(myInput); + myExtractor->SetInput(GetInput2()); myFieldTransform->SetInput(myExtractor->GetOutput()); myMapper->SetInput(DoHook()); } diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index f219d4a3..3c1af7ee 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -44,7 +44,7 @@ static int MYDEBUG = 0; static float EPS = 1.0e-7; static float aMinNbOfSteps = 1.0E+2; -static float aMaxNbOfSteps = 1.0E+3; +//static float aMaxNbOfSteps = 1.0E+3; static float aCoeffOfIntStep = 1.0E+1; @@ -99,7 +99,7 @@ float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float float aConnectivitySize = aCellsSize*sizeof(vtkIdType); float aTypesSize = aNbCells*sizeof(char); float aLocationsSize = aNbCells*sizeof(int); - float aNbCellsPerPoint = aCellsSize / aNbCells - 1; + //float aNbCellsPerPoint = aCellsSize / aNbCells - 1; float aMeshSize = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize; float anAssignedDataSize = aCellsSize*4.0*sizeof(float); @@ -165,7 +165,7 @@ int VISU_StreamLinesPL::SetParams(float theIntStep, if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){ mySource = theSource; myPercents = thePercents; - if(myInput->GetCellData()->GetNumberOfArrays()){ + if(GetInput2()->GetCellData()->GetNumberOfArrays()){ myCenters->SetInput(aDataSet); myCenters->VertexCellsOn(); aDataSet = myCenters->GetOutput(); @@ -238,7 +238,7 @@ int VISU_StreamLinesPL::GetDirection(){ float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet, float thePercents) { if(!theDataSet) return -1.0; - float aVolume = 1.0, tmp; + float aVolume = 1.0; int degree = 0; theDataSet->Update(); float* aBounds = theDataSet->GetBounds(); @@ -386,9 +386,9 @@ void VISU_StreamLinesPL::Init(){ } VISU_ScalarMapPL::THook* VISU_StreamLinesPL::DoHook(){ - myInput->Update(); - VISU::CellDataToPoint(myStream,myCellDataToPointData,myInput,myFieldTransform); - float *aBounds = myInput->GetBounds(); + GetInput2()->Update(); + VISU::CellDataToPoint(myStream,myCellDataToPointData,GetInput2(),myFieldTransform); + float *aBounds = GetInput2()->GetBounds(); myGeomFilter->SetExtent(aBounds); myGeomFilter->ExtentClippingOn(); myGeomFilter->SetInput(myStream->GetOutput()); diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index ddb703b5..7945bf30 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -107,7 +107,7 @@ void VISU_VectorsPL::Init(){ VISU_ScalarMapPL::THook* VISU_VectorsPL::DoHook(){ - VISU::ToCellCenters(myTransformFilter,myCenters,myInput,myFieldTransform); + VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform); myGlyph->SetInput(myTransformFilter->GetOutput()); myGlyph->SetVectorModeToUseVector(); myGlyph->SetScaleModeToScaleByVector(); diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index b7a57964..e5af114c 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -57,6 +57,7 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_TimeAnimation.cxx \ VisuGUI_CutLinesDlg.cxx \ VisuGUI_FileDlg.cxx \ + VisuGUI_ClippingDlg.cxx \ VisuGUI_EditContainerDlg.cxx LIB_MOC = \ @@ -73,6 +74,7 @@ LIB_MOC = \ VisuGUI_TimeAnimation.h \ VisuGUI_CutLinesDlg.h \ VisuGUI_FileDlg.h \ + VisuGUI_ClippingDlg.h \ VisuGUI_EditContainerDlg.h \ VisuGUI_Selection.h diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 86d82f65..52ba7bdf 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -35,6 +35,9 @@ msgstr "" msgid "VISU_BUT_OK" msgstr "OK" +msgid "VISU_BUT_APPLY" +msgstr "Apply" + msgid "VISU_WARNING" msgstr "Post-Pro Warning" @@ -197,6 +200,26 @@ msgstr "" msgid "VisuGUI_VectorsDlg::Vectors Representation" msgstr "" +# -------------- Clipping -------------- + +#Title +msgid "VISU_CLIPPING_TITLE" +msgstr "Change Clipping" + +msgid "VISU_BUT_NEW" +msgstr "New" + +msgid "VISU_BUT_DELETE" +msgstr "Delete" + +msgid "VISU_PARAMETERS" +msgstr "Parameters" + +msgid "VISU_DISTANCE" +msgstr "Distance" + +# -------------------------------------- + msgid "VisuGUI_BAD_MEDFILE" msgstr "Med file is not correct" @@ -223,6 +246,7 @@ msgstr "Logarithmic scaling: use imposed range values > 0" msgid "WRN_LOGARITHMIC_FIELD_RANGE" msgstr "Logarithmic scaling: field range contains negative values, use imposed range instead"======= + msgid "TXT_ORIENTATION" msgstr "Orientation" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 6e4b1d19..d45552c7 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -60,6 +60,7 @@ #include "VisuGUI_StreamLinesDlg.h" #include "VisuGUI_EditContainerDlg.h" #include "VisuGUI_TimeAnimation.h" +#include "VisuGUI_ClippingDlg.h" #include "VisuGUI_Selection.h" #include "VisuGUI_NonIsometricDlg.h" @@ -424,9 +425,9 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) SALOMEDS::AttributeIOR_var anIOR; switch (theCommandID){ - /* ======================================================================================== */ - /* Import Table from file */ - /* ======================================================================================== */ + /* ========================================================================== */ + /* Import Table from file */ + /* ========================================================================== */ case 199: { if(checkLock(aStudy)) break; @@ -434,24 +435,24 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) break; } - /* ======================================================================================== */ - /* Import Mesh from MED, DAT file */ - /* ======================================================================================== */ + /* ========================================================================== */ + /* Import Mesh from MED, DAT file */ + /* ========================================================================== */ - case 111: - { - visuGUI->CopyAndImportFile(); - break; - } +// case 111: +// { +// visuGUI->CopyAndImportFile(); +// break; +// } case 112: { visuGUI->ImportFile(); break; } - /* ======================================================================================== */ - /* Export results and mesh into a file format */ - /* ======================================================================================== */ + /* ========================================================================== */ + /* Export results and mesh into a file format */ + /* ========================================================================== */ case 122: { @@ -459,15 +460,15 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) break; } - /* ========================================================================== */ - /* Visualization of Results : */ - /* 4011 : Scalar Map */ - /* 4012 : Deformed Shape */ - /* 4013 : Vectors */ - /* 4014 : Iso-Surfaces */ - /* 4015 : Cut Planes */ - /* 4016 : Stream Lines */ - /* ========================================================================== */ + /* ========================================================================== */ + /* Visualization of Results : */ + /* 4011 : Scalar Map */ + /* 4012 : Deformed Shape */ + /* 4013 : Vectors */ + /* 4014 : Iso-Surfaces */ + /* 4015 : Cut Planes */ + /* 4016 : Stream Lines */ + /* ========================================================================== */ case 4011 : visuGUI->CreateScalarMap(); @@ -495,47 +496,47 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) visuGUI->SelectionInfo(); break; - /* ========================================================================================================================= */ - /* Visualization - Wireframe */ - /* ========================================================================================================================= */ + /* ========================================================================== */ + /* Visualization - Wireframe */ + /* ========================================================================== */ case 4211 : ChangeViewer(1); break; - /* ========================================================================================================================= */ - /* Visualization - Surface */ - /* ========================================================================================================================= */ + /* ========================================================================== */ + /* Visualization - Surface */ + /* ========================================================================== */ case 4212 : ChangeViewer(2); break; - /* ========================================================================================================================= */ - /* Visualization - Points */ - /* ========================================================================================================================= */ + /* ========================================================================== */ + /* Visualization - Points */ + /* ========================================================================== */ case 4213 : ChangeViewer(0); break; - /* ========================================================================================================================= */ - /* Visualization - Erase */ - /* ========================================================================================================================= */ + /* ========================================================================== */ + /* Visualization - Erase */ + /* ========================================================================== */ case 422 : ChangeViewer(-1); break; - /* ========================================================================================================================= */ - /* Visualization - Global */ - /* ========================================================================================================================= */ + /* ========================================================================== */ + /* Visualization - Global */ + /* ========================================================================== */ //case 423 : - /* ========================================================================================================================= */ - /* Visualization - Partial */ - /* ========================================================================================================================= */ + /* ========================================================================== */ + /* Visualization - Partial */ + /* ========================================================================== */ //case 424 : @@ -552,12 +553,12 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* POP-UP OBJECTS BROWSER */ /* ============================ */ - case 900 : // Rename object - visuGUI->Rename(); - break; +// case 900 : // Rename object +// visuGUI->Rename(); +// break; // ---------------- For Popup in Viewer - case 802 : // Erase +/* case 802 : // Erase case 902 : // Erase visuGUI->ErasePrs(); break; @@ -610,7 +611,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 908 : // Sweep IsoSurfaces or Cutplanes visuGUI->Sweep(); break; - +*/ /* ======================================================================================== */ /* Preferences for Scalar Bar */ /* ======================================================================================== */ @@ -621,7 +622,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } /* ======================================================================================== */ -/* Preferences for Sweeping */ +/* Preferences for Sweeping */ /* ======================================================================================== */ case 52: { @@ -689,13 +690,14 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) tr("ERR_NO_MEMORY") + " " + tr(e.what()), tr("VISU_BUT_OK") ); return false; - } - catch (std::exception& e){ + } + catch (std::exception& e) { INFOS(e.what()); QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), tr(e.what()), tr("VISU_BUT_OK") ); - }catch (const SALOME::SALOME_Exception& S_ex) { + } + catch (const SALOME::SALOME_Exception& S_ex) { INFOS("const SALOME::SALOME_Exception& S_ex"); QtCatchCorbaException(S_ex); return false; @@ -2341,6 +2343,15 @@ void VisuGUI::DeleteViewParams() { } +//===================================================================================== +// function : ClippingPlanes() +// purpose : +//===================================================================================== +void VisuGUI::ClippingPlanes() { + //SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + new VisuGUI_ClippingDlg (QAD_Application::getDesktop(),"",false); +} + //===================================================================================== // function : Sweep() // purpose : @@ -3024,6 +3035,9 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep())); } + + thePopup->insertItem("Clipping planes", visuGUI, SLOT(ClippingPlanes())); + if (isVTKViewer) { if ( theParent == "Viewer" && ( aType == VISU::TMESH || diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index bcefa28a..813f13e7 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -258,6 +258,7 @@ public slots: void Rename(); void RenameTable(); void RenameContainer(); + void ClippingPlanes(); void Sweep(); void TimeAnimation(); diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx new file mode 100644 index 00000000..2a20b5fe --- /dev/null +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -0,0 +1,746 @@ + +#include "VisuGUI_ClippingDlg.h" + +#include "VisuGUI.h" + +#include "VISU_Prs3d_i.hh" + +#include "QAD_Config.h" +#include "QAD_RightFrame.h" +#include "QAD_WaitCursor.h" + +#include "SALOME_Actor.h" + +#include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindow.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include + +// VTK Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +namespace VISU { + float GetFloat (const QString& theValue, float theDefault) + { + if (theValue.isEmpty()) return theDefault; + QString aValue = QAD_CONFIG->getSetting(theValue); + if (aValue.isEmpty()) return theDefault; + return aValue.toFloat(); + } + + void RenderViewFrame (QAD_Study* theStudy) + { + VTKViewer_ViewFrame* vf = dynamic_cast + (theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()); + if (vf) { + if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) { + vf->getRenderer()->ResetCameraClippingRange(); + vf->Repaint(); + } + } + } + + void RangeStepAndValidator (QAD_SpinBoxDbl* theSpinBox, double min, double max, + double step, unsigned short decimals) + { + theSpinBox->setRange(min, max); + theSpinBox->setLineStep(step); + ((QDoubleValidator*)theSpinBox->validator())->setRange(min, max, decimals); + } +}; + +class OrientedPlane: public vtkPlane +{ + QAD_Study* myStudy; + QAD_StudyFrame* myStudyFrame; + VTKViewer_ViewFrame* myViewFrame; + + vtkDataSetMapper* myMapper; + +public: + static OrientedPlane *New(){ + return new OrientedPlane(); + } + static OrientedPlane *New(QAD_Study* theStudy){ + return new OrientedPlane(theStudy); + } + vtkTypeMacro(OrientedPlane, vtkPlane); + + + VISU::Orientation myOrientation; + float myDistance; + double myAngle[2]; + + vtkPlaneSource* myPlaneSource; + SALOME_Actor *myActor; + + void SetOrientation(VISU::Orientation theOrientation) {myOrientation = theOrientation;} + VISU::Orientation GetOrientation() {return myOrientation;} + + void SetDistance(float theDistance) {myDistance = theDistance;} + float GetDistance() {return myDistance;} + + void ShallowCopy(OrientedPlane* theOrientedPlane){ + SetNormal(theOrientedPlane->GetNormal()); + SetOrigin(theOrientedPlane->GetOrigin()); + + myOrientation = theOrientedPlane->GetOrientation(); + myDistance = theOrientedPlane->GetDistance(); + + myAngle[0] = theOrientedPlane->myAngle[0]; + myAngle[1] = theOrientedPlane->myAngle[1]; + + myPlaneSource->SetNormal(theOrientedPlane->myPlaneSource->GetNormal()); + myPlaneSource->SetOrigin(theOrientedPlane->myPlaneSource->GetOrigin()); + myPlaneSource->SetPoint1(theOrientedPlane->myPlaneSource->GetPoint1()); + myPlaneSource->SetPoint2(theOrientedPlane->myPlaneSource->GetPoint2()); + } + +protected: + OrientedPlane(QAD_Study* theStudy): + myOrientation(VISU::XY), + myDistance(0.5), + myStudy(theStudy), + myStudyFrame(theStudy->getActiveStudyFrame()), + myViewFrame(VisuGUI::GetVtkViewFrame()) + { + Init(); + myViewFrame->AddActor( myActor ); + } + + OrientedPlane(): + myOrientation(VISU::XY), + myDistance(0.5), + myStudy(NULL), + myStudyFrame(NULL), + myViewFrame(NULL) + { + Init(); + } + + void Init(){ + myPlaneSource = vtkPlaneSource::New(); + + myAngle[0] = myAngle[1] = 0.0; + + // Create and display actor + myMapper = vtkDataSetMapper::New(); + myMapper->SetInput( myPlaneSource->GetOutput() ); + + myActor = SALOME_Actor::New(); + myActor->VisibilityOff(); + myActor->PickableOff(); + myActor->SetInfinitive(true); + myActor->SetMapper( myMapper ); + + vtkProperty* aProp = vtkProperty::New(); + float anRGB[3]; + anRGB[0] = VISU::GetFloat("SMESH:SettingsFillColorRed", 0)/255.; + anRGB[1] = VISU::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; + anRGB[2] = VISU::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + aProp->SetOpacity(0.75); + myActor->SetProperty( aProp ); + aProp->Delete(); + + vtkProperty* aBackProp = vtkProperty::New(); + anRGB[0] = VISU::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; + anRGB[1] = VISU::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; + anRGB[2] = VISU::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + aBackProp->SetOpacity(0.75); + myActor->SetBackfaceProperty( aBackProp ); + aBackProp->Delete(); + } + + ~OrientedPlane() + { + //if (myStudy && VISU::FindVtkViewFrame(myStudy,myStudyFrame)) { + if (myStudy && VisuGUI::GetVtkViewFrame()) { + myViewFrame->RemoveActor(myActor); + } + myActor->Delete(); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myPlaneSource->UnRegisterAllOutputs(); + myPlaneSource->Delete(); + }; + +private: + // Not implemented. + OrientedPlane(const OrientedPlane&); + void operator=(const OrientedPlane&); +}; + +struct TSetVisiblity { + TSetVisiblity(int theIsVisible): myIsVisible(theIsVisible){} + void operator()(VISU::TVTKPlane& theOrientedPlane){ + theOrientedPlane->myActor->SetVisibility(myIsVisible); + } + int myIsVisible; +}; + +//================================================================================= +// class : VisuGUI_ClippingDlg() +// purpose : +// +//================================================================================= +VisuGUI_ClippingDlg::VisuGUI_ClippingDlg (QWidget* parent, + const char* name, + bool modal, + WFlags fl) + : QDialog( parent, name, modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + if ( !name ) + setName( "VisuGUI_ClippingDlg" ); + setCaption( tr( "VISU_CLIPPING_TITLE" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* VisuGUI_ClippingDlgLayout = new QGridLayout( this ); + VisuGUI_ClippingDlgLayout->setSpacing( 6 ); + VisuGUI_ClippingDlgLayout->setMargin( 11 ); + + // Controls for selecting, creating, deleting planes + QGroupBox* GroupPlanes = new QGroupBox( this, "GroupPlanes" ); + GroupPlanes->setTitle( tr("Clipping planes") ); + GroupPlanes->setColumnLayout(0, Qt::Vertical); + GroupPlanes->layout()->setSpacing( 0 ); + GroupPlanes->layout()->setMargin( 0 ); + QGridLayout* GroupPlanesLayout = new QGridLayout( GroupPlanes->layout() ); + GroupPlanesLayout->setAlignment( Qt::AlignTop ); + GroupPlanesLayout->setSpacing( 6 ); + GroupPlanesLayout->setMargin( 11 ); + + ComboBoxPlanes = new QComboBox(GroupPlanes, "ComboBoxPlanes"); + GroupPlanesLayout->addWidget( ComboBoxPlanes, 0, 0 ); + + QSpacerItem* spacerGP = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupPlanesLayout->addItem( spacerGP, 0, 1 ); + + buttonNew = new QPushButton( GroupPlanes, "buttonNew" ); + buttonNew->setText( tr( "VISU_BUT_NEW" ) ); + GroupPlanesLayout->addWidget( buttonNew, 0, 2 ); + + buttonDelete = new QPushButton( GroupPlanes, "buttonDelete" ); + buttonDelete->setText( tr( "VISU_BUT_DELETE" ) ); + GroupPlanesLayout->addWidget( buttonDelete, 0, 3 ); + + // Controls for defining plane parameters + QGroupBox* GroupParameters = new QGroupBox( this, "GroupParameters" ); + GroupParameters->setTitle( tr("VISU_PARAMETERS") ); + GroupParameters->setColumnLayout(0, Qt::Vertical); + GroupParameters->layout()->setSpacing( 0 ); + GroupParameters->layout()->setMargin( 0 ); + QGridLayout* GroupParametersLayout = new QGridLayout( GroupParameters->layout() ); + GroupParametersLayout->setAlignment( Qt::AlignTop ); + GroupParametersLayout->setSpacing( 6 ); + GroupParametersLayout->setMargin( 11 ); + + TextLabelOrientation = new QLabel( GroupParameters, "TextLabelOrientation" ); + TextLabelOrientation->setText( tr("TXT_ORIENTATION") ); + GroupParametersLayout->addWidget( TextLabelOrientation, 0, 0 ); + + ComboBoxOrientation = new QComboBox(GroupParameters, "ComboBoxOrientation"); + GroupParametersLayout->addWidget( ComboBoxOrientation, 0, 1 ); + + TextLabelDistance = new QLabel( GroupParameters, "TextLabelDistance" ); + TextLabelDistance->setText( tr("VISU_DISTANCE") ); + GroupParametersLayout->addWidget( TextLabelDistance, 1, 0 ); + + SpinBoxDistance = new QAD_SpinBoxDbl( GroupParameters, "SpinBoxDistance" ); + GroupParametersLayout->addWidget( SpinBoxDistance, 1, 1 ); + + TextLabelRot1 = new QLabel( GroupParameters, "TextLabelRot1" ); + TextLabelRot1->setText( tr("Rotation around X (Y to Z):") ); + GroupParametersLayout->addWidget( TextLabelRot1, 2, 0 ); + + SpinBoxRot1 = new QAD_SpinBoxDbl( GroupParameters, "SpinBoxRot1" ); + GroupParametersLayout->addWidget( SpinBoxRot1, 2, 1 ); + + TextLabelRot2 = new QLabel( GroupParameters, "TextLabelRot2" ); + TextLabelRot2->setText( tr("Rotation around Y (X to Z):") ); + GroupParametersLayout->addWidget( TextLabelRot2, 3, 0 ); + + SpinBoxRot2 = new QAD_SpinBoxDbl( GroupParameters, "SpinBoxRot2" ); + GroupParametersLayout->addWidget( SpinBoxRot2, 3, 1 ); + + PreviewCheckBox = new QCheckBox(tr("Show preview"), GroupParameters); + PreviewCheckBox->setChecked(true); + GroupParametersLayout->addWidget( PreviewCheckBox, 4, 0 ); + + AutoApplyCheckBox = new QCheckBox(tr("Auto Apply"), GroupParameters); + AutoApplyCheckBox->setChecked(false); + GroupParametersLayout->addWidget( AutoApplyCheckBox, 4, 1 ); + + // Controls for "Ok", "Apply" and "Close" button + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "VISU_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "VISU_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + + VisuGUI_ClippingDlgLayout->addWidget( GroupPlanes, 0, 0 ); + VisuGUI_ClippingDlgLayout->addWidget( GroupParameters, 1, 0 ); + VisuGUI_ClippingDlgLayout->addWidget( GroupButtons, 2, 0 ); + +// mySelection = SALOME_Selection::Selection( VisuGUI::GetVisuGUI()->GetActiveStudy()->getSelection()); + + // Initial state + VISU::RangeStepAndValidator( SpinBoxDistance, 0.0, 1.0, 0.01, 3 ); + VISU::RangeStepAndValidator( SpinBoxRot1, -180.0, 180.0, 1, 3 ); + VISU::RangeStepAndValidator( SpinBoxRot2, -180.0, 180.0, 1, 3 ); + + ComboBoxOrientation->insertItem( tr("|| X-Y") ); + ComboBoxOrientation->insertItem( tr("|| Y-Z") ); + ComboBoxOrientation->insertItem( tr("|| Z-X") ); + + SpinBoxDistance->setValue(0.5); + + myPrs3d = 0; + myIsSelectPlane = false; + onSelectionChanged(); + + // signals and slots connections : + connect( ComboBoxPlanes, SIGNAL( activated( int )), this, SLOT( onSelectPlane( int ) ) ); + connect( buttonNew, SIGNAL( clicked() ), this, SLOT( ClickOnNew() ) ); + connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( ClickOnDelete() ) ); + connect( ComboBoxOrientation, SIGNAL( activated( int )), this, SLOT( onSelectOrientation( int ) ) ); + connect( SpinBoxDistance, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); + connect( SpinBoxRot1, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); + connect( SpinBoxRot2, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); + connect( PreviewCheckBox, SIGNAL( toggled( bool )), this, SLOT( OnPreviewToggle( bool ) ) ); + connect( AutoApplyCheckBox, SIGNAL( toggled( bool )), this, SLOT( ClickOnApply() ) ); + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); +// connect( VisuGUI::GetVisuGUI(), SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnOk() ) ) ; +// connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + /* to close dialog if study frame change */ +// connect( VisuGUI::GetVisuGUI(), SIGNAL ( SignalStudyFrameChanged() ), this, SLOT( ClickOnCancel() ) ) ; + + //connect( myStudy, SIGNAL(closed()), this, SLOT( reject() ) ); + //connect( myStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)), + // this, SLOT(onFrameActivated(QAD_StudyFrame*))); + connect(VisuGUI::GetActiveStudy()->getActiveStudyFrame(), + SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)), this, SLOT( ClickOnCancel())); + + this->show(); +} + +//================================================================================= +// function : ~VisuGUI_ClippingDlg() +// purpose : +//================================================================================= +VisuGUI_ClippingDlg::~VisuGUI_ClippingDlg() +{ + // no need to delete child widgets, Qt does it all for us + std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); + //VISU::RenderViewFrame(VISU::GetCurrentVtkView()); + VISU::RenderViewFrame(VisuGUI::GetActiveStudy()); +} + +//======================================================================= +// function : ClickOnApply() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::ClickOnApply() +{ + if (!myPrs3d) + return; + + if (VisuGUI::GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + QAD_WaitCursor wc; + + myPrs3d->RemoveAllClippingPlanes(); + + VISU::TPlanes::iterator anIter = myPlanes.begin(); + for (;anIter != myPlanes.end();anIter++){ + OrientedPlane* anOrientedPlane = OrientedPlane::New(); + anOrientedPlane->ShallowCopy(anIter->GetPointer()); + myPrs3d->AddClippingPlane(anOrientedPlane); + anOrientedPlane->Delete(); + } + + //VISU::RenderViewFrame(VISU::GetCurrentVtkView()); + VISU::RenderViewFrame(VisuGUI::GetActiveStudy()); + //VisuGUI::UpdateViewer(myPrs3d, false); + } +} + +//======================================================================= +// function : ClickOnOk() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::ClickOnOk() +{ + ClickOnApply(); + ClickOnCancel(); +} + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::ClickOnCancel() +{ + close(); +} + +//================================================================================= +// function : onSelectionChanged() +// purpose : Called when selection is changed +//================================================================================= +void VisuGUI_ClippingDlg::onSelectionChanged() +{ + if (VisuGUI::GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + myPrs3d = VisuGUI::GetSelectedPrs3d(); + if (myPrs3d) { + std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); + myPlanes.clear(); + + vtkIdType anId = 0, anEnd = myPrs3d->GetNumberOfClippingPlanes(); + for (; anId < anEnd; anId++) { + if (vtkImplicitFunction* aFunction = myPrs3d->GetClippingPlane(anId)) { + if (OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)) { + OrientedPlane* anOrientedPlane = OrientedPlane::New(VisuGUI::GetActiveStudy()); + VISU::TVTKPlane aTVTKPlane(anOrientedPlane); + anOrientedPlane->Delete(); + aTVTKPlane->ShallowCopy(aPlane); + myPlanes.push_back(aTVTKPlane); + } + } + } + + std::for_each(myPlanes.begin(),myPlanes.end(), + TSetVisiblity(PreviewCheckBox->isChecked())); + } + } + Sinchronize(); + //VISU::RenderViewFrame(VISU::GetCurrentVtkView()); + VISU::RenderViewFrame(VisuGUI::GetActiveStudy()); + //VisuGUI::UpdateViewer(myPrs3d, false); +} + +//======================================================================= +// function : onSelectPlane() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::onSelectPlane(int theIndex) +{ + if (!myPrs3d || myPlanes.empty()) + return; + + OrientedPlane* aPlane = myPlanes[theIndex].GetPointer(); + + // Orientation + VISU::Orientation anOrientation = aPlane->GetOrientation(); + + // Rotations + double aRot[2] = {aPlane->myAngle[0], aPlane->myAngle[1]}; + + // Set plane parameters in the dialog + myIsSelectPlane = true; + setDistance(aPlane->GetDistance()); + setRotation(aRot[0], aRot[1]); + switch (anOrientation) { + case VISU::XY: + ComboBoxOrientation->setCurrentItem(0); + onSelectOrientation(0); + break; + case VISU::YZ: + ComboBoxOrientation->setCurrentItem(1); + onSelectOrientation(1); + break; + case VISU::ZX: + ComboBoxOrientation->setCurrentItem(2); + onSelectOrientation(2); + break; + } + myIsSelectPlane = false; +} + +//======================================================================= +// function : ClickOnNew() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::ClickOnNew() +{ + if (!myPrs3d) + return; + + OrientedPlane* aPlane = OrientedPlane::New(VisuGUI::GetActiveStudy()); + VISU::TVTKPlane aTVTKPlane(aPlane); + myPlanes.push_back(aTVTKPlane); + + if (PreviewCheckBox->isChecked()) + aTVTKPlane->myActor->VisibilityOn(); + + Sinchronize(); + SetCurrentPlaneParam(); +} + +//======================================================================= +// function : ClickOnDelete() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::ClickOnDelete() +{ + if (!myPrs3d || myPlanes.empty()) + return; + + int aPlaneIndex = ComboBoxPlanes->currentItem(); + + VISU::TPlanes::iterator anIter = myPlanes.begin() + aPlaneIndex; + anIter->GetPointer()->myActor->SetVisibility(false); + myPlanes.erase(anIter); + + if(AutoApplyCheckBox->isChecked()) + ClickOnApply(); + + Sinchronize(); + //VISU::RenderViewFrame(VISU::GetCurrentVtkView()); + VISU::RenderViewFrame(VisuGUI::GetActiveStudy()); + //VisuGUI::UpdateViewer(myPrs3d, false); +} + +//======================================================================= +// function : onSelectOrientation() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::onSelectOrientation(int theItem) +{ + if (myPlanes.empty()) + return; + + if (theItem == 0) { + TextLabelRot1->setText( tr( "Rotation around X (Y to Z):") ); + TextLabelRot2->setText( tr( "Rotation around Y (X to Z):" ) ); + } + else if (theItem == 1) { + TextLabelRot1->setText( tr( "Rotation around Y (Z to X):" ) ); + TextLabelRot2->setText( tr( "Rotation around Z (Y to X):" ) ); + } + else if (theItem == 2) { + TextLabelRot1->setText( tr( "Rotation around Z (X to Y):" ) ); + TextLabelRot2->setText( tr( "Rotation around X (Z to Y):" ) ); + } + + if((QComboBox*)sender() == ComboBoxOrientation) + SetCurrentPlaneParam(); +} + +//======================================================================= +// function : Sinchronize() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::Sinchronize() +{ + int aNbPlanes = myPlanes.size(); + ComboBoxPlanes->clear(); + + QString aName; + for(int i = 1; i<=aNbPlanes ; i++){ + aName = QString(tr("Plane# %1")).arg(i); + ComboBoxPlanes->insertItem(aName); + } + + int aPos = ComboBoxPlanes->count() - 1; + ComboBoxPlanes->setCurrentItem(aPos); + + bool anIsControlsEnable = (aPos >= 0); + if(anIsControlsEnable){ + onSelectPlane(aPos); + }else{ + ComboBoxPlanes->insertItem( tr("No planes") ); + SpinBoxRot1->setValue(0.0); + SpinBoxRot2->setValue(0.0); + SpinBoxDistance->setValue(0.5); + } + + buttonDelete->setEnabled(anIsControlsEnable); + buttonApply->setEnabled(anIsControlsEnable); + PreviewCheckBox->setEnabled(anIsControlsEnable); + AutoApplyCheckBox->setEnabled(anIsControlsEnable); + ComboBoxOrientation->setEnabled(anIsControlsEnable); + SpinBoxDistance->setEnabled(anIsControlsEnable); + SpinBoxRot1->setEnabled(anIsControlsEnable); + SpinBoxRot2->setEnabled(anIsControlsEnable); +} + +//======================================================================= +// function : setRotation() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::setRotation( const double theRot1, const double theRot2 ) +{ + SpinBoxRot1->setValue(theRot1); + SpinBoxRot2->setValue(theRot2); +} + +//======================================================================= +// function : SetCurrentPlaneParam() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::SetCurrentPlaneParam() +{ + if (myPlanes.empty() || myIsSelectPlane) + return; + + int aCurPlaneIndex = ComboBoxPlanes->currentItem(); + + OrientedPlane* aPlane = myPlanes[aCurPlaneIndex].GetPointer(); + + float aNormal[3]; + VISU::Orientation anOrientation; + float aDir[3][3] = {{0, 0, 0}, {0, 0, 0}}; + { + static double aCoeff = vtkMath::Pi()/180.0; + + float aRot[2] = {getRotation1(), getRotation2()}; + aPlane->myAngle[0] = aRot[0]; + aPlane->myAngle[1] = aRot[1]; + + float anU[2] = {cos(aCoeff*aRot[0]), cos(aCoeff*aRot[1])}; + float aV[2] = {sqrt(1.0-anU[0]*anU[0]), sqrt(1.0-anU[1]*anU[1])}; + aV[0] = aRot[0] > 0? aV[0]: -aV[0]; + aV[1] = aRot[1] > 0? aV[1]: -aV[1]; + + switch (ComboBoxOrientation->currentItem()) { + case 0: + anOrientation = VISU::XY; + + aDir[0][1] = anU[0]; + aDir[0][2] = aV[0]; + + aDir[1][0] = anU[1]; + aDir[1][2] = aV[1]; + + break; + case 1: + anOrientation = VISU::YZ; + + aDir[0][2] = anU[0]; + aDir[0][0] = aV[0]; + + aDir[1][1] = anU[1]; + aDir[1][0] = aV[1]; + + break; + case 2: + anOrientation = VISU::ZX; + + aDir[0][0] = anU[0]; + aDir[0][1] = aV[0]; + + aDir[1][2] = anU[1]; + aDir[1][1] = aV[1]; + + break; + } + + vtkMath::Cross(aDir[1],aDir[0],aNormal); + vtkMath::Normalize(aNormal); + vtkMath::Cross(aNormal,aDir[1],aDir[0]); + } + + aPlane->SetOrientation(anOrientation); + aPlane->SetDistance(getDistance()); + + myPrs3d->SetPlaneParam(aNormal, getDistance(), aPlane); + + vtkDataSet* aDataSet = myPrs3d->GetInput(); + float *aPnt = aDataSet->GetCenter(); + + float* anOrigin = aPlane->GetOrigin(); + float aDel = aDataSet->GetLength()/2.0; + + float aDelta[2][3] = {{aDir[0][0]*aDel, aDir[0][1]*aDel, aDir[0][2]*aDel}, + {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}}; + float aParam, aPnt0[3], aPnt1[3], aPnt2[3]; + + float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0], + aPnt[1] - aDelta[0][1] - aDelta[1][1], + aPnt[2] - aDelta[0][2] - aDelta[1][2]}; + float aPnt02[3] = {aPnt01[0] + aNormal[0], + aPnt01[1] + aNormal[1], + aPnt01[2] + aNormal[2]}; + vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0); + + float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0], + aPnt[1] - aDelta[0][1] + aDelta[1][1], + aPnt[2] - aDelta[0][2] + aDelta[1][2]}; + float aPnt12[3] = {aPnt11[0] + aNormal[0], + aPnt11[1] + aNormal[1], + aPnt11[2] + aNormal[2]}; + vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1); + + float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0], + aPnt[1] + aDelta[0][1] - aDelta[1][1], + aPnt[2] + aDelta[0][2] - aDelta[1][2]}; + float aPnt22[3] = {aPnt21[0] + aNormal[0], + aPnt21[1] + aNormal[1], + aPnt21[2] + aNormal[2]}; + vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2); + + vtkPlaneSource* aPlaneSource = aPlane->myPlaneSource; + aPlaneSource->SetNormal(aNormal[0],aNormal[1],aNormal[2]); + aPlaneSource->SetOrigin(aPnt0[0],aPnt0[1],aPnt0[2]); + aPlaneSource->SetPoint1(aPnt1[0],aPnt1[1],aPnt1[2]); + aPlaneSource->SetPoint2(aPnt2[0],aPnt2[1],aPnt2[2]); + + if (AutoApplyCheckBox->isChecked()) + ClickOnApply(); + + //VISU::RenderViewFrame(VISU::GetCurrentVtkView()); + VISU::RenderViewFrame(VisuGUI::GetActiveStudy()); +} + +//======================================================================= +// function : OnPreviewToggle() +// purpose : +//======================================================================= +void VisuGUI_ClippingDlg::OnPreviewToggle(bool theIsToggled){ + std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); + //VISU::RenderViewFrame(VISU::GetCurrentVtkView()); + VISU::RenderViewFrame(VisuGUI::GetActiveStudy()); +} diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.h b/src/VISUGUI/VisuGUI_ClippingDlg.h new file mode 100644 index 00000000..c4743688 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ClippingDlg.h @@ -0,0 +1,101 @@ + +#ifndef DIALOGBOX_CLIPPING_H +#define DIALOGBOX_CLIPPING_H + +#include "QAD_SpinBoxDbl.h" + +// QT Includes +#include +#include + +// VTK Includes +#include +#include + +#include + +class QLabel; +class QPushButton; +class QTable; +class QCheckBox; +class QComboBox; +//class SALOME_Selection; + +class OrientedPlane; + +namespace VISU { + class Prs3d_i; + + typedef vtkSmartPointer TVTKPlane; + typedef std::vector TPlanes; + enum Orientation {XY, YZ, ZX}; +}; + + +//================================================================================= +// class : VisuGUI_ClippingDlg +// purpose : +//================================================================================= +class VisuGUI_ClippingDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_ClippingDlg( QWidget* parent = 0, + const char* name = 0, + bool modal = false, + WFlags fl = 0 ); + + float getDistance() { return (float)SpinBoxDistance->value(); } + void setDistance(const float theDistance) { SpinBoxDistance->setValue(theDistance); } + double getRotation1() { return SpinBoxRot1->value(); } + double getRotation2() { return SpinBoxRot2->value(); } + void setRotation(const double theRot1, const double theRot2); + void Sinchronize(); + + ~VisuGUI_ClippingDlg(); + +private: + + //SALOME_Selection* mySelection; + VISU::Prs3d_i* myPrs3d; + VISU::TPlanes myPlanes; + + QComboBox* ComboBoxPlanes; + QPushButton* buttonNew; + QPushButton* buttonDelete; + + QLabel* TextLabelOrientation; + QLabel* TextLabelDistance; + QLabel* TextLabelRot1; + QLabel* TextLabelRot2; + + QComboBox* ComboBoxOrientation; + QAD_SpinBoxDbl* SpinBoxDistance; + QAD_SpinBoxDbl* SpinBoxRot1; + QAD_SpinBoxDbl* SpinBoxRot2; + + QCheckBox* PreviewCheckBox; + QCheckBox* AutoApplyCheckBox; + + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + + bool myIsSelectPlane; + +public slots: + + void onSelectPlane(int theIndex); + void ClickOnNew(); + void ClickOnDelete(); + void onSelectOrientation(int theItem); + void SetCurrentPlaneParam(); + void onSelectionChanged(); + void OnPreviewToggle(bool theIsToggled); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); +}; + +#endif // DIALOGBOX_TRANSPARENCYDLG_H diff --git a/src/VISU_I/VISU_CutLines_i.hh b/src/VISU_I/VISU_CutLines_i.hh index e0ee1820..78a4bd5c 100644 --- a/src/VISU_I/VISU_CutLines_i.hh +++ b/src/VISU_I/VISU_CutLines_i.hh @@ -100,7 +100,7 @@ namespace VISU{ void BuildTableOfReal(SALOMEDS::SObject_ptr theSObject); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual QString GenerateName(); }; diff --git a/src/VISU_I/VISU_CutPlanes_i.hh b/src/VISU_I/VISU_CutPlanes_i.hh index 867fe5d3..41cab140 100644 --- a/src/VISU_I/VISU_CutPlanes_i.hh +++ b/src/VISU_I/VISU_CutPlanes_i.hh @@ -83,7 +83,7 @@ namespace VISU{ virtual Storable* Restore(const Storable::TRestoringMap& theMap); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual QString GenerateName(); }; diff --git a/src/VISU_I/VISU_DeformedShape_i.hh b/src/VISU_I/VISU_DeformedShape_i.hh index 96fc4d22..a5784ba7 100644 --- a/src/VISU_I/VISU_DeformedShape_i.hh +++ b/src/VISU_I/VISU_DeformedShape_i.hh @@ -71,7 +71,7 @@ namespace VISU{ virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, int theIteration); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual QString GenerateName(); diff --git a/src/VISU_I/VISU_IsoSurfaces_i.hh b/src/VISU_I/VISU_IsoSurfaces_i.hh index d3e70ff1..52dacdea 100644 --- a/src/VISU_I/VISU_IsoSurfaces_i.hh +++ b/src/VISU_I/VISU_IsoSurfaces_i.hh @@ -66,7 +66,7 @@ namespace VISU{ virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, int theIteration); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual QString GenerateName(); diff --git a/src/VISU_I/VISU_Mesh_i.hh b/src/VISU_I/VISU_Mesh_i.hh index 5ae8a364..f08a9fc2 100644 --- a/src/VISU_I/VISU_Mesh_i.hh +++ b/src/VISU_I/VISU_Mesh_i.hh @@ -66,9 +66,9 @@ namespace VISU{ VISU_MeshPL* myMeshPL; - string myMeshName; + std::string myMeshName; TEntity myEntity; - string mySubMeshName; + std::string mySubMeshName; VISU::VISUType myType; VISU::PresentationType myPresentType; @@ -84,7 +84,7 @@ namespace VISU{ virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; - static const string myComment; + static const std::string myComment; virtual QString GenerateName(); virtual Storable* Restore(const Storable::TRestoringMap& theMap); diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index bd655338..e0b42eec 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -121,6 +121,10 @@ VISU_PipeLine* VISU::Prs3d_i::GetPL(){ return myPipeLine; } +vtkUnstructuredGrid* VISU::Prs3d_i::GetInput(){ + return myPipeLine->GetInput(); +} + SALOMEDS::SObject_var VISU::Prs3d_i::GetSObject(){ return mySObject; @@ -130,6 +134,28 @@ void VISU::Prs3d_i::GetBounds(float aBounds[6]){ myPipeLine->GetMapper()->GetBounds(aBounds); } +// Clipping planes + +void VISU::Prs3d_i::SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane) { + myPipeLine->SetPlaneParam(theDir, theDist, thePlane); +} + +void VISU::Prs3d_i::RemoveAllClippingPlanes() { + myPipeLine->RemoveAllClippingPlanes(); +} + +vtkIdType VISU::Prs3d_i::GetNumberOfClippingPlanes() { + return myPipeLine->GetNumberOfClippingPlanes(); +} + +vtkPlane* VISU::Prs3d_i::GetClippingPlane (vtkIdType theID) { + return myPipeLine->GetClippingPlane(theID); +} + +vtkIdType VISU::Prs3d_i::AddClippingPlane (vtkPlane* thePlane) { + return myPipeLine->AddClippingPlane(thePlane); +} + VISU::Result_i* VISU::GetResult(SALOMEDS::SObject_ptr theSObject){ VISU::Result_var aResult = FindResult(theSObject); if(!aResult->_is_nil()) diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index cd7115aa..feb1a8ab 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -32,9 +32,14 @@ #include "Handle_SALOME_InteractiveObject.hxx" #include "VISU_Convertor.hxx" +#include + class VISU_PipeLine; class VISU_Actor; +class vtkPlane; +class vtkUnstructuredGrid; + namespace VISU{ class Result_i; class Prs3d_i : @@ -65,6 +70,8 @@ namespace VISU{ virtual void Update() ; VISU_PipeLine* GetPL(); + vtkUnstructuredGrid* GetInput(); + void GetBounds(float aBounds[6]); virtual const char* GetComment() const = 0; @@ -80,11 +87,21 @@ namespace VISU{ Result_i* GetResult() const { return myResult;} virtual SALOMEDS::SObject_var GetSObject(); + + // Clipping planes + virtual void SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane); + //virtual void GetPlaneParam (float theDir[3], float& theDist, vtkPlane* thePlane); + + virtual void RemoveAllClippingPlanes(); + virtual vtkIdType GetNumberOfClippingPlanes(); + virtual vtkPlane* GetClippingPlane (vtkIdType theID); + virtual vtkIdType AddClippingPlane (vtkPlane* thePlane); }; Result_i* GetResult(SALOMEDS::SObject_ptr theSObject); template - Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, const Storable::TRestoringMap& theMap) + Storable* Restore (SALOMEDS::SObject_ptr theSObject, + const std::string& thePrefix, + const Storable::TRestoringMap& theMap) { VISU::Result_i* pResult = GetResult(theSObject); if(pResult != NULL){ diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index 510ff794..eca96624 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -127,9 +127,9 @@ namespace VISU{ VISU_ScalarMapPL* myScalarMapPL; PField myField; - string myMeshName; + std::string myMeshName; TEntity myEntity; - string myFieldName; + std::string myFieldName; int myIteration; bool myIsFixedRange; @@ -160,20 +160,20 @@ namespace VISU{ virtual void ToStream(std::ostringstream& theStr); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual QString GenerateName(); virtual Storable* Restore(const Storable::TRestoringMap& theMap); static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, const Storable::TRestoringMap& theMap); + const std::string& thePrefix, const Storable::TRestoringMap& theMap); virtual void Update() ; virtual void SetMapScale(double theMapScale = 1.0); const VISU::PField GetField() const { return myField;} - const string& GetFieldName() const { return myFieldName;} + const std::string& GetFieldName() const { return myFieldName;} virtual bool IsRangeFixed() { return myIsFixedRange; } virtual void SetSourceRange(); diff --git a/src/VISU_I/VISU_StreamLines_i.hh b/src/VISU_I/VISU_StreamLines_i.hh index 05d6cb46..43be1a1d 100644 --- a/src/VISU_I/VISU_StreamLines_i.hh +++ b/src/VISU_I/VISU_StreamLines_i.hh @@ -71,7 +71,7 @@ namespace VISU{ VISU_StreamLinesPL* myStreamLinesPL; vtkAppendFilter* myAppendFilter; - string mySourceEntry; + std::string mySourceEntry; public: static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, @@ -81,7 +81,7 @@ namespace VISU{ virtual void ToStream(std::ostringstream& theStr); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual QString GenerateName(); diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index 1d00478b..38311147 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -61,16 +61,16 @@ namespace VISU{ protected: VISU::Table::Orientation myOrientation; - string myTitle; + std::string myTitle; SALOMEDS::SObject_var mySObj; public: virtual Storable* Create(); virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO); static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, const Storable::TRestoringMap& theMap); + const std::string& thePrefix, const Storable::TRestoringMap& theMap); virtual void ToStream( std::ostringstream& theStr ); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual const char* GenerateName(); virtual const char* GetTableTitle(); @@ -118,7 +118,7 @@ namespace VISU{ VISU::Curve::MarkerType myMarker; VISU::Curve::LineType myLine; int myLineWidth; - string myTitle; + std::string myTitle; bool myAuto; SALOMEDS::SObject_var mySObj; @@ -127,20 +127,20 @@ namespace VISU{ virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO); static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, const Storable::TRestoringMap& theMap); + const std::string& thePrefix, const Storable::TRestoringMap& theMap); virtual void ToStream( std::ostringstream& theStr ); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual const char* GenerateName(); virtual const char* GetTableID(); virtual CORBA::Boolean IsAuto() { return myAuto; } virtual CORBA::Boolean IsValid(); - virtual string GetHorTitle(); - virtual string GetVerTitle(); - virtual string GetHorUnits(); - virtual string GetVerUnits(); + virtual std::string GetHorTitle(); + virtual std::string GetVerTitle(); + virtual std::string GetHorUnits(); + virtual std::string GetVerUnits(); virtual int GetData( double*& theHorList, double*& theVerList ); virtual Plot2d_Curve* CreatePresentation(); @@ -178,10 +178,10 @@ namespace VISU{ virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO ); static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const string& thePrefix, const Storable::TRestoringMap& theMap); + const std::string& thePrefix, const Storable::TRestoringMap& theMap); virtual void ToStream( std::ostringstream& theStr ); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual const char* GenerateName(); diff --git a/src/VISU_I/VISU_Vectors_i.hh b/src/VISU_I/VISU_Vectors_i.hh index 40b45a43..6ecd5e6b 100644 --- a/src/VISU_I/VISU_Vectors_i.hh +++ b/src/VISU_I/VISU_Vectors_i.hh @@ -75,7 +75,7 @@ namespace VISU{ virtual Storable* Restore(const Storable::TRestoringMap& theMap); - static const string myComment; + static const std::string myComment; virtual const char* GetComment() const; virtual QString GenerateName(); -- 2.39.2