#include <vtkCamera.h>
#include <vtkActor.h>
+#include <vtkProperty.h>
+
#include "utilities.h"
using namespace std;
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];
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();
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]);
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){
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
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();
}
void VISU_IsoSurfacesPL::Update(){
- VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,myInput,myFieldTransform);
+ VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform);
SetMapScale();
VISU_ScalarMapPL::Update();
VISU_MeshPL::VISU_MeshPL(){}
void VISU_MeshPL::Build() {
- myMapper->SetInput(myInput);
+ myMapper->SetInput(GetInput2());
}
void VISU_MeshPL::Init(){
#include "VISU_PipeLine.hxx"
#include "VISU_PipeLineUtils.hxx"
+#include "SALOME_PassThroughFilter.h"
+
#include <limits.h>
#include <vtkObjectFactory.h>
#include <vtkDataSetMapper.h>
#include <vtkUnstructuredGrid.h>
+#include <vtkPlane.h>
+#include <vtkExtractGeometry.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunctionCollection.h>
+#include <vtkMath.h>
+
static int MYVTKDEBUG = 0;
#ifdef _DEBUG_
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 = "<<myInput->GetReferenceCount());
+VISU_PipeLine::~VISU_PipeLine()
+{
+ if (MYDEBUG) MESSAGE("~VISU_PipeLine - myInput = "<<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();
}
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);
+}
#ifndef VISU_PipeLine_HeaderFile
#define VISU_PipeLine_HeaderFile
-#include <string>
-#include <algorithm>
#include <vtkObject.h>
-#include <vtkProperty.h>
+#include <vtkSmartPointer.h>
+
+#include <vector>
+
+template <class T>
+class TVTKSmartPtr: public vtkSmartPointer<T>
+{
+public:
+ TVTKSmartPtr() {}
+ TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) {
+ if(r && theIsOwner)
+ r->Delete();
+ }
+ TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){
+ vtkSmartPointer<T>::operator=(r);
+ if(r && theIsOwner)
+ r->Delete();
+ return *this;
+ }
+ TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::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:
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();
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<vtkPlane> TPlanePtr;
+ typedef std::vector<TPlanePtr> TCippingPlaneCont;
+ TCippingPlaneCont myCippingPlaneCont;
+
+ SALOME_PassThroughFilter* myPassFilter0;
+ vtkExtractGeometry* myExtractGeometry;
+
+private:
+ TInput *myInput;
};
#endif
void VISU_ScalarMapPL::Build() {
- myExtractor->SetInput(myInput);
+ myExtractor->SetInput(GetInput2());
myFieldTransform->SetInput(myExtractor->GetOutput());
myMapper->SetInput(DoHook());
}
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;
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);
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();
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();
}
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());
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();
VisuGUI_TimeAnimation.cxx \
VisuGUI_CutLinesDlg.cxx \
VisuGUI_FileDlg.cxx \
+ VisuGUI_ClippingDlg.cxx \
VisuGUI_EditContainerDlg.cxx
LIB_MOC = \
VisuGUI_TimeAnimation.h \
VisuGUI_CutLinesDlg.h \
VisuGUI_FileDlg.h \
+ VisuGUI_ClippingDlg.h \
VisuGUI_EditContainerDlg.h \
VisuGUI_Selection.h
msgid "VISU_BUT_OK"
msgstr "OK"
+msgid "VISU_BUT_APPLY"
+msgstr "Apply"
+
msgid "VISU_WARNING"
msgstr "Post-Pro Warning"
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"
msgid "WRN_LOGARITHMIC_FIELD_RANGE"
msgstr "Logarithmic scaling: field range contains negative values, use imposed range instead"=======
+
msgid "TXT_ORIENTATION"
msgstr "Orientation"
#include "VisuGUI_StreamLinesDlg.h"
#include "VisuGUI_EditContainerDlg.h"
#include "VisuGUI_TimeAnimation.h"
+#include "VisuGUI_ClippingDlg.h"
#include "VisuGUI_Selection.h"
#include "VisuGUI_NonIsometricDlg.h"
SALOMEDS::AttributeIOR_var anIOR;
switch (theCommandID){
- /* ======================================================================================== */
- /* Import Table from file */
- /* ======================================================================================== */
+ /* ========================================================================== */
+ /* Import Table from file */
+ /* ========================================================================== */
case 199:
{
if(checkLock(aStudy)) break;
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:
{
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();
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 :
/* 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;
case 908 : // Sweep IsoSurfaces or Cutplanes
visuGUI->Sweep();
break;
-
+*/
/* ======================================================================================== */
/* Preferences for Scalar Bar */
/* ======================================================================================== */
}
/* ======================================================================================== */
-/* Preferences for Sweeping */
+/* Preferences for Sweeping */
/* ======================================================================================== */
case 52:
{
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;
}
+//=====================================================================================
+// function : ClippingPlanes()
+// purpose :
+//=====================================================================================
+void VisuGUI::ClippingPlanes() {
+ //SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
+ new VisuGUI_ClippingDlg (QAD_Application::getDesktop(),"",false);
+}
+
//=====================================================================================
// function : Sweep()
// purpose :
thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
}
+
+ thePopup->insertItem("Clipping planes", visuGUI, SLOT(ClippingPlanes()));
+
if (isVTKViewer) {
if ( theParent == "Viewer" &&
( aType == VISU::TMESH ||
void Rename();
void RenameTable();
void RenameContainer();
+ void ClippingPlanes();
void Sweep();
void TimeAnimation();
--- /dev/null
+
+#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 <qlabel.h>
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qvalidator.h>
+
+// VTK Includes
+#include <vtkMath.h>
+#include <vtkCamera.h>
+#include <vtkRenderer.h>
+#include <vtkDataSet.h>
+#include <vtkDataSetMapper.h>
+#include <vtkImplicitFunction.h>
+#include <vtkPlaneSource.h>
+#include <vtkPolyData.h>
+#include <vtkUnstructuredGrid.h>
+
+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<VTKViewer_ViewFrame*>
+ (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());
+}
--- /dev/null
+
+#ifndef DIALOGBOX_CLIPPING_H
+#define DIALOGBOX_CLIPPING_H
+
+#include "QAD_SpinBoxDbl.h"
+
+// QT Includes
+#include <qdialog.h>
+#include <qtable.h>
+
+// VTK Includes
+#include <vtkSmartPointer.h>
+#include <vtkPlane.h>
+
+#include <vector>
+
+class QLabel;
+class QPushButton;
+class QTable;
+class QCheckBox;
+class QComboBox;
+//class SALOME_Selection;
+
+class OrientedPlane;
+
+namespace VISU {
+ class Prs3d_i;
+
+ typedef vtkSmartPointer<OrientedPlane> TVTKPlane;
+ typedef std::vector<TVTKPlane> 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
void BuildTableOfReal(SALOMEDS::SObject_ptr theSObject);
- 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 const string myComment;
+ static const std::string myComment;
virtual const char* GetComment() const;
virtual QString GenerateName();
};
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();
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();
VISU_MeshPL* myMeshPL;
- string myMeshName;
+ std::string myMeshName;
TEntity myEntity;
- string mySubMeshName;
+ std::string mySubMeshName;
VISU::VISUType myType;
VISU::PresentationType myPresentType;
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);
return myPipeLine;
}
+vtkUnstructuredGrid* VISU::Prs3d_i::GetInput(){
+ return myPipeLine->GetInput();
+}
+
SALOMEDS::SObject_var VISU::Prs3d_i::GetSObject(){
return mySObject;
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())
#include "Handle_SALOME_InteractiveObject.hxx"
#include "VISU_Convertor.hxx"
+#include <vtkPlaneSource.h>
+
class VISU_PipeLine;
class VISU_Actor;
+class vtkPlane;
+class vtkUnstructuredGrid;
+
namespace VISU{
class Result_i;
class Prs3d_i :
virtual void Update() ;
VISU_PipeLine* GetPL();
+ vtkUnstructuredGrid* GetInput();
+
void GetBounds(float aBounds[6]);
virtual const char* GetComment() const = 0;
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<class TPrs3d>
- 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){
VISU_ScalarMapPL* myScalarMapPL;
PField myField;
- string myMeshName;
+ std::string myMeshName;
TEntity myEntity;
- string myFieldName;
+ std::string myFieldName;
int myIteration;
bool myIsFixedRange;
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();
VISU_StreamLinesPL* myStreamLinesPL;
vtkAppendFilter* myAppendFilter;
- string mySourceEntry;
+ std::string mySourceEntry;
public:
static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
virtual void ToStream(std::ostringstream& theStr);
- static const string myComment;
+ static const std::string myComment;
virtual const char* GetComment() const;
virtual QString GenerateName();
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();
VISU::Curve::MarkerType myMarker;
VISU::Curve::LineType myLine;
int myLineWidth;
- string myTitle;
+ std::string myTitle;
bool myAuto;
SALOMEDS::SObject_var mySObj;
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();
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 Storable* Restore(const Storable::TRestoringMap& theMap);
- static const string myComment;
+ static const std::string myComment;
virtual const char* GetComment() const;
virtual QString GenerateName();