First step for the "21793: [CEA 625] Clipping : from coordinates or from bounding box" issue.

This commit is contained in:
rnv 2013-10-16 12:56:06 +00:00
parent fcec7fb454
commit 824f011cef
18 changed files with 2082 additions and 911 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -75,6 +75,7 @@
#include <vtkMath.h> #include <vtkMath.h>
#include <vtkPlane.h> #include <vtkPlane.h>
#include <vtkPlaneCollection.h>
#include <vtkImplicitBoolean.h> #include <vtkImplicitBoolean.h>
#include <vtkImplicitFunctionCollection.h> #include <vtkImplicitFunctionCollection.h>
@ -534,6 +535,8 @@ SMESH_ActorDef::SMESH_ActorDef()
myImplicitBoolean = vtkImplicitBoolean::New(); myImplicitBoolean = vtkImplicitBoolean::New();
myImplicitBoolean->SetOperationTypeToIntersection(); myImplicitBoolean->SetOperationTypeToIntersection();
myPlaneCollection = vtkPlaneCollection::New();
//Quadratic 2D elements representation //Quadratic 2D elements representation
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0); int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
@ -619,6 +622,7 @@ SMESH_ActorDef::~SMESH_ActorDef()
//my0DExtActor->Delete(); //my0DExtActor->Delete();
myImplicitBoolean->Delete(); myImplicitBoolean->Delete();
myPlaneCollection->Delete();
#ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_PLOT2DVIEWER
if(my2dHistogram) { if(my2dHistogram) {
@ -2149,10 +2153,67 @@ SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
return myCippingPlaneCont.size(); return myCippingPlaneCont.size();
} }
void
SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
{
if(thePlane)
myPlaneCollection->AddItem( thePlane );
}
void
SMESH_ActorDef::SetOpenGLClippingPlane()
{
// before use this method you must add clipping planes using method
// SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
if( !myPlaneCollection->GetNumberOfItems() )
return;
// It is necessary to set plane collection for each mapper of actor
// and update current inputs of mapper
myNodeActor->SetPlaneCollection( myPlaneCollection );
myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
myBaseActor->SetPlaneCollection( myPlaneCollection );
myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
myHighlitableActor->SetPlaneCollection( myPlaneCollection );
myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
my1DActor->SetPlaneCollection( myPlaneCollection );
my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
my2DActor->SetPlaneCollection( myPlaneCollection );
my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
myNodeExtActor->SetPlaneCollection( myPlaneCollection );
myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
my0DActor->SetPlaneCollection( myPlaneCollection );
my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
myBallActor->SetPlaneCollection( myPlaneCollection );
myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
my1DExtActor->SetPlaneCollection( myPlaneCollection );
my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
my2DExtActor->SetPlaneCollection( myPlaneCollection );
my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
my3DActor->SetPlaneCollection( myPlaneCollection );
my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
my3DExtActor->SetPlaneCollection( myPlaneCollection );
my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
Modified();
}
void void
SMESH_ActorDef:: SMESH_ActorDef::
RemoveAllClippingPlanes() RemoveAllClippingPlanes()
{ {
myPlaneCollection->RemoveAllItems();
myImplicitBoolean->GetFunction()->RemoveAllItems(); myImplicitBoolean->GetFunction()->RemoveAllItems();
myImplicitBoolean->GetFunction()->Modified(); // VTK bug myImplicitBoolean->GetFunction()->Modified(); // VTK bug
myCippingPlaneCont.clear(); myCippingPlaneCont.clear();

View File

@ -154,6 +154,8 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
virtual vtkIdType GetNumberOfClippingPlanes() = 0; virtual vtkIdType GetNumberOfClippingPlanes() = 0;
virtual vtkPlane* GetClippingPlane(vtkIdType theID) = 0; virtual vtkPlane* GetClippingPlane(vtkIdType theID) = 0;
virtual vtkIdType AddClippingPlane(vtkPlane* thePlane) = 0; virtual vtkIdType AddClippingPlane(vtkPlane* thePlane) = 0;
virtual void AddOpenGLClippingPlane(vtkPlane* thePlane) = 0;
virtual void SetOpenGLClippingPlane() = 0;
virtual TVisualObjPtr GetObject() = 0; virtual TVisualObjPtr GetObject() = 0;

View File

@ -65,6 +65,7 @@ class vtkLookupTable;
class vtkPlane; class vtkPlane;
class vtkImplicitBoolean; class vtkImplicitBoolean;
class vtkTimeStamp; class vtkTimeStamp;
class vtkPlaneCollection;
class SMESH_DeviceActor; class SMESH_DeviceActor;
class SMESH_NodeLabelActor; class SMESH_NodeLabelActor;
@ -212,6 +213,8 @@ class SMESH_ActorDef : public SMESH_Actor
virtual vtkIdType GetNumberOfClippingPlanes(); virtual vtkIdType GetNumberOfClippingPlanes();
virtual vtkPlane* GetClippingPlane(vtkIdType theID); virtual vtkPlane* GetClippingPlane(vtkIdType theID);
virtual vtkIdType AddClippingPlane(vtkPlane* thePlane); virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
virtual void AddOpenGLClippingPlane(vtkPlane* thePlane);
virtual void SetOpenGLClippingPlane();
virtual TVisualObjPtr GetObject() { return myVisualObj;} virtual TVisualObjPtr GetObject() { return myVisualObj;}
@ -296,6 +299,7 @@ class SMESH_ActorDef : public SMESH_Actor
bool myIsShrunk; bool myIsShrunk;
vtkImplicitBoolean* myImplicitBoolean; vtkImplicitBoolean* myImplicitBoolean;
vtkPlaneCollection* myPlaneCollection;
typedef TVTKSmartPtr<vtkPlane> TPlanePtr; typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
typedef std::vector<TPlanePtr> TCippingPlaneCont; typedef std::vector<TPlanePtr> TCippingPlaneCont;
TCippingPlaneCont myCippingPlaneCont; TCippingPlaneCont myCippingPlaneCont;

View File

@ -63,6 +63,8 @@
#include <vtkRenderer.h> #include <vtkRenderer.h>
#include <vtkPlaneCollection.h>
#include "utilities.h" #include "utilities.h"
#ifdef _DEBUG_ #ifdef _DEBUG_
@ -90,6 +92,7 @@ SMESH_DeviceActor
myProperty = vtkProperty::New(); myProperty = vtkProperty::New();
myMapper = VTKViewer_PolyDataMapper::New(); myMapper = VTKViewer_PolyDataMapper::New();
myPlaneCollection = vtkPlaneCollection::New();
vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
myPolygonOffsetUnits); myPolygonOffsetUnits);
@ -139,6 +142,7 @@ SMESH_DeviceActor
if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this); if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
myMapper->Delete(); myMapper->Delete();
myPlaneCollection->Delete();
myProperty->Delete(); myProperty->Delete();
@ -256,12 +260,20 @@ SMESH_DeviceActor
anId++; // 5 anId++; // 5
myMapper->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); myMapper->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
if( myPlaneCollection->GetNumberOfItems() )
myMapper->SetClippingPlanes( myPlaneCollection );
vtkLODActor::SetMapper( myMapper ); vtkLODActor::SetMapper( myMapper );
Modified(); Modified();
} }
} }
void
SMESH_DeviceActor
::SetPlaneCollection( vtkPlaneCollection* theCollection )
{
myPlaneCollection = theCollection;
}
VTKViewer_ExtractUnstructuredGrid* VTKViewer_ExtractUnstructuredGrid*
SMESH_DeviceActor SMESH_DeviceActor

View File

@ -45,6 +45,7 @@ class vtkUnstructuredGrid;
class vtkLookupTable; class vtkLookupTable;
class vtkImplicitBoolean; class vtkImplicitBoolean;
class vtkPassThroughFilter; class vtkPassThroughFilter;
class vtkPlaneCollection;
class VTKViewer_Transform; class VTKViewer_Transform;
class VTKViewer_TransformFilter; class VTKViewer_TransformFilter;
@ -119,6 +120,8 @@ class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{
VTKViewer_ExtractUnstructuredGrid* GetExtractUnstructuredGrid(); VTKViewer_ExtractUnstructuredGrid* GetExtractUnstructuredGrid();
vtkUnstructuredGrid* GetUnstructuredGrid(); vtkUnstructuredGrid* GetUnstructuredGrid();
void SetPlaneCollection( vtkPlaneCollection* theCollection );
void SetControlMode(SMESH::Controls::FunctorPtr theFunctor, void SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
SMESH_ScalarBarActor* theScalarBarActor, SMESH_ScalarBarActor* theScalarBarActor,
vtkLookupTable* theLookupTable); vtkLookupTable* theLookupTable);
@ -158,6 +161,7 @@ class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{
VTKViewer_PolyDataMapper *myMapper; VTKViewer_PolyDataMapper *myMapper;
TVisualObjPtr myVisualObj; TVisualObjPtr myVisualObj;
vtkPlaneCollection* myPlaneCollection;
vtkProperty *myProperty; vtkProperty *myProperty;
EReperesent myRepresentation; EReperesent myRepresentation;

View File

@ -5533,13 +5533,34 @@ void SMESHGUI::storeVisualParameters (int savePoint)
aPropertyName += gSeparator; aPropertyName += gSeparator;
aPropertyName += QString::number( anId ); aPropertyName += QString::number( anId );
QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData(); QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
aPropertyValue += gDigitsSep; aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData(); aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
aPropertyValue += gDigitsSep; aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData(); if ( aPlane->PlaneMode == SMESH::Absolute ) {
aPropertyValue += gDigitsSep; aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData(); aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
}
else if ( aPlane->PlaneMode == SMESH::Relative ) {
aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
aPropertyValue += gDigitsSep;
aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
}
ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() ); ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
} }
@ -5749,9 +5770,13 @@ void SMESHGUI::storeVisualParameters (int savePoint)
// data structures for clipping planes processing // data structures for clipping planes processing
typedef struct { typedef struct {
int Id; int Id;
vtkIdType Orientation; int Mode;
bool isOpenGLClipping;
vtkIdType RelativeOrientation;
double Distance; double Distance;
double Angle[2]; double Angle[2];
int AbsoluteOrientation;
double X, Y, Z, Dx, Dy, Dz;
} TPlaneData; } TPlaneData;
typedef std::list<TPlaneData> TPlaneDataList; typedef std::list<TPlaneData> TPlaneDataList;
typedef std::map<int, TPlaneDataList> TPlaneDataMap; typedef std::map<int, TPlaneDataList> TPlaneDataMap;
@ -5868,31 +5893,80 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
continue; continue;
QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts ); QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
if( aPropertyValueList.size() != 4 ) if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
continue; continue;
TPlaneData aPlaneData; TPlaneData aPlaneData;
aPlaneData.Id = aClippingPlaneId; aPlaneData.Id = aClippingPlaneId;
ok = false; ok = false;
aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok ); aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
if( !ok ) if( !ok )
continue; continue;
ok = false; ok = false;
aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok ); aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
if( !ok ) if( !ok )
continue; continue;
ok = false; if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok ); {
if( !ok ) ok = false;
continue; aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
if( !ok )
continue;
ok = false; ok = false;
aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok ); aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
if( !ok ) if( !ok )
continue; continue;
ok = false;
aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
if( !ok )
continue;
ok = false;
aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
if( !ok )
continue;
ok = false;
aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
if( !ok )
continue;
ok = false;
aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
if( !ok )
continue;
ok = false;
aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
if( !ok )
continue;
}
else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
ok = false;
aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
if( !ok )
continue;
ok = false;
aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
if( !ok )
continue;
ok = false;
aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
if( !ok )
continue;
ok = false;
aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
if( !ok )
continue;
}
TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ]; TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
aPlaneDataList.push_back( aPlaneData ); aPlaneDataList.push_back( aPlaneData );
@ -6315,21 +6389,18 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
// Clipping // Clipping
else if (paramNameStr.startsWith("ClippingPlane")) { else if (paramNameStr.startsWith("ClippingPlane")) {
QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts); QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
// old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles) // old format - val looks like "Off" or "1:0:0:0.5:0:0"
// (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
// or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
// (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
// new format - val looks like "Off" or "0" (plane id) // new format - val looks like "Off" or "0" (plane id)
// (note: in new format "Off" value is used only for consistency, // (note: in new format "Off" value is used only for consistency,
// so it is processed together with values in old format) // so it is processed together with values in old format)
bool anIsOldFormat = ( vals.count() == 4 || val == "Off" ); bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
if( anIsOldFormat ) { if( anIsOldFormat ) {
if (paramNameStr == "ClippingPlane1" || val == "Off") if (paramNameStr == "ClippingPlane1" || val == "Off")
aSmeshActor->RemoveAllClippingPlanes(); aSmeshActor->RemoveAllClippingPlanes();
if (val != "Off") { if (val != "Off") {
SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
double aDistance = vals[1].toFloat();
double anAngle[2];
anAngle[0] = vals[2].toFloat();
anAngle[1] = vals[3].toFloat();
QList<SUIT_ViewManager*> lst; QList<SUIT_ViewManager*> lst;
getApp()->viewManagers(viewerTypStr, lst); getApp()->viewManagers(viewerTypStr, lst);
// SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
@ -6341,13 +6412,35 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
SMESH::TActorList anActorList; SMESH::TActorList anActorList;
anActorList.push_back( aSmeshActor ); anActorList.push_back( aSmeshActor );
SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle); aPlane->myViewWindow = vtkView;
SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
aPlane->PlaneMode = aMode;
bool isOpenGLClipping = ( bool )vals[1].toInt();
aPlane->IsOpenGLClipping = isOpenGLClipping;
if ( aMode == SMESH::Absolute ) {
aPlane->myAbsoluteOrientation = vals[2].toInt();
aPlane->X = vals[3].toFloat();
aPlane->Y = vals[4].toFloat();
aPlane->Z = vals[5].toFloat();
aPlane->Dx = vals[6].toFloat();
aPlane->Dy = vals[7].toFloat();
aPlane->Dz = vals[8].toFloat();
}
else if ( aMode == SMESH::Relative ) {
aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
aPlane->myDistance = vals[3].toFloat();
aPlane->myAngle[0] = vals[4].toFloat();
aPlane->myAngle[1] = vals[5].toFloat();
}
if( aPlane ) { if( aPlane ) {
SMESH::ClippingPlaneInfo aClippingPlaneInfo; if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
aClippingPlaneInfo.Plane = aPlane; SMESH::ClippingPlaneInfo aClippingPlaneInfo;
aClippingPlaneInfo.ActorList = anActorList; aClippingPlaneInfo.Plane = aPlane;
aClippingPlaneInfoList.push_back( aClippingPlaneInfo ); aClippingPlaneInfo.ActorList = anActorList;
aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
}
} }
} }
} }
@ -6468,24 +6561,41 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) { for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
const TPlaneData& aPlaneData = *anIter4; const TPlaneData& aPlaneData = *anIter4;
if( aPlaneData.Id == aPlaneId ) { if( aPlaneData.Id == aPlaneId ) {
SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane->myViewWindow = aViewWindow;
aViewWindow, aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
(SMESH::Orientation)aPlaneData.Orientation, aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
aPlaneData.Distance, if ( aPlane->PlaneMode == SMESH::Absolute ) {
aPlaneData.Angle ); aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
aPlane->X = aPlaneData.X;
aPlane->Y = aPlaneData.Y;
aPlane->Z = aPlaneData.Z;
aPlane->Dx = aPlaneData.Dx;
aPlane->Dy = aPlaneData.Dy;
aPlane->Dz = aPlaneData.Dz;
}
else if ( aPlane->PlaneMode == SMESH::Relative ) {
aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
aPlane->myDistance = aPlaneData.Distance;
aPlane->myAngle[0] = aPlaneData.Angle[0];
aPlane->myAngle[1] = aPlaneData.Angle[1];
}
if( aPlane ) { if( aPlane ) {
SMESH::ClippingPlaneInfo aClippingPlaneInfo; if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
aClippingPlaneInfo.Plane = aPlane; SMESH::ClippingPlaneInfo aClippingPlaneInfo;
aClippingPlaneInfo.ActorList = anActorList; aClippingPlaneInfo.Plane = aPlane;
aClippingPlaneInfoList.push_back( aClippingPlaneInfo ); aClippingPlaneInfo.ActorList = anActorList;
aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
}
} }
break; break;
} }
} }
} }
} }
// update all VTK views // update all VTK views
QList<SUIT_ViewManager*> lst; QList<SUIT_ViewManager*> lst;
getApp()->viewManagers(lst); getApp()->viewManagers(lst);
@ -6493,6 +6603,14 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
SUIT_ViewModel* vmodel = (*it)->getViewModel(); SUIT_ViewModel* vmodel = (*it)->getViewModel();
if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) { if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView(); SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
// set OpenGL clipping planes
VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
vtkActorCollection* anAllActors = aCopy.GetActors();
anAllActors->InitTraversal();
while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
anActor->SetOpenGLClippingPlane();
vtkView->getRenderer()->ResetCameraClippingRange(); vtkView->getRenderer()->ResetCameraClippingRange();
vtkView->Repaint(); vtkView->Repaint();
} }
@ -6691,7 +6809,6 @@ bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
return false; return false;
} }
SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor() SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
{ {
static QList<QColor> colors; static QList<QColor> colors;

File diff suppressed because it is too large Load Diff

View File

@ -46,60 +46,74 @@
#include <map> #include <map>
#include <vector> #include <vector>
class QGroupBox;
class QLabel; class QLabel;
class QPushButton; class QPushButton;
class QCheckBox; class QCheckBox;
class QComboBox; class QComboBox;
class QListWidget; class QListWidget;
class QListWidgetItem; class QListWidgetItem;
class QStackedLayout;
class QSlider;
class QMenu;
class SALOME_Actor; class SALOME_Actor;
class SMESHGUI; class SMESHGUI;
class SMESH_Actor; class SMESH_Actor;
class SMESHGUI_SpinBox; class QtxDoubleSpinBox;
class vtkActor; class vtkActor;
class vtkDataSetMapper; class vtkDataSetMapper;
class vtkPlaneSource; class vtkPlaneSource;
class vtkCallbackCommand;
class vtkObject;
class vtkImplicitPlaneWidget;
namespace SMESH namespace SMESH
{ {
enum Mode { Absolute, Relative };
enum Orientation { XY, YZ, ZX }; enum Orientation { XY, YZ, ZX };
class OrientedPlane: public vtkPlane class OrientedPlane: public vtkPlane
{ {
QPointer<SVTK_ViewWindow> myViewWindow;
vtkDataSetMapper* myMapper; vtkDataSetMapper* myMapper;
public: public:
static OrientedPlane *New(); static OrientedPlane *New();
static OrientedPlane *New(SVTK_ViewWindow* theViewWindow); static OrientedPlane *New(SVTK_ViewWindow* theViewWindow);
vtkTypeMacro (OrientedPlane, vtkPlane); vtkTypeMacro (OrientedPlane, vtkPlane);
SMESH::Orientation myOrientation; QPointer<SVTK_ViewWindow> myViewWindow;
float myDistance; SMESH::Orientation myRelativeOrientation;
double myAngle[2]; float myDistance;
double myAngle[2];
double X, Y, Z, Dx, Dy, Dz;
int myAbsoluteOrientation;
bool IsInvert;
bool IsOpenGLClipping;
Mode PlaneMode;
vtkPlaneSource* myPlaneSource; vtkPlaneSource* myPlaneSource;
SALOME_Actor *myActor; SALOME_Actor *myActor;
void SetOrientation (SMESH::Orientation theOrientation) { myOrientation = theOrientation; } void SetOrientation (SMESH::Orientation theOrientation) { myRelativeOrientation = theOrientation; }
SMESH::Orientation GetOrientation() { return myOrientation; } SMESH::Orientation GetOrientation() { return myRelativeOrientation; }
void SetDistance (float theDistance) { myDistance = theDistance; } void SetDistance (float theDistance) { myDistance = theDistance; }
float GetDistance() { return myDistance; } float GetDistance() { return myDistance; }
void ShallowCopy (OrientedPlane* theOrientedPlane); void ShallowCopy (OrientedPlane* theOrientedPlane);
OrientedPlane* InvertPlane ();
protected: protected:
OrientedPlane(SVTK_ViewWindow* theViewWindow); OrientedPlane(SVTK_ViewWindow* theViewWindow);
OrientedPlane(); OrientedPlane();
void Init(); void Init();
~OrientedPlane(); ~OrientedPlane();
private: private:
// Not implemented. // Not implemented.
OrientedPlane (const OrientedPlane&); OrientedPlane (const OrientedPlane&);
void operator= (const OrientedPlane&); void operator= (const OrientedPlane&);
}; };
typedef vtkSmartPointer<OrientedPlane> TPlane; typedef vtkSmartPointer<OrientedPlane> TPlane;
@ -133,81 +147,132 @@ public:
SMESHGUI_ClippingDlg( SMESHGUI*, SVTK_ViewWindow* ); SMESHGUI_ClippingDlg( SMESHGUI*, SVTK_ViewWindow* );
~SMESHGUI_ClippingDlg(); ~SMESHGUI_ClippingDlg();
double getDistance() const; static bool AddPlane ( SMESH::TActorList theActorList,
void setDistance( const double ); SMESH::OrientedPlane* thePlane );
double getRotation1() const;
double getRotation2() const;
void setRotation( const double, const double );
// used in SMESHGUI::restoreVisualParameters() to avoid
// declaration of OrientedPlane outside of SMESHGUI_ClippingDlg.cxx
static SMESH::OrientedPlane* AddPlane (SMESH::TActorList theActorList,
SVTK_ViewWindow* theViewWindow,
SMESH::Orientation theOrientation,
double theDistance,
const double theAngle[2]);
protected: protected:
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
static void ProcessEvents( vtkObject* theObject,
unsigned long theEvent,
void* theClientData,
void* theCallData);
private: private:
void initializePlaneData(); double getDistance() const;
void setDistance( const double );
double getRotation1() const;
double getRotation2() const;
void setRotation( const double, const double );
void synchronize(); void setOrigin(double theVal[3]);
void setDirection(double theVal[3]);
void updateActorList(); void initializePlaneData();
SMESH::TActorList getCurrentActors(); void initParam();
void synchronize();
void updateActorList();
void updateActorItem( QListWidgetItem* theItem,
bool theUpdateSelectAll,
bool theUpdateClippingPlaneMap );
SMESH::TActorList getCurrentActors();
void updateActorItem( QListWidgetItem* theItem, void dumpPlaneData() const;
bool theUpdateSelectAll, void absolutePlaneToRelative ( double theOrigin[3], double theDir[3] );
bool theUpdateClippingPlaneMap ); void setBoundsForPreviewWidget();
vtkImplicitPlaneWidget* createPreviewWidget();
void dumpPlaneData() const;
private: private:
SMESHGUI* mySMESHGUI; SMESHGUI* mySMESHGUI;
SVTK_ViewWindow* myViewWindow; SVTK_ViewWindow* myViewWindow;
SMESH::TPlaneDataVector myPlanes; SMESH::TPlaneDataVector myPlanes;
vtkCallbackCommand* myCallback;
vtkImplicitPlaneWidget* myPreviewWidget;
double myBounds[6];
QComboBox* ComboBoxPlanes; QComboBox* ComboBoxPlanes;
QCheckBox* isOpenGLClipping;
QPushButton* buttonNew; QPushButton* buttonNew;
QMenu* MenuMode;
QPushButton* buttonDelete; QPushButton* buttonDelete;
QListWidget* ActorList; QListWidget* ActorList;
QCheckBox* SelectAllCheckBox; QCheckBox* SelectAllCheckBox;
QStackedLayout* ModeStackedLayout;
QGroupBox* GroupAbsolutePoint;
QLabel* TextLabelX;
QLabel* TextLabelY;
QLabel* TextLabelZ;
QtxDoubleSpinBox* SpinBox_X;
QtxDoubleSpinBox* SpinBox_Y;
QtxDoubleSpinBox* SpinBox_Z;
QPushButton* resetButton;
QGroupBox* GroupAbsoluteDirection;
QLabel* TextLabelDx;
QLabel* TextLabelDy;
QLabel* TextLabelDz;
QtxDoubleSpinBox* SpinBox_Dx;
QtxDoubleSpinBox* SpinBox_Dy;
QtxDoubleSpinBox* SpinBox_Dz;
QPushButton* invertButton;
QComboBox* CBAbsoluteOrientation;
QGroupBox* GroupRelative;
QLabel* TextLabelOrientation; QLabel* TextLabelOrientation;
QComboBox* ComboBoxOrientation;
QLabel* TextLabelDistance; QLabel* TextLabelDistance;
SMESHGUI_SpinBox* SpinBoxDistance; QLabel* TextLabelRotation1;
QLabel* TextLabelRot1; QLabel* TextLabelRotation2;
SMESHGUI_SpinBox* SpinBoxRot1; QLabel* TLValueDistance;
QLabel* TextLabelRot2; QLabel* TLValueRotation1;
SMESHGUI_SpinBox* SpinBoxRot2; QLabel* TLValueRotation2;
QSlider* SliderDistance;
QSlider* SliderRotation1;
QSlider* SliderRotation2;
QComboBox* CBRelativeOrientation;
QCheckBox* PreviewCheckBox; QCheckBox* PreviewCheckBox;
QCheckBox* AutoApplyCheckBox; QCheckBox* AutoApplyCheckBox;
QPushButton* buttonOk; QPushButton* buttonOk;
QPushButton* buttonCancel; QPushButton* buttonCancel;
QPushButton* buttonApply; QPushButton* buttonApply;
QPushButton* buttonHelp; QPushButton* buttonHelp;
bool myIsSelectPlane; bool myIsSelectPlane;
bool myIsPreviewMoved;
QString myHelpFileName; QString myHelpFileName;
SMESH::Mode CurrentMode;
protected slots: protected slots:
virtual void reject(); virtual void reject();
public slots: public slots:
void onSelectPlane( int ); void onModeAbsolute();
void ClickOnNew(); void onModeRelative();
void ClickOnDelete(); void ClickOnNew();
void onActorItemChanged( QListWidgetItem* ); void ClickOnDelete();
void onSelectAll( int ); void onSelectPlane( int );
void onSelectOrientation( int ); void onSelectAll( int );
void SetCurrentPlaneParam(); void onActorItemChanged( QListWidgetItem* );
void OnPreviewToggle( bool ); void SetCurrentPlaneParam();
void onAutoApply(bool);
void ClickOnOk(); void onIsOpenGLClipping(bool);
void ClickOnApply(); void OnPreviewToggle( bool );
void ClickOnHelp(); void onAutoApply(bool);
void ClickOnOk();
void ClickOnApply();
void ClickOnHelp();
void SliderDistanceHasMoved(int);
void SliderRotation1HasMoved(int);
void SliderRotation2HasMoved(int);
void onSelectAbsoluteOrientation( int );
void onSelectRelativeOrientation( int );
void onReset();
void onInvert();
}; };
#endif // SMESHGUI_CLIPPINGDLG_H #endif // SMESHGUI_CLIPPINGDLG_H

View File

@ -1396,6 +1396,20 @@ namespace SMESH
double theDist, double theDist,
double theBounds[6], double theBounds[6],
double theOrigin[3] ) double theOrigin[3] )
{
bool anIsOk = false;
anIsOk = ComputeBounds( theActorList, theBounds );
if( !anIsOk )
return false;
DistanceToPosition( theBounds, theNormal, theDist, theOrigin );
return true;
}
bool ComputeBounds( std::list<vtkActor*> theActorList,
double theBounds[6])
{ {
bool anIsOk = false; bool anIsOk = false;
theBounds[0] = theBounds[2] = theBounds[4] = VTK_DOUBLE_MAX; theBounds[0] = theBounds[2] = theBounds[4] = VTK_DOUBLE_MAX;
@ -1416,12 +1430,7 @@ namespace SMESH
} }
} }
} }
return anIsOk;
if( !anIsOk )
return false;
DistanceToPosition( theBounds, theNormal, theDist, theOrigin );
return true;
} }
#ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_PLOT2DVIEWER

View File

@ -206,6 +206,14 @@ SMESHGUI_EXPORT
double theDist, double theDist,
double theBounds[6], double theBounds[6],
double theOrigin[3] ); double theOrigin[3] );
bool ComputeBounds( std::list<vtkActor*> theActorList,
double theBounds[6]);
void PositionToDistance( double theBounds[6],
double theDirection[3],
double thePos[3],
double& theDist );
SMESHGUI_EXPORT SMESHGUI_EXPORT
void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews = false ); void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews = false );
}; };

View File

@ -6548,6 +6548,10 @@ It is impossible to read point coordinates from file</translation>
<source>CLIP_PLANES</source> <source>CLIP_PLANES</source>
<translation>Clipping planes</translation> <translation>Clipping planes</translation>
</message> </message>
<message>
<source>IS_OPENGL_CLIPPING</source>
<translation>OpenGL clipping</translation>
</message>
<message> <message>
<source>MESHES_SUBMESHES_GROUPS</source> <source>MESHES_SUBMESHES_GROUPS</source>
<translation>Meshes, sub-meshes and groups</translation> <translation>Meshes, sub-meshes and groups</translation>
@ -6608,6 +6612,30 @@ It is impossible to read point coordinates from file</translation>
<source>NO_PLANES</source> <source>NO_PLANES</source>
<translation>No planes</translation> <translation>No planes</translation>
</message> </message>
<message>
<source>ABSOLUTE</source>
<translation>Absolute</translation>
</message>
<message>
<source>RELATIVE</source>
<translation>Relative</translation>
</message>
<message>
<source>BASE_POINT</source>
<translation>Base point</translation>
</message>
<message>
<source>DIRECTION</source>
<translation>Direction</translation>
</message>
<message>
<source>RESET</source>
<translation>Reset</translation>
</message>
<message>
<source>INVERT</source>
<translation>Invert</translation>
</message>
</context> </context>
<context> <context>
<name>SMESHGUI_DuplicateNodesDlg</name> <name>SMESHGUI_DuplicateNodesDlg</name>

View File

@ -6486,6 +6486,10 @@ Il y a trop peu de points dans le fichier </translation>
<source>CLIP_PLANES</source> <source>CLIP_PLANES</source>
<translation>Plans de découpe</translation> <translation>Plans de découpe</translation>
</message> </message>
<message>
<source>IS_OPENGL_CLIPPING</source>
<translation>OpenGL découpage</translation>
</message>
<message> <message>
<source>MESHES_SUBMESHES_GROUPS</source> <source>MESHES_SUBMESHES_GROUPS</source>
<translation>Maillages, sous-maillages et groupes</translation> <translation>Maillages, sous-maillages et groupes</translation>
@ -6546,6 +6550,30 @@ Il y a trop peu de points dans le fichier </translation>
<source>NO_PLANES</source> <source>NO_PLANES</source>
<translation>Pas de plans</translation> <translation>Pas de plans</translation>
</message> </message>
<message>
<source>ABSOLUTE</source>
<translation>Absolute</translation>
</message>
<message>
<source>RELATIVE</source>
<translation>Relative</translation>
</message>
<message>
<source>RESET</source>
<translation>Réinitialiser</translation>
</message>
<message>
<source>INVERT</source>
<translation>Inverser</translation>
</message>
<message>
<source>BASE_POINT</source>
<translation>Le point fondamental</translation>
</message>
<message>
<source>DIRECTION</source>
<translation>Direction</translation>
</message>
</context> </context>
<context> <context>
<name>SMESHGUI_DuplicateNodesDlg</name> <name>SMESHGUI_DuplicateNodesDlg</name>